Skip to content

Instantly share code, notes, and snippets.

@rc1
Created March 8, 2016 13:42
Show Gist options
  • Save rc1/22f38b851cb3efc54a28 to your computer and use it in GitHub Desktop.
Save rc1/22f38b851cb3efc54a28 to your computer and use it in GitHub Desktop.
LightToggler
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