How to Change Scene in Unity while running? -- Unity

How to Change Scene in Unity while running? -- Unity


For Changing existing Scene.

First way:

Step1: 
Create Scene.

Step2:
Select File->Build And Run

Step3:
Then Add all scene into "Scene In Build" through clicking "Add Open Scenes".

Step4:
Click "Build" or "Build And Run".

Step5:
Write a script.
using 
UnityEngine.SceneManager.SceneManagement.LoadScene(string SceneName)
where SceneName is the name of scene in Hierarchy.

I usually write
using UnityEngine,SceneManager;
...
SceneManagement.LoadScene(string SceneName);

Step6: 
Attach a script to an empty object

Step7:
Run it. That's done.

[NOTE]
(1)It can used in play mode.
If not used in play mode, an exception will be thrown.
For more details on:

Comments

Popular posts from this blog

How to build a project in unity?