- Home /
what is the compile error on this script?
I have been stuck forever (I am not a good scripter) on what the compile error is on this script. can anybody tell me what im doing wrong? // JavaScript function OnGUI () { // Make a background box GUI.Box (Rect (10,10,1000,500), "Menu");
// Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
if (GUI.Button (Rect (20,40,1000,20), "Desert")) {
Application.LoadLevel (1);
}
// Make the second button.
if (GUI.Button (Rect (20,70,1000,20), "Mountains")) {
Application.LoadLevel (2);
}
// Make the third button.
if (GUI.Button (Rect (20,100,1000,20), "Third")) {
Application.LoadLevel (3);
}
}
EDIT: I do not think I have been clear enough that there is no error message I can find. he is a picture of my problem:
[1]: /storage/temp/11929-error.png
Compiles and runs for me. Any chance you authored it inside a C# script file ins$$anonymous$$d of a Javascript file? It always helps us figure out what is going on if you copy and past the error message from the Console in Unity.
smug: I get a compile error on line 1... "I" is not defined :P
Are the scenes added to your "Build Settings" window?
You really should copy/paste the error message you are getting from the Unity console too as it will help us better help you. Like Ben mentioned above, are there at least 4 scenes in your Build Settings? That seems like the most likely reason to get an error in the code snippet you posted.
Answer by SubatomicHero · Jun 12, 2013 at 02:09 PM
So it looks like you probably copied and pasted your script from somewhere else? This error is thrown when there is some form of white space garbage sat in your script that you simply cannot see.
My advice is to create a new script and type copy (don't copy and paste) the script over to your new script and use that one.
Answer by Slobdell · Jun 14, 2013 at 12:03 AM
I've had issues with MonoDevelop lately, things like instantiating a Vector3 array, and then further down in my script when I try to do something with it Mono is telling me it's a Vector3, not a Vector3 array. Usually fixes if I clean and build again, sometimes restart Mono. Try that maybe...
Your answer
Follow this Question
Related Questions
GUI Scale Problem 1 Answer
Error: you are pushing more GUIClips than you are poping. 1 Answer
Bool script error 1 Answer
A GUI error in script??? HELP,Please!! 1 Answer
Tracking Down GUI Errors 0 Answers