Basic GUI Error

I tried to do the basic GUI button code given on the Unity Manual, and Unity error log came up telling me that “Button is not a member of GUI”

here’s the code:

function OnGUI () {
	if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
		print ("You clicked the button!");
	}
}

I just realized, that this only happens if I name the .js file “GUI,” but otherwise it doesn’t notice it…

Don’t use class names that are the same as Unity class names.

–Eric

then how do I execute the script before the rest of the scene?

(I take it by class names you mean the name of the .js file, right?)

I don’t understand the question, I’m afraid.

In Javascript, the name of the script is the class name. Don’t call anything “GUI”, because that confuses Unity when you’re trying to refer to the actual GUI class.

–Eric