- Home /
GUI Label "flash a Arrow"
I'm working on a GUI and have an arrow on the screen and I want to flash every 3 seconds, does anyone know how I can do this because I've been there a few days beizg and I can not find it.
I have an example below at how I did it:
 void OnGUI()
 {
     if (GOON)
     {    
         GOON = true;
         GUI.Label(new Rect(Screen.width/2+330,200,260,80), arrowright);
     }
 }
IEnumerator Life() {
     yield return new WaitForSeconds(.05f);
     lifetime-=.05f;
     
     if(lifetime<=0)
     {
         Destroy(transform.parent.gameObject);
     }
         
      if(lifetime <= 3 && !isflickering)
     {
         StartCoroutine("Flicker");
         StartCoroutine("Life");
     }
     else
     {
         StartCoroutine("Life");
     }
 }
 
 IEnumerator Flicker()
 {
     isflickering = true;
     yield return new WaitForSeconds(.3f);
     renderer.enabled = false;
     yield return new WaitForSeconds(.3f);
     renderer.enabled = true;    
     
 }
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by clunk47 · Dec 21, 2012 at 01:42 PM
 Here is a C# EXAMPLE. I stripped your original code just to show you how to get started. Simply toggle your boolean "GOON" by using GOON = !GOON. "!" means "not" or "opposite of". So if GOON is true, it will switch to false and vice versa, each time the Coroutine loops. Here is GUI_EXAMPLE.cs
 
 
 using UnityEngine;
 using System.Collections;
 
 public class GUI_EXAMPLE : MonoBehaviour 
 {
     public Texture2D  arrowright;
     bool GOON = false;
     
     void Start()
     {
         StartCoroutine("Flicker");
     }
     
     void OnGUI() 
     { 
         if (GOON) 
         {
             GUI.DrawTexture(new Rect(Screen.width/2+330,200,260,80), arrowright, ScaleMode.ScaleToFit); 
         }
     }
     
     IEnumerator Flicker()
     {
         while(true)
         {
             yield return new WaitForSeconds(0.3f);
             GOON = !GOON;
         }
     }
 }
 
Your answer
 
 
             Follow this Question
Related Questions
Equivelant of GUI.DrawSprite() ? 0 Answers
Gui.DrawTexture Working in Scene Mode, but not build or full game scene 2 Answers
Display "organized" string on GUI Label 1 Answer
Trouble using C# tooltips 1 Answer
How To Print Text Random 2 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                