• 使用Unity旧版本使用hotReload在开始的时候提示 PlayerSettings.suppressCommonWarnings; 找不到


    Unity Hot Reload 旧版本的报错

    使用Unity旧版本使用hotReload在开始的时候提示

       PlayerSettings.suppressCommonWarnings; 找不到
    
    • 1

    按照下面的方式修改完毕后可以正常使用
    在添加热更新之前请备份。

    代码片段:

    
            public async Task Sync() {
                await ThreadUtility.SwitchToThreadPool();
                var config = LoadConfig();
                if (config.useBuiltInProjectGeneration) {
                    return;
                }
                
                await ThreadUtility.SwitchToMainThread();
                await gate.WaitAsync();
                try {
                    //Cache all data that is accessed via unity API on the unity main thread.
                    m_AllAssetPaths = AssetDatabase.GetAllAssetPaths();
                    m_ProjectSupportedExtensions = EditorSettings.projectGenerationUserExtensions;
                    m_EngineAssemblyPath = InternalEditorUtility.GetEngineAssemblyPath();
                    m_EditorAssemblyPath = InternalEditorUtility.GetEditorAssemblyPath();
                    m_FallbackRootNamespace = EditorSettings.projectGenerationRootNamespace;
                    m_SuppressCommonWarnings = 
                     #if UNITY_2020_1_OR_NEWER
                         PlayerSettings.suppressCommonWarnings;
                    #else
                          false;
                    #endif
    
                    //Do the remaining work on a separate thread
                    await Task.WhenAll(
                        BuildPackageInfoCache(),
                        BuildEditorAssemblies(),
                        BuildPostProcessors()
                    );
                    await GenerateAndWriteSolutionAndProjects(config);
                } finally {
                    gate.Release();
                }
            }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36

    在旧的IDE中会提示PlayerSettings.suppressCommonWarnings;找不到,
    修改方式是,注释宏命令,将m_SuppressCommonWarnings设置为false

            public async Task Sync() {
                await ThreadUtility.SwitchToThreadPool();
                var config = LoadConfig();
                if (config.useBuiltInProjectGeneration) {
                    return;
                }
                
                await ThreadUtility.SwitchToMainThread();
                await gate.WaitAsync();
                try {
                    //Cache all data that is accessed via unity API on the unity main thread.
                    m_AllAssetPaths = AssetDatabase.GetAllAssetPaths();
                    m_ProjectSupportedExtensions = EditorSettings.projectGenerationUserExtensions;
                    m_EngineAssemblyPath = InternalEditorUtility.GetEngineAssemblyPath();
                    m_EditorAssemblyPath = InternalEditorUtility.GetEditorAssemblyPath();
                    m_FallbackRootNamespace = EditorSettings.projectGenerationRootNamespace;
                    m_SuppressCommonWarnings = false;
                   //  #if UNITY_2020_1_OR_NEWER
                   //      PlayerSettings.suppressCommonWarnings;
                   // #else
                   //       false;
                  //#endif
    
                    //Do the remaining work on a separate thread
                    await Task.WhenAll(
                        BuildPackageInfoCache(),
                        BuildEditorAssemblies(),
                        BuildPostProcessors()
                    );
                    await GenerateAndWriteSolutionAndProjects(config);
                } finally {
                    gate.Release();
                }
            }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
  • 相关阅读:
    TPH-YOLOv5: 基于Transformer预测头的改进YOLOv5用于无人机捕获场景目标检测
    ROS中tf转换 launch文件 静态坐标转化写法
    第三章 内存管理 二、内存管理的概念
    【LeetCode每日一题】——141.环形链表
    11.11一些资源整理和总结
    【JS】计算任意多个数字的和、差、积、商
    推荐10个Vue 3.0开发的开源前端项目
    如何查看dll文件内导出函数名称
    Unity制作透明材质直接方法——6.15山大软院项目实训
    java基础09
  • 原文地址:https://blog.csdn.net/GoodCooking/article/details/134040513