有谁知道错误在哪里?我一直在寻找各种解决方案,但没有得到我想要的
public static void LoadScene(int levelNum)
{
Application.backgroundLoadingPriority = ThreadPriority.High;
sceneToLoad = levelNum;
SceneManager.LoadScene(loadingSceneIndex);
}
错误:Assets\Script AR\LoadingScreenManager.cs(35,32):错误 CS0103:当前上下文中不存在名称“loadingSceneIndex”
还有一个问题
private void StartOperation(int levelNum)
{
Application.backgroundLoadingPriority = loadThreadPriority;
operation = SceneManager.LoadSceneAsync(levelNum, loadSceneMode);
if (loadSceneMode = LoadSceneMode.Single)
operation.allowSceneActivation = false;
}
错误:Assets\Script AR\LoadingScreenManager.cs(91,13):错误 CS0029:无法将类型“UnityEngine.SceneManagement.LoadSceneMode”隐式转换为“bool”
答案 0 :(得分:1)
第一个错误发生是因为变量 loadingSceneIndex
不存在。您应该像这样将要加载的场景插入到 LoadScene 函数中:
SceneManager.LoadScene(levelNum);
这样 LoadScene 函数就知道要加载哪个场景。
发生第二个错误是因为在 if 语句中需要一个布尔值,但插入 loadSceneMode = LoadSceneMode.Single
。那就是定义 loadSceneMode。相反,请改用 loadSceneMode == LoadSceneMode.Single
,因为这将返回一个布尔值。
注意:您是否考虑过使用 Intellisense 之类的工具,以便您的编辑器可以为您检测这些错误。如果您使用的是 Visual Studio,this link 可能会有所帮助。