Load a scene on a condition in c#

How to load a scene from code?

1 Like

If you are using a version of Unity prior to 5.3 then you can use Application.LoadLevel(), if you are using 5.3 upwards you need to reference another namespace at the top of your script;

using UnityEngine.SceneManagement;

and then you can use;

SceneManager.LoadScene()

…again passing in the name of the scene.

In both cases it is possible to instead pass in the build index number of the scene instead of the name.

Note : This is covered in the lectures.


See also;

Privacy & Terms