- Home /
Main menu not working
Hey, I have been taking help from a tutorial site how to make a menu. I made a new scene that shall function as a menu and added a script to the camera that would supposedly make a menu. But nothing pops up when I start the game!
here's the script:
using UnityEngine; using System.Collections;
public class Menu : MonoBehaviour {
#region Fields
private string instructionText = "Instructions: \n Move around with the arrow keys, when you think you have found that speciall place \n in life...press space";
private int buttonWidth = 200;
private int buttonHeight = 50;
#endregion
// Use this for initialization
//void Start () {
//}
// Update is called once per frame
//void Update () {
//}
#region Functions
void OnGui ()
{
GUI.Label(new Rect(10,10,200,200), instructionText);
GUI.Button(new Rect(Screen.width / 2 - buttonWidth / 2, 200,buttonWidth, buttonHeight), "Start game");
}
#endregion
Answer by CHPedersen · Sep 08, 2011 at 09:08 AM
Nothing pops up, because the method called by the Unity engine is called OnGUI, not OnGui. See:
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnGUI.html
You just need to capitalize those two letters.
argh! I see...must have missed it. gosh, feel really stupid now Dx
but thanks anyway, would probably taken longer to get the problem if you didn't tell me =)
Not to worry, we all miss banal stuff once in a while. ;)