【问题标题】:Can anyone help me with the loadingSceneIndex issue谁能帮我解决 loadingSceneIndex 问题
【发布时间】:2021-03-24 14:42:25
【问题描述】:

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

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”

【问题讨论】:

  • 你是否检查过你是否在构建设置中添加了你的场景->构建中的场景?
  • 貌似不行,怎么办?
  • 转到文件构建设置并在那里添加您的场景
  • 有教程吗?
  • 点击添加打开的场景

标签: c# unity3d augmented-reality vuforia


【解决方案1】:
  1. 第一个错误发生是因为变量loadingSceneIndex 不存在。您应该将要加载的场景插入到 LoadScene 函数中,如下所示:

    SceneManager.LoadScene(levelNum);

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

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 2023-03-30
    • 2021-11-13
    • 1970-01-01
    • 2022-12-03
    相关资源
    最近更新 更多