You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
550 B
38 lines
550 B
using UnityEngine; |
|
using System.Collections; |
|
|
|
/** |
|
* Rapidly sets a light on/off. |
|
* |
|
* (c) 2015, Jean Moreno |
|
**/ |
|
|
|
[RequireComponent(typeof(Light))] |
|
public class WFX_LightFlicker : MonoBehaviour |
|
{ |
|
public float time = 0.05f; |
|
|
|
private float timer; |
|
|
|
void Start () |
|
{ |
|
timer = time; |
|
StartCoroutine("Flicker"); |
|
} |
|
|
|
IEnumerator Flicker() |
|
{ |
|
while(true) |
|
{ |
|
GetComponent<Light>().enabled = !GetComponent<Light>().enabled; |
|
|
|
do |
|
{ |
|
timer -= Time.deltaTime; |
|
yield return null; |
|
} |
|
while(timer > 0); |
|
timer = time; |
|
} |
|
} |
|
}
|
|
|