Unable to make gui with c# scripts

using UnityEngine;
using System.Collections;

public class GameOverScript : MonoBehaviour {

	int score = 0;
	void Start () 
	{
		score = PlayerPrefs.GetInt ("Score");
	}

	void OnGui ()
	{
		GUI.Box (new Rect ((Screen.width-40)/2,50,60,30 ), "GAME OVER");
		GUI.Box (new Rect ((Screen.width - 40)/2 ,300,80,30), "Your Score: " + score);
		if(GUI.Button (new Rect ((Screen.width- 30)/2,350,60,30), "Retry?"));
		{
			Application.LoadLevel(0);
		}


	}
}

Any help? I cant seem to find a mistake :l

void OnGui should be void OnGUI

OnGUI is slow and hard to use. The new UI system is much better in my opinion and a lot more flexible and easier.

1 Like

ah thanks man

I am really new to unity was watching the archives and following it.

Then it is better to watch the new tutorials. OnGUI is obsolete for the most part, although it can still be handy in some situations.

1 Like

Hey! OnGUI still has a place…unfortunately. I still have to use it to make custom editor windows for my assets.

1 Like

thanks man :smile: