- Home /
How can I change to next stage when current stage is completed(in case of multiple scenes)?
Can any1 tell me how to change to next stage..My stage scenes name are like:- Stage1 Stage2 Stage3...n so on
So i was wondering to take the name of current stage, take its 5 element to be an integer and add 1 to it..this is what i created...plz help
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Analytics; using UnityEngine.SceneManagement;
public class ButtonScript : MonoBehaviour {
Scene scene;
string[] sceneName;
void Start ()
{
scene = SceneManager.GetActiveScene ();// getting the name of the scene
sceneName[] = scene.name;//converting string to array
}
void ButtonNextStage ()//this is my button
{
int myint = int.Parse (scene [5]);//converting the a specific string value to int
Application.LoadLevel ("Stage" + (myint + 1));//adding 1 to the int value to load next scene
}
}
Your answer
Follow this Question
Related Questions
Cannot close/unload a scene that is open in editor during playmode (using C# code)? 3 Answers
Using scene created with SceneManager.CreateScene during runtime 0 Answers
Loading bar for NEXT scene/level... 1 Answer
Scene of index 1 is active when I start game and it should be scene of index 0? 0 Answers
How can I make a loading screen with LoadSceneAsync 2 Answers