- Home /
Restart button
What the script of restart btn :
Application.Loadlevel (I want here an code to begin the current Scene);
Answer by mactinite77 · Aug 08, 2013 at 03:47 PM
If you want to restart the current level you can do it like this:
Application.LoadLevel(Application.loadedLevel);
It's that plain and simple, unless I'm misunderstanding your question.
Answer by ivan2532 · Aug 08, 2013 at 11:40 AM
Hello, Abdulla Ashraf, you should write it like this:
Application.LoadLevel(your scene number here);
You need to build the scene in Build Settings.
Answer by abdulla ashraf · Aug 08, 2013 at 01:09 PM
I now that but I have more than one scene so i want if me in lvl1 begin 1 if in 2 begin 2 etc...
Answer by Mill0698 · Aug 08, 2013 at 01:49 PM
If you are confused on what scene number your game is, have you checked your build settings?
As you can see, when you are in your current scene you click "Add Current" this will appear in your build settings, with a number next to it. In the image example, you can see that Main.unity scene is the first build. So when you run your game, Main.unity will be the first scene to appear. If you do not have the scene in your build settings, then it won't work. That number is the number you need to change scenes.
Application.LoadLevel(your scene number here);
Answer by Nilsboom · Aug 08, 2013 at 01:41 PM
Hello, Abdulla Ashraf, you should write it like this:
if(Application.loadedLevel == "1" )
{
}
or
if ( Application.loadedLevelName == "Level1" ){
}
Your answer
Follow this Question
Related Questions
Trouble with calling a variable from another script 5 Answers
GameObject.name to call script name? 1 Answer
Global data structure accessible by any script? 1 Answer
Is it possible to acces variables from the unity prefabs such as the sparks and smoke 0 Answers
accesing variable from other script 4 Answers