- Home /
Loading the Next Level By Increments
I am creating a game where pressing a button that says "Next Level" loads the next level. My problem is that there are going to be about 50 levels in my game, so is there a script that just loads the next scene in the order I have them in the build settings?
function nextLevel()
{
yield WaitForSeconds(3);
Application.loadLevel ("Level2");
}
Is there any script that can do this instead of using a specific level? Thanks, all feedback is appreciated.
Answer by perchik · Mar 17, 2014 at 05:07 PM
Application.LoadLevel can take an integer index instead of a name. If you have your build settings setup right, you could just do:
var i: int=0;
function nextLevel()
{
yield WaitForSeconds(3);
i++;
Application.loadLevel (i);
}
This code for load levels one by one
function nextLevel()
{
yield WaitForSeconds(3);
Application.loadLevel(Application.loadedLevel + 1);
}
Both of these answers were helpful, thanks! I was able to get it to work now!
Your answer
Follow this Question
Related Questions
problems with continuous audio between scenes 1 Answer
load next scene during current scene 1 Answer
Missed Input Events with Joystick 0 Answers