Reputation: 39698
Pre Unity 5.3, I had the following code:
Application.LoadLevel(Application.loadedLevel + 1);
This would advance the current level by one, which is handy for moving to the next level in a multiple level game. However, I noticed that both LoadLevel
and loadedLevel
are deprecated. I've found a pretty good equivalent code for the LoadLevel
, but I'm struggling to find anything that advances the level by one, or a current scene indicator. Any suggestions?
SceneManager.LoadScene(Application.loadedLevel + 1);
Upvotes: 3
Views: 2262
Reputation: 39698
SceneManager has a function called GetActiveScene(), which returns a Scene. The scene has a getter called buildIndex that returns the build index. That value is the same as the previous loadedLevel. Thus, the code should be the following:
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
Upvotes: 5