- Home /
Load scene with buildindex equal to a int variable.
Hi. I'm new to unity and I want to ask : How can I load a scene by buildindex by an int variable? Like I have an int = 3 and how can I load the scene with the buildindex = int = 3? i have public int level = SceneManager.GetActiveScene().buildIndex; and I have a saving script so that when I enter the game i load the scene with buildindex int value. How can I do that? SceneManager.LoadScene and next?
Answer by JaCoBReaper · May 17, 2020 at 01:49 PM
you could simply use built in method for int values: SceneManager.LoadScene(level);
Example:
public class MySceneManager : MonoBehaviour
{
void Start()
{
LoadLevel(0);
}
public void LoadLevel(int level)
{
SceneManager.LoadScene(level);
}
}
Your answer
Follow this Question
Related Questions
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); is working badly 1 Answer
how to reset deltatime back to 1f when scene has reloaded?, 1 Answer
How to only load one scene on app launch 0 Answers
Get a reference to the newly loaded scene after a LoadSceneAsync() 2 Answers
Scene.isLoaded not working properly. 1 Answer