Question by
Smitlord · Feb 10, 2016 at 03:13 PM ·
scripting problemloadlevelload scene
example of new way to load levels
i have tried over 46,853 times to load a level with the new way of doing it and it fails every time the new way of doing it is GameManager.LoadScene but i just cant get that to work so can someone give me a working example it is driving me insane that i cant get it to work
Comment
Best Answer
Answer by Landern · Feb 10, 2016 at 03:22 PM
I'm not sure what this GameManager.LoadScene thing is, but i assume you're referring to the SceneManager that is new.
SceneManagement.SceneManager.LoadScene("MyLevelName"); // by name
SceneManagement.SceneManager.LoadScene(0); // by build settings index listed in the build settings.
You may also need to use/import the namespace hence why i fully qualified SceneManagement type. You can get around it by using or importing
c#
using UnityEngine.SceneManagement;
unityscript/javascript
import UnityEngine.SceneManagement;
If you use the name space you can clip off the SceneManagement type from above so it looks like:
SceneManager.LoadScene("MyLevelName"); // by name
SceneManager.LoadScene(0); // by build settings index listed in the build settings.