So I have been creating a very simple inventory script as I am new to scripting, and ran into an error. I have tried googling it countless times and came up with nothing. Here is the issue: I cannot hide the buttons after I create them. I am trying to get it to where I can press tab to open the inventory and escape to close it.
#pragma strict
var Can : GameObject;
var rock : float = 0;
var wood : float = 0;
var Open2 : boolean = false;
var open : boolean = false;
var a = GUI;
var b = GameObject;
function Update () {
if (Input.GetKeyDown (KeyCode.Tab)){
open = true;
if (Input.GetKey (KeyCode.Escape)){
open = false;
}
}
if (open == false){
}
}
function OnGUI () {
if (GUI.Button (Rect (10, 10, 100, 20), "Inventory")){
open = true;
}
if (open == true){
var a : GUI = GUI.Button (Rect (10, 40, 100, 20), "Rock: "+rock);
var b : GUI = GUI.Button (Rect (10, 70, 100, 20), "wood: "+wood);
}
if (open == false){
}
}
And I am getting the error of:
Assets/MainInv.js(30,42): BCE0022: Cannot convert ‘boolean’ to ‘UnityEngine.GUI’.
Thanks in advance!
Ok, I have actually changed them to labels, because I was not thinking when I made this as I did not need buttons. Now I just need to know how to remove the Rock label and Wood label. Thanks for your help!