- Home /
Option to restart the game?
I am trying to develop a basic car game as a iPhone app, I would like to know how can I have an option to restart the game. Please help me out.
Have another question regarding the JavaScript, how can I roundoff double number to two decimal places.
Answer by KrisCadle · Jan 22, 2012 at 10:34 PM
You could try something like this... use Application.LoadLevel to load the first level again... everything will be destroyed and "Scene1" (or whatever you name it) will load from the beginning... use a GUI Button or something to execute it...
function OnGUI() {
if (GUI.Button(Rect(10,70,50,30),"New Game"))
Application.LoadLevel ("YourSceneNameHere");
}
read more about it here... http://unity3d.com/support/documentation/ScriptReference/Application.LoadLevel.html
Answer by Akin · Jan 23, 2012 at 06:36 PM
Thanks guys, I have tried Application.LoadLevel(0); last time but it dint work may be because I did not try to Add Levels in Build Settings. I will try adding levels first and then LoadLevel();,
Your answer
![](https://koobas.hobune.stream/wayback/20220613063257im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
getting udp package info inside unity (GlovePIE) 0 Answers
Car Script error C# 2 Answers
Trouble with restarting 2D tutorial 2 Answers
Problem using 'function Update ()' to restart the game, error CS0246 2 Answers
Don't restart game after killing Orb 1 Answer