简体   繁体   中英

how can I load my scenes without the error [scene has not been added to the build settings or the AssetBundle has not been loaded]

I have an error of scene that couldn't be loaded.

I have two scenes. I change my current scene if the requested scene from my server is not the same but it is not loaded.

Scene '/Assets/Beach_Essentials/DemoScene' couldn't be loaded because it has not been added to the build settings or the AssetBundle has not been loaded. To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene (string)

But my scenes are in Build settings.

Has anyone had an issue like this, please?

I get the name of the requested scene from my json defined like this:

    requested_scene = root["item"]["asset"]; 
    private void Update()
        {
            // Check if the name of the current Active Scene is your first Scene.
            if(requested_scene != "")
            {
                Debug.Log("Try to load scene "+requested_scene);
                Scene current_scene = SceneManager.GetActiveScene();
                if(current_scene.name != requested_scene)
                {
                    SceneManager.LoadScene(requested_scene);
                    Debug.Log("Scene loaded"+requested_scene);
                }
            }
    //rest of the code
    }

构建设置捕获

错误

Do you think that I have to make my scenes in the regular environment or UI environment presented in the picture below:

项目设置

The problem occurs because of the value of the requested_scene .

You put the FULL PATH ( /Assets/Beach_Essentials/DemoScene ) in the requested_scene variable. Just add the name of the scene to your variable.

Like this:

requested_scene = "DemoScene";
SceneManager.LoadScene(requested_scene);

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