如何在没有错误的情况下加载我的场景 [场景尚未添加到构建设置或 AssetBundle 尚未加载]
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]
我有一个无法加载的场景错误。
我有两个场景。如果从我的服务器请求的场景不相同但未加载,我会更改当前场景。
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)
但我的场景在构建设置中。
请问有人遇到过这样的问题吗?
我从我的 json 中得到请求场景的名称,定义如下:
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
}
你觉得我的场景是要在常规环境还是下图UI环境中制作:
问题的发生是因为 requested_scene
的值。
您将 FULL PATH (/Assets/Beach_Essentials/DemoScene
) 放入 requested_scene
变量中。只需将场景的名称添加到您的变量中即可。
像这样:
requested_scene = "DemoScene";
SceneManager.LoadScene(requested_scene);
我有一个无法加载的场景错误。
我有两个场景。如果从我的服务器请求的场景不相同但未加载,我会更改当前场景。
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)
但我的场景在构建设置中。
请问有人遇到过这样的问题吗?
我从我的 json 中得到请求场景的名称,定义如下:
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
}
你觉得我的场景是要在常规环境还是下图UI环境中制作:
问题的发生是因为 requested_scene
的值。
您将 FULL PATH (/Assets/Beach_Essentials/DemoScene
) 放入 requested_scene
变量中。只需将场景的名称添加到您的变量中即可。
像这样:
requested_scene = "DemoScene";
SceneManager.LoadScene(requested_scene);