- Home /
Question by
John Sartain · May 04, 2014 at 06:58 PM ·
mobilelevel
How do I use Application.LoadLevel to load the next consecutive scene?
How do I use Application.LoadLevel to load the next consecutive scene? (sorry about how its all stuck together I don't know how to fix it) function Start() { yield WaitForSeconds(1); Application.LoadLevel(whatever code it is); } thanks
Comment
Answer by fafase · May 04, 2014 at 07:02 PM
Well you could name your scene with consecutive names: Level1, Level2.
This way you get the digit of the scene, add 1 and load the next scene:
string nextLevel = "Level";
string level = Application.loadedLevelName.AsEnumerable().Where(char.IsDigit);
int value = int.Parse(level);
value++;
nextLevel+=value.ToString();
Application.LoadLevel(nextLevel);
Or, place them in order in the build and just increase the index:
int level = Application.loadedLevel;
level++,
Application.LoadLevel(level);