I downloaded Unity 3 today, and I took this exact code:
function OnGUI () {
if (GUI.Button (Rect (10,10,150,100), "I am a button")) {
print ("You clicked the button!");
}
}
from the GUI scripting guide , put it in a empty, and ran it, and it said “Button’ is not a member of ‘GUI’.”
How do I get it too work??
ilkejav
September 28, 2010, 9:58pm
2
I got the same problem. Nothing from the scripting reference works, and there is no mention of a change between 2.6 and 3.0.
Very frustrating.
I got it to work, I can’t name the script “GUI”, it doesn’t work when I do that.
you can name it gui, the unity class GUI will just cease to exist as “GUI” (will still be there as UnityEngine.GUI though) and it will expect the function in your new gui class