- Home /
How to Hide GUI Box Once Clicked?
Hi there. I'm working on an RPG game called 'Lost Worlds'. I've finally got the 3rd Person Player working in the game and now i'm working on the GUI. What i've done is that once you load up the game,a GUI Box displays, which has text introducing the player to the game. Please note that i have novice knowledge on scripting so please help me with this.
What i want to know is, what is the code for Javascript to hide the GUI Box once it is clicked so that the player, once read the message, can just click on it to cancel it out/ hide it?
Thanks! :)
Answer by AliAzin · Oct 27, 2010 at 05:08 PM
you can do something like this:
var showBox = true; function OnGUI(){ if (GUILayout.Button("close this")) showBox = false;
if (showBox) GUILayout.Box("your Box");
}
Answer by Steven Brewis · Nov 04, 2010 at 08:38 PM
is there a way to do exactly that, but on collision?
get rid of the first 'if' statement in on gui, then add this above function OnCollisionEnter () { showBox = false; }
the gameobject needs a collider.
Your answer
Follow this Question
Related Questions
NGUI: Recommended way of hiding/showing multiple menu panels? 1 Answer
Hide GUI while switchcam 3 Answers
Object Creation with GUI Button. 1 Answer
hide button 1 Answer
show popup message in unity 3d 1 Answer