- Home /
How will i goes fresh level?
Hi All,
I am making simple level passing code. i struck simple problem.
after passing two levels of my game there is a back button. if i comes back the level 1 is not started fresh level. that will continue as same. how will i start fresh if i comes back and goes front also same problem occurs.
How will solve that.
here is my sample code:
void OnGUI()
{
if(GUI.Button(new Rect(290,Screen.height-160,100,40),"Back"))
{
Application.LoadLevel(3);
}
if(GUI.Button(new Rect(290,Screen.height-120,100,40),"Go to Menu"))
{
Application.LoadLevel(0);
}
if(GUI.Button(new Rect(290,Screen.height-80,100,40),"Quit"))
{
Application.Quit();
}
Second code: For level 3
void OnGUI (){
if(GUI.Button(new Rect(240,Screen.height-50,100,40),"Continue to lab"))
{
Application.LoadLevel(4);
}
if(GUI.Button(new Rect(120,Screen.height-50,100,40),"Go to Menu"))
{
Application.LoadLevel(0);
}
}
}
I found that if i comes back that before level not completely stop. i think that is running in back ground. if i goes front that will execute currently state.
Please Help me
Shankar
Your answer
Follow this Question
Related Questions
My Unity Android app is preventing the lock screen from displaying properly 2 Answers
How do i reset the backgrounds offset 2 Answers
GUI background changed, don't know how to reset it. 2 Answers
Best practices for large background image on mobile? 0 Answers
Does anyone know why those blue lines appear when the camera and background moves? 1 Answer