- Home /
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); }"
Answer by Uzquiano · Apr 18, 2011 at 10:22 AM
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); } }
Answer by Uzquiano · Apr 18, 2011 at 09:09 AM
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
no i need the message confirmation when i click yes(retart the game) or no else
Wouldn't it be better to reset the position car and other things, ins$$anonymous$$d of loading the whole level again?