全网第一,Unity编辑器拓展,修改URP管线设置

全网第一,Unity编辑器拓展,修改URP管线设置

  • 【前言】
    • Graphics、Quality的渲染管线资产设置,PlayerSettings的colorSpace、Auto Graphics API,Color Gamut设置,菜单栏为:URP设置/普通3D和URP互转
  • 【放出代码】

【前言】

Graphics、Quality的渲染管线资产设置,PlayerSettings的colorSpace、Auto Graphics API,Color Gamut设置,菜单栏为:URP设置/普通3D和URP互转

【放出代码】


    private static bool _isEnableURP;
    /// 
    /// URP设置
    /// 
    [MenuItem("URP设置/普通3D和URP互转", priority = -1000)]
    public static void SettingURP() {
        ProjectURP_Transformation();
    }

    static void ProjectURP_Transformation()
    {
        if (_isEnableURP)
        {
            Debug.Log("设置项目为URP管线");
            
            RenderPipelineAsset URPAsset_Graphics = AssetDatabase.LoadAssetAtPath<RenderPipelineAsset>(string assetPath);//Graphics设置的渲染管线资产,assetPath需要自己去Copy Path
            GraphicsSettings.renderPipelineAsset = URPAsset_Graphics;
            RenderPipelineAsset URPAsset_Quality = AssetDatabase.LoadAssetAtPath<RenderPipelineAsset>(string assetPath);//Quality设置的渲染管线资产,assetPath需要自己去Copy Path
            QualitySettings.renderPipeline = URPAsset_Quality;
            Debug.Log($"渲染管线设置完成:   {GraphicsSettings.renderPipelineAsset}      {QualitySettings.renderPipeline}");
            
            PlayerSettings.colorSpace = ColorSpace.Linear;//根据需求自行设置颜色空间,参照ColorSpace枚举
            PlayerSettings.SetUseDefaultGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget,false);//根据需求自行设置Auto Graphics API
            
            GraphicsDeviceType[] graphicsDeviceType =
            {
                GraphicsDeviceType.OpenGLES3,
                GraphicsDeviceType.Vulkan
            };//根据需求自行设置Color Gamut,像我这个必须要关闭Auto Graphics API
            PlayerSettings.SetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget,graphicsDeviceType);

            foreach (var VARIABLE in PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget))
            {
                Debug.Log($"设置图形API完成:   {VARIABLE}");
            }

            _isEnableURP = false;
        }
        else
        {
            Debug.Log("设置项目为普通管线");
            
            GraphicsSettings.renderPipelineAsset = null;
            QualitySettings.renderPipeline = null;
            Debug.Log($"渲染管线设置完成:   {GraphicsSettings.renderPipelineAsset}      {QualitySettings.renderPipeline}");

            PlayerSettings.colorSpace = ColorSpace.Gamma;//根据需求自行设置颜色空间
            PlayerSettings.SetUseDefaultGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget,true);//根据需求自行设置Auto Graphics API
            
            /*GraphicsDeviceType[] graphicsDeviceType =
            {
                GraphicsDeviceType.OpenGLES3,
                GraphicsDeviceType.Vulkan
            };
            PlayerSettings.SetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget,graphicsDeviceType);//根据需求自行设置Color Gamut,像我这个必须要关闭Auto Graphics API*/
            
            foreach (var VARIABLE in PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget))
            {
                Debug.Log($"设置图形API完成:   {VARIABLE}");
            }
            
            _isEnableURP = true;
        }
    }

你可能感兴趣的:(Unity,unity,编辑器,游戏引擎)