- Home /
Making it display a Gui
I am making a inventory for my game. This is part of my coding...
function Update ()
{
Input.GetButton(Inventory)
show.inventoryGui;
}
I typed that in and have the Inventory input set up and it gives me this error
Assets/Scripts/CharacterSave.js(50,35): UCE0001: ';' expected. Insert a semicolon at the end.
If you have any help at all please post...
Thanks in advance for anyone that helps me with this...
Answer by skovacs1 · Oct 08, 2010 at 07:37 PM
you like ellipses...
Is Inventory a button or a type?
Input.GetButton()
takes a String
defining a button configured in your input manager.
If you have defined a button Inventory, then you probably wanted
Input.GetButton("Inventory")
If you want the code to only act when the button is held down, you probably wanted
Input.GetButtonDown()
If you wanted the inventory thing to only happen when the Input.Get...
was true, then you should put it inside of an if
statement
if(Input.GetButtonDown("Inventory"))
//show your GUI
What is show
supposed to be? If show
is an enum
, class
or class instance, then this is syntactically correct, but will not actually do anything.
What is inventoryGui
supposed to be? If it is a variable of a class, then you should be assigning or changing it like show.inventoryGui = something;
. If it is an enum
, then you should be assigning something to have its value like something = show.inventoryGui;
. If it is a function, you must call it with parentheses like show.inventoryGui();
.
Answer by stevesterrr · Jul 24, 2012 at 12:53 PM
var button : boolean;
function Update()
{
//if user presses Tab then the GUI should appear;
if (Input.GetKeyDown(KeyCode.Tab))
{
button = true;
}
//if he's not pressing Tab anymore let's make the GUI dissapear;
if (Input.GetKeyUp(KeyCode.Tab))
{
button = false;
}
}
//now let's make our GUI;
function OnGUI()
{
if (button == true)
{
// you can change the values and the text displayed as you wish;
GUI.Box (Rect (100,100,100,100), "it works" );
}
}
add it to your player or camera and it should work ;)
Your answer
Follow this Question
Related Questions
Lerpz tutorial multiple errors.HELP!!!! 4 Answers
Scripting Error when drawing texture to custom window; What am I doing wrong? 1 Answer
Limit rotation for a statue puzzle 1 Answer
Semicolon? WHAT? HELP ME! 1 Answer
Collision Detector script 1 Answer