restart level of car game

i m used this code for restart the level i need now the message confiramtion when i clic on restart as are you sure to retart the game the code" if (!IsBrowser() && !IsBeginning() && GUILayout.Button ("Restart")) { Application.LoadLevel(Application.loadedLevelName); }"

2 Answers

2

Hi,

Do you mean this?

if (!IsBrowser() && !IsBeginning() && GUILayout.Button ("Restart")) { 
 if GUILayout.Button ("Sure?"){
Application.LoadLevel(Application.loadedLevelName); 
}
}

Are you sure 'Application.LoadLevel(Application.loadedLevelName);' works? I always use Application.LoadLevel(1);//where 1 is a level number

So something like this?

var auxTime : float = 0.0;
var delayTime : float = 4.0;

if (!IsBrowser() && !IsBeginning() && GUILayout.Button ("Restart")) { 
 auxTime = Time.time;

}

function Update () {
  if ((Time.time - auxTime) > delayTime){
//SHOW HERE THE LABEL OR GUITEXT
Application.LoadLevel(Application.loadedLevelName); 
}
  }