- Home /
The question is answered, right answer was accepted
Getting Scene index as int
Im trying to simply get the scene index as an int. With the new Unity.SceneManagment it should be easy but Im still experiencing problems.
I tried using Scene.BuildIndex but couldn't figure out how to get the index from the scene the script was in. And then I moved on to using SceneManagment.GetActiveScene and that has led to where I have the script attempt now which is
SceneManagment.GetActiveScene = new int (y);
int y = SceneManager.GetActiveScene();
although neither attempts are proving successful.
Is there any way to get the build index, as an int, from the current scene the.
Any help would be appreciated thanks
Answer by allenallenallen · Dec 19, 2015 at 09:13 AM
int y = SceneManager.GetActiveScene().buildIndex;
SceneManager.GetActiveScene() returns a scene and bulidIndex returns that scene's build index.
Just wondering. What is the buildindex and how come it returns an int?
The top right hand side shows the build indexes for each scene.
2 years later I am here to answer in text. The build index is more like the order in which your levels are. The first one is 0 and then it goes up. It is also the number Scene$$anonymous$$anager.LoadScene() uses to load a scene.