I have a script that should:
- On collision with a gameObject tagged ‘Cube’
- Display a GUI box with some text saying ‘You got eaten by the cubes…’
- And underneath that a GUI button with the text ‘Restart Game’
- When you press the GUI button, it restarts the current level.
Unity just comes up with lots of compiler errors. Can anyone debug this code and give me a version that is correct?
Thankyou in advance…
function OnCollisionEnter (hit : Collision)
{
if(hit.transform.gameObject.name == "Cube")
{
function OnGUI() {
GUI.Box (Rect (10, 10, 100, 20),"You got eaten by the cubes...");
if GUI.Button(Rect(10,70,50,30),"Restart Game")
Application.LoadLevel(Application.loadedLevel);
}
}
}