- Home /
Help with Void Boolean Text problem
//Javascript
function OnGUI()
{
if(GUI.Label(Rect(500,500,250,50), "Reset"))
{
Application.Load("yourCurrentScene");
}
}
This is my script. It says at 3;13 I have a void problem, help? (Im new, just started using unity a few weeks ago)
ps: If you select the error in the console there's a more detailed description in the lower half of the console window. You can select the text in there and copy it, so you don't have to type what Unity tells you.
Answer by Bunny83 · Oct 10, 2013 at 06:48 PM
It certainly doesn't say you "have a void problem". Post the exact error and show us the exact line in which the compiler has found the error.
However i think i've found your problem. You use a Label the same way as you would use a Button. That's not possible since a Label doesn't return anything.
If you want a button you have to use a button:
function OnGUI()
{
if(GUI.Button(Rect(500,500,250,50), "Reset"))
{
Application.Load("yourCurrentScene");
}
}
If you want a button that looks like a label you have to use a different style for the button:
function OnGUI()
{
if(GUI.Button(Rect(500,500,250,50), "Reset", "label"))
{
Application.Load("yourCurrentScene");
}
}
Your answer
Follow this Question
Related Questions
Trying to make a simple inventory: 0 Answers
How to prevent numbers in the input box and just display text? 0 Answers
Need help with building system 1 Answer
Chain Texture for Line Renderer 1 Answer
Creating a teleportation gun 1 Answer