- Home /
 
Hide GUI Text when button is pressed
I have a GUI Text that shows the controls. All I need to have is a script that i could attach to the GUI Text, making it disappear when "Tab" is pressed. And if I press the button again the GUI Text will reappear back in the game.
Felipe
               Comment
              
 
               
              Answer by Piflik · May 15, 2012 at 08:24 PM
Create a boolean variable and invert it on tab.
 var UIActive : boolean = false;
 function Update() {
     Input.GetKeyUp(KeyCode.Tab)
         UIActive = !UIActive;
 }
 function OnGUI() {
     if(UIActive) {
         //GUI code
     }
 }
 
              Your answer
 
             Follow this Question
Related Questions
show "labelnew" after clicking a button and hide "labelold" 1 Answer
hide button 1 Answer
Hide/Show material 2 Answers