[英]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.
无法加载场景“/Assets/Beach_Essentials/DemoScene”,因为它尚未添加到构建设置中或尚未加载 AssetBundle。 To add a scene to the build settings use the menu File->Build Settings... UnityEngine.SceneManagement.SceneManager:LoadScene (string)
要将场景添加到构建设置,请使用菜单 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:我从像这样定义的 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
}
Do you think that I have to make my scenes in the regular environment or UI environment presented in the picture below:您认为我必须在下图所示的常规环境或UI环境中制作场景:
The problem occurs because of the value of the requested_scene
.出现此问题是因为价值的
requested_scene
。
You put the FULL PATH ( /Assets/Beach_Essentials/DemoScene
) in the requested_scene
variable.你把完整路径(
/Assets/Beach_Essentials/DemoScene
)在requested_scene
变量。 Just add the name of the scene to your variable.只需将场景名称添加到变量中即可。
Like this:像这样:
requested_scene = "DemoScene";
SceneManager.LoadScene(requested_scene);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.