Created
March 8, 2016 13:42
-
-
Save rc1/22f38b851cb3efc54a28 to your computer and use it in GitHub Desktop.
LightToggler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class LightToggler : MonoBehaviour { | |
[RangeAttribute(0.01f, 20.0f)] | |
public float toggleEvery = 1; | |
private float _lastToggle; | |
// Use this for initialization | |
void Start () { | |
} | |
// Update is called once per frame | |
void Update () { | |
if (Time.time - _lastToggle > toggleEvery) { | |
Light light = GetComponent<Light> (); | |
light.enabled = !light.enabled; | |
_lastToggle = Time.time; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment