Basically I’m trying to make it so when I click a button a box will open and then if I click the button again I want to the box to close. Like the characters inventory button in most games.
var customSkin: UnityEngine.GUISkin;
function OnGUI () {
GUI.skin = customSkin;
GUI.Button (Rect (498,543, 40, 40),"");
}
This is the code that I have that will create the button and this is attached to the main camera. When this button is clicked I want the box to appear and then disappear when clicked again. Below is the code for the box:
var customSkin:GUISkin;
function OnGUI () {
GUI.skin = customSkin;
GUI.Box (Rect (515,135, 220, 250),"");
}
I have tried to do it like this below, which showed no errors on the compiler however it did not work.
var customSkin: UnityEngine.GUISkin;
var Guiscript : InventoryBackdrop;
function OnGUI () {
GUI.skin = customSkin;
GUI.Button (Rect (498,543, 40, 40),"");
if (GUI.Button (Rect (498, 543, 40, 40),""));
if (Guiscript.enabled == true){
Guiscript.enabled = false;
}
else {
Guiscript.enabled = true;
}
}
The script “InventoryBackdrop” is the box that I showed earlier.
Any help would be greatly appreciated,
Thanks in advance.