...
This commit is contained in:
38
Assets/JMO Assets/WarFX/Scripts/WFX_LightFlicker.cs
Normal file
38
Assets/JMO Assets/WarFX/Scripts/WFX_LightFlicker.cs
Normal file
@ -0,0 +1,38 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user