简体   繁体   中英

Scene Management in unity2D

I'm working on unity 2d , and in one part i have to load the next scene(for example c) , if the user presses space .
I have this part of code and I have attached it to the main scene , but it doesn't do anything .

void Update () {

if (Input.GetKey (KeyCode.Space))   {
                        SceneManager.LoadScene('c');
    }

}

Did you add the scene you are trying to load to the Build Settings? Scenes have to be added to the 'Scenes In Build' to be newly loaded. You can access Build Settings through File > Build Settings.

SceneManager.LoadScene: https://docs.unity3d.com/ScriptReference/SceneManagement.SceneManager.LoadScene.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM