[英]Can anyone help me with the loadingSceneIndex issue
does anyone know where the error is?有谁知道错误在哪里? I've been looking for various solutions but I didn't get what I wanted我一直在寻找各种解决方案,但我没有得到我想要的
public static void LoadScene(int levelNum)
{
Application.backgroundLoadingPriority = ThreadPriority.High;
sceneToLoad = levelNum;
SceneManager.LoadScene(loadingSceneIndex);
}
Eror: Assets\Script AR\LoadingScreenManager.cs(35,32): error CS0103: The name 'loadingSceneIndex' does not exist in the current context错误:Assets\Script AR\LoadingScreenManager.cs(35,32):错误 CS0103:当前上下文中不存在名称“loadingSceneIndex”
and one more problem this one还有一个问题这个
private void StartOperation(int levelNum)
{
Application.backgroundLoadingPriority = loadThreadPriority;
operation = SceneManager.LoadSceneAsync(levelNum, loadSceneMode);
if (loadSceneMode = LoadSceneMode.Single)
operation.allowSceneActivation = false;
}
Eror: Assets\Script AR\LoadingScreenManager.cs(91,13): error CS0029: Cannot implicitly convert type 'UnityEngine.SceneManagement.LoadSceneMode' to 'bool'错误:Assets\Script AR\LoadingScreenManager.cs(91,13):错误 CS0029:无法将类型“UnityEngine.SceneManagement.LoadSceneMode”隐式转换为“bool”
The first error happens because the variable loadingSceneIndex
doesn't exist.发生第一个错误是因为变量loadingSceneIndex
不存在。 You should plug the scene you want to load into the LoadScene function like this:您应该像这样将要加载的场景插入 LoadScene function:
SceneManager.LoadScene(levelNum);
That way the LoadScene function knows which scene to load.这样,LoadScene function 就知道要加载哪个场景。
The second error happens because in you're if statement expects a bool, but plug in loadSceneMode = LoadSceneMode.Single
.发生第二个错误是因为您的 if 语句需要一个布尔值,但插入loadSceneMode = LoadSceneMode.Single
。 That is defining loadSceneMode.那就是定义 loadSceneMode。 Instead, use loadSceneMode == LoadSceneMode.Single
instead because that will return a bool.相反,请改用loadSceneMode == LoadSceneMode.Single
,因为这将返回一个布尔值。
Note: Have you looked into using something like Intellisense so your editor can detect these errors for you.注意:您是否考虑过使用 Intellisense 之类的工具,以便您的编辑器可以为您检测到这些错误。 If you are using Visual Studio, this link might help.如果您使用的是 Visual Studio, 此链接可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.