- Home /
Unity 4: GUI.Button does not work anymore?
Hey guys! I'm trying out the new Unity 4.0 and have a big problem with GUI.Button. This method worked well in Version 3.5 but no buttons appear if I try this in Unity 4.0. I created a new empty GameObject and wrote the script below. After saving the script I attached it to the GameObject.
float buttonX;
float buttonY;
float buttonWidth;
float buttonHeight;
// Use this for initialization
void Start () {
buttonX = Screen.width * 0.05f;
buttonY = Screen.width * 0.05f;
buttonWidth = Screen.width * 0.1f;
buttonHeight = Screen.width * 0.1f;
}
//Draw GUI
void onGUI(){
GUI.Button (new Rect(buttonX, buttonY, buttonWidth, buttonHeight), "Start");
}
Maybe I am wrong but I think this should work. Am I doing it wrong or is it something new in Unity 4.0?
Thanks a lot!
mischaal
Answer by GerryM · Nov 15, 2012 at 10:10 PM
Use `void OnGUI()` instead of `void onGUI()` and it'll work.
Your answer
Follow this Question
Related Questions
Button then instanitates gameobject 1 Answer
How to hook up the particle system to jump animation? 1 Answer
Make more buttons appear, on button click. 1 Answer
Null reference exception[SOLVED] 1 Answer
GUI Button Animation Cue 1 Answer