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
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.
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
}
}