- Home /
OnGUI not working
I was going to make a GUI for my project today. So I made a JavaScript called testGui.js
This is my code:
function OnGUI()
{
if (GUI.Button(new Rect(10,10, 100, 100), "Test")) {
print("Test");
}
}
But when I add it to the camera game object it I get an error:
MissingMethodException: Method not found: 'GUI.Button'.
I have done this before in an older version of Unity. I have no idea if this has to with updates or anything but the API references are still up. Can anyone tell me whats wrong with my script?
I know why the GUI isn't working I named the script GUI and it thinks I am talking about the script and not the class.
Answer by whydoidoit · Jul 20, 2012 at 08:08 PM
Is your script called GUI? If it is it will hide the real functions...
Your answer
![](https://koobas.hobune.stream/wayback/20220613074456im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
[Solved] GUI Error? 1 Answer
UnityAds - Ads not showing 0 Answers
Compiled Game Crashing 1 Answer
Fill a circle by values with onGUI 0 Answers
My buttons do not appear when paused? 2 Answers