- Home /
Expecting :, found ; and can't figure it out...
Hey all, this is probably really simple, but I have only a basic understanding of java, and have spent too long trying to find a fix for this... I get the aforementioned error on line 5.57 in my code, pasted below.
function OnGUI () {
GUI.Box (Rect ((Screen.width/2)-60,(Screen.height/2)-50,120,105), "Menu");
GUI.Button (Rect ((Screen.width/2)-50,(Screen.height/2)-25,100,30), "Load Level 1"); {
EditorApplication.OpenScene("TestScene");
}
GUI.Button (Rect ((Screen.width/2)-50,(Screen.height/2)+15,100,30), "Load Level 2"); {
}
}
Am I doing this the wrong way or...?
Thanks in advance,
Shade
JavaScript is not Java. UnityScript is not really JavaScript.
Answer by Jessy · Feb 25, 2012 at 04:24 PM
You're putting a semicolon before your curly braces, and you're not using the if keyword. The documentation show you how to do it, but they don't have curly braces. Curly braces are optional if you would only have one statement between them.
http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html
Answer by AchillesWF · Feb 26, 2012 at 12:01 AM
I think it may be that you are not really constructing a Rect to pass to the GUI.Box function. Try creating your rectangles in the function using locally declared variables and then pass them, or "new" to instantiate them.
Your answer
![](https://koobas.hobune.stream/wayback/20220613064451im_/https://answers.unity.com/themes/thub/images/avi.jpg)