- Home /
loaded level function not working on my restart or quit screen
I have a game over screen and I'm trying to script it so that the player can either restart the level he/she got the gameover on or quit the application. Below is the script I have written. The quit portion works fine but the restart is not. I'm not sure why it's not working because there's no errors appearing in the dialogue box.
Any help would be greatly appreciated.
using UnityEngine; using System.Collections;
public class GameOver : MonoBehaviour {
private bool restart;
private bool quit;
// Use this for initialization
void Start () {
restart = true;
quit = true;
}
// Update is called once per frame
void Update()
{
if (restart)
{
if (Input.GetKeyDown (KeyCode.R))
{
Application.LoadLevel (Application.loadedLevel);
}
}
if (quit)
{
if (Input.GetKeyDown (KeyCode.Escape))
{
Application.Quit ();
}
}
}
}
Comment
$$anonymous$$ake sure the scene is added to the level list in the Player/Build settings
Your answer

Follow this Question
Related Questions
Proper way for Quit Application 2 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers