- Home /
This question was
closed Jan 01, 2016 at 04:06 PM by
SgtShadowWalker for the following reason:
Other
Question by
SgtShadowWalker · Jun 05, 2014 at 10:05 AM ·
javascriptguijavatabguilayer
How to make the tab key to show/hide GUIlayer
I'm making a game and I think the GUI on the screen that shows the objective is distracting you from the game experience. Is there a way to make a script that if you hold the tab key, the GUIlayer is visible and that when you let go, the GUIlayer disappears?
Comment
Answer by HarshadK · Jun 05, 2014 at 11:17 AM
Below is the psuedo-code for doing this:
bool showGUI = false;
void OnGUI(){
if(showGUI) {
// Show your GUI and perform the things to be done
}
}
void Update(){
if(Input.GetKeyDown(KeyCode.Tab)){
showGUI = true;
}
if(Input.GetKeyUp(KeyCode.Tab)){
showGUI = false;
}
}
Follow this Question
Related Questions
help with errors 2 Answers
Setting Scroll View Width GUILayout 1 Answer
How to display GUI in sequence in trigger 3 Answers
Can't move GUI 1 Answer
How to add rigidbody with script? 1 Answer