谁能帮我解决 loadingSceneIndex 问题

Can anyone help me with the loadingSceneIndex issue

有谁知道错误在哪里?我一直在寻找各种解决方案,但我没有得到我想要的

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'

  1. 第一个错误是因为变量 loadingSceneIndex 不存在。您应该像这样将要加载的场景插入到 LoadScene 函数中:

    SceneManager.LoadScene(levelNum);

    这样 LoadScene 函数就知道要加载哪个场景。

  2. 第二个错误发生是因为在您的 if 语句中需要一个布尔值,但插入了 loadSceneMode = LoadSceneMode.Single。那就是定义 loadSceneMode。相反,请改用 loadSceneMode == LoadSceneMode.Single 因为那将 return 一个 bool.

注意:您是否考虑过使用诸如 Intellisense 之类的工具,以便您的编辑器可以为您检测这些错误。如果您使用 Visual Studio, 可能会有所帮助。