Advertisement
Guest User

FlashCam.cs

a guest
Feb 23rd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.71 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FlashCam : MonoBehaviour {
  6.  
  7.     public GameObject flashImage;
  8.  
  9.     // Use this for initialization
  10.     void Start () {
  11.         flashImage = GameObject.Find("Flash Image");
  12.         flashImage.SetActive(false);
  13.     }
  14.    
  15.     // Update is called once per frame
  16.     void Update () {
  17.        
  18.     }
  19.  
  20.     IEnumerator flash()
  21.     {
  22.         for (int i = 0; i < 24; i++)
  23.         {
  24.             if(flashImage.activeSelf)
  25.             {
  26.                 flashImage.SetActive(false);
  27.             }else
  28.             {
  29.                 flashImage.SetActive(true);
  30.             }
  31.             yield return null;
  32.         }
  33.     }
  34.  
  35.     void OnGUI() {
  36.        
  37.         if (GUI.Button(new Rect(10, 70, 50, 30), "Flash"))
  38.            StartCoroutine("flash");
  39.        
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement