- Home /
Question by
iDesign · Jul 26, 2014 at 07:54 PM ·
togglegui.buttontoggle buttongui.box
show/hide GUI.box with a GUI.button
I did some research but couldn't seem to find anything significant. Here's what I have so far:
var showInventory = false;
function OnGUI () {
if(GUI.Button(Rect(210,80,35,30), "Open")){
showInventory = true;
}
if (showInventory) {
GUI.Box(Rect (10,50,315,300), "Inventory"); // x, y, w, h
}
}
When the user clicks the GUI.Button, the GUI.Box should popup, when he clicks it again, it should disappear and etc... (a toggle button basically).
Comment
Best Answer
Answer by robertbu · Jul 26, 2014 at 07:54 PM
Change line 5 to:
showInventory = !showInventory;