Application.LoadLevel(lvl) obsolet

hi, i want to use Application.LoadLevel(lvl); but say that is obsolet and that i have to use “use SceneManager.LoadScene” but that code when i use is not right, solutons ? :frowning:

SceneManager is in the UnityEngine.SceneManagement namespace, you need to put:

using UnityEngine.SceneManagement;

at the top of your cs file.

Note the examples in the documentation:

ty !! how can i know when i have to add “using unity engine” in some codes?

If the class you’re attempting to access is in said namespace.

look at the Unity API (that link Lordofduct posted). on the left panel you see the function is listed in the UnityEngine>UnityEngine.SceneManagement>Classes>SceneManager group. that means the SceneManager class is in the UnityEngine.SceneManagement namespace.

scroll down

theres another group item simply labeled "Classes"full of the most used UnityEngine classes (like Monobehaviour) if you look at the parent list item for that “classes” group you’ll see that it says UnityEngine. this means all those Classes mentioned in that UnityEngine>Classes group are in the UnityEngine namespace.

The entire Scripting API documentation follows that convention

1 Like

ty

By the way, Application.LoadLevel is obsolete but it still works. Unity will recommend using the new SceneManagement, but Application.LoadLevel can still be used.