"Level Manager" trying to update deprecated code
Hi guys, I am new to unity, and I am currently trying to learn code via some Udemey videos. I am running into some deprecated code on line 12. I know that I need to update line 12 to SceneManager.LoadScene, however I am very new to programming and don't have a strong enough understanding to fix it beyond that. Any help would be greatly appreciated. Thanks in advance.
public class LevelManager : MonoBehaviour {
public void LoadLevel(string name) {
Debug.Log("level load requested for: " + name);
SceneManager.LoadScene(name);
}
public void QuitRequest() {
Debug.Log("I want to quit!: ");
Application.Quit();
}
public LoadNextLevel() {
Application.LoadLevel(Application.loadedLevel +1);
}
}
Answer by Addyarb · Aug 06, 2016 at 11:58 PM
It is indeed a little confusing to switch from the Application to SceneManager class, as the implementation is considerably (and needlessly imo) more complex.
Here's how line 12 should look:
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
Anyhow, always check the Unity Scripting API for these types of things, and you'll usually get a really good idea (if not a code sample) of what you need to do.
Good luck learning Unity!
Your answer
Follow this Question
Related Questions
Error : Failed to build apk -1 Answers
ComponentChunkIterator is not liking me.. 0 Answers
Missing the class attribute 'ExtensionOfNativeClass' 4 Answers
Error in Inventory Script 1 Answer