How can I Restart the game fast?

How can I easily make it so that my standalone Unity project restarts with the press of a button?

I have one scene and I need to make it so that restarts when I press ENTER

Any tips or pointers would be appreciated!

If you have only one scene 'Restart' means reloading your first level. You could use this:

function Update  () {  
  if (Input.GetKeyDown (KeyCode.Return)) {  
    Application.LoadLevel (0);  




Easy, make another scene... empty.. thay jumps directly to your game scene. and when you end, load this scene (Application.LoadLevel("EmpryScene");)

And put an empty GamObject to your gameScene and attach this script.

I notice that putting Time.timeSinceLevelLoad; instead of Time.time reloads the scene and clear all variables.

Do not forget to put a value into the variable startTime in your inspector panel when yo attach this script in the empty Game Object that you just has created..

var isPaused : boolean = false; var startTime : float; //(in seconds) static var timeRemaining : float; //(in seconds)

function Update() { if (!isPaused) { // make sure the timer is not paused DoCountDown(); }


function DoCountDown() { timeRemaining = startTime - Time.timeSinceLevelLoad; ////////////// Debug.Log("time remaining = " + timeRemaining); ////////////// if (timeRemaining <0) { timeRemaining = 0; isPaused = true; TimeIsUp(); } }

// clock reaches zero function TimeIsUp() { Debug.Log("Time is Up"); //startTime = 12; Application.LoadLevel("Navigation"); }