So I have a very simple and small code that should do the following:
Load Scene; After loaded, do stuff.
For making sure the scene would have enough time for loading, I called the LoadScene() function and made a loop under it that executes a million times (not kidding lol) checking if the scene has loaded. It never returns true. The code:
if (Input.GetMouseButtonDown(1))
{
SceneManager.LoadScene(sceneToLoad); //previously defined scene name (string)
for (int i = 0; i < 1000000; i++)
{
if (SceneManager.GetSceneByName(sceneToLoad).isLoaded)
{
//do stuff
break;
}
}
}
Apart from the one million runs loop, what’s wrong with my code?