- Home /
 
 
               Question by 
               valen boubee · Sep 17, 2012 at 06:43 PM · 
                c#rpg  
              
 
              Problem with text blinking
i'm having a problem to create the text that says press any button and making it blink. i have create the background and the text but i can't make it blink. i'm doing it in C#. here is my code
 using UnityEngine;
 using System.Collections;
 
 public class MainMenu : MonoBehaviour {
     public GUITexture guiTexture;
     private int GuiLabel = false;
     
     void OnGUI(){
         CreateBackgroundBox();
         GuilabelStart();
         
          if (displayLabel == true)
 
  GUILayout.Label("Press Any Button");
         
     }
     
     private void CreateBackgroundBox(){
         GUI.Box(new Rect(0, 0, Screen.width, Screen.height), "");
     }
     
     private int GuilabelStart(){
         while(1){
              GuiLabel = true;
 
  yield return new WaitForSeconds(.5);
 
  GuiLabel = false;
 
  yield return new WaitForSeconds(.5); 
 
         }
     }
     
     
 }
 
 
              
               Comment
              
 
               
              Does your code even compile? You use int which means integer (Numbers like 1 2 3 ...) as a boolean (true false). Your GuilabelStart does not return an int either and must be an IEnumerator if you want to use yield.
 
               Best Answer 
              
 
              Answer by hvilela · Sep 18, 2012 at 03:50 AM
Try something like this:
 void OnGUI(){
   if (Time.time - (int) Time.time < 0.5) {
     GUILayout.Label("Press Any Button");
   }
 }
 
              Your answer
 
             Follow this Question
Related Questions
A node in a childnode? 1 Answer
Die Function Help With C# 1 Answer
Distribute terrain in zones 3 Answers
Multiple Cars not working 1 Answer
what am I doing wrong 1 Answer