Advertisement
NPSF3000

GO Blink

Jul 26th, 2011
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. // Created By NPSF3000 270711
  2. // Not intended for general consumption.
  3. // Use at OWN Risk.
  4.  
  5. using UnityEngine;
  6. using System.Collections;
  7.  
  8. public class GO_Blink : MonoBehaviour
  9. {
  10.     public GameObject go;
  11.  
  12.     public float onLength = 5;
  13.     public float offLength = 5;
  14.     public float offset = 0;
  15.  
  16.     // Use this for initialization
  17.     void Start () {
  18.         if (go == null)
  19.             Debug.LogWarning("GO_Blink needs a GO assinged");
  20.         else
  21.             StartCoroutine(Blink());
  22.     }
  23.  
  24.     IEnumerator Blink()
  25.     {
  26.  
  27.         yield return new WaitForSeconds(offset);
  28.        
  29.     while (true)
  30.         {
  31.             yield return new WaitForSeconds(onLength);
  32.  
  33.             go.active = false;
  34.  
  35.             yield return new WaitForSeconds(offLength);
  36.  
  37.             go.active = true;
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement