【问题标题】:How do I fix the error I receive in Post Processing when launching Unity?如何修复启动 Unity 时在后期处理中收到的错误?
【发布时间】:2020-10-06 06:28:20
【问题描述】:

我对 Unity 还很陌生,所以请原谅我如果我没有给你足够的信息,但是每当我在 Unity 中打开项目时都会遇到一些错误。

前两个是:Unity Error Image

#1:

***Library\PackageCach\.com.unity.postprocessing@2.0.3-preview\PostProccessing\Runtime\PostProcessManager.cs(424,66):error CS0117:'EditorSceneManager' does not contain a definition for 'IsGameObjectInScene'\***

#2:***Library\PackageCach\.com.unity.postprocessing@2.0.3-preview\PostProccessing\Runtime\PostProcessManager.cs(425,66):error CS0117:'EditorSceneManager' does not contain a definition for 'IsGameObjectInMainScene'***

如果我进入代码并删除这两行

 ? UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInScene(volume.gameObject, customScene)
                : UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInMainScenes(volume.gameObject);

从这里

 #if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
                // If the current camera have a custom scene then the camera is rendering that scene,
                // otherwise the camera is rendering the scenes in the SceneManager.
                var customScene = camera.scene;
                return customScene.IsValid()
                    ? UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInScene(volume.gameObject, customScene)
                    : UnityEditor.SceneManagement.EditorSceneManager.IsGameObjectInMainScenes(volume.gameObject);
    #else
                return true;

它在 Unity 中给了我一个语法错误: ;预计

当我修复这个错误时,它给了我这个错误: **Library\PackageCache\com.unity.postprocessing@2.0.3-preview\PostProcessing\Editor\Utils\PostProcessShaderIncludePath.cs(10,10): error CS0619: 'ShaderIncludePathAttribute' is obsolete: '[ShaderIncludePath] attribute is no longer supported. Your shader library must be under the Assets folder or in a package. To include shader headers directly from a package, use #include "Packages/<package name>/<path to your header file>"'**

我删除这行代码后:

[ShaderIncludePath]

从这里:

#if UNITY_2018_1_OR_NEWER
        [ShaderIncludePath]
#endif
        public static string[] GetPaths()
        {
            var srpMarker = Directory.GetFiles(Application.dataPath, "POSTFXMARKER", SearchOption.AllDirectories).FirstOrDefault();
            var paths = new string[srpMarker == null ? 1 : 2];
            var index = 0;
            if (srpMarker != null)
            {
                paths[index] = Directory.GetParent(srpMarker).ToString();
                index++;
            }
            paths[index] = Path.GetFullPath("Packages/com.unity.postprocessing");
            return paths;

修复所有问题后,我可以正常使用 Unity。如果这对导出我的项目没有未来影响,我可以每次都删除它。但我对任何代码的作用一无所知,所以如果有人可以帮助我或知道如何解决它,请告诉我。

【问题讨论】:

    标签: c# unity3d


    【解决方案1】:

    从 2020 年 1 月的后期处理包版本为 2.0.3(预览版),最新的稳定版本为 2.3.0 的事实来看,我建议您使用严重过时的包。

    首先,使用 Unity Hub 应用程序检查 Unity 编辑器是否是最新的,以“添加”新的 Unity 版本。如果您正在寻找广受好评、最稳定的版本,我建议您使用 2019.4 LTS。否则,如果您正在寻找“新”事物,那么 2020.2 测试版在大多数情况下都相当稳定,但具有包含新工具和新功能的优势。

    接下来,在“窗口”菜单下打开您的包管理器,然后检查您的所有包是否都是最新的。

    一旦您的 Unity 编辑器和包全部更新,您很可能会发现此错误已得到解决。我还建议现在更新,因为您已经说过您是 Unity 的新手,而且我假设您还没有完成一个主要项目。通常认为,在没有令人信服的理由的情况下将 Unity 编辑器更新到新的主要版本是不明智的。

    【讨论】:

    • 谢谢你,我会试试这个,如果它有效,我会确保你的答案是正确的。
    猜你喜欢
    • 2019-08-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-01
    相关资源
    最近更新 更多