全网第一,Unity编辑器拓展,修改URP管线设置
【前言】
Graphics、Quality的渲染管线资产设置,PlayerSettings的colorSpace、Auto Graphics API,Color Gamut设置,菜单栏为:URP设置/普通3D和URP互转
【放出代码】
private static bool _isEnableURP;
[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);
GraphicsSettings.renderPipelineAsset = URPAsset_Graphics;
RenderPipelineAsset URPAsset_Quality = AssetDatabase.LoadAssetAtPath<RenderPipelineAsset>(string assetPath);
QualitySettings.renderPipeline = URPAsset_Quality;
Debug.Log($"渲染管线设置完成: {GraphicsSettings.renderPipelineAsset} {QualitySettings.renderPipeline}");
PlayerSettings.colorSpace = ColorSpace.Linear;
PlayerSettings.SetUseDefaultGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget,false);
GraphicsDeviceType[] graphicsDeviceType =
{
GraphicsDeviceType.OpenGLES3,
GraphicsDeviceType.Vulkan
};
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);
foreach (var VARIABLE in PlayerSettings.GetGraphicsAPIs(EditorUserBuildSettings.activeBuildTarget))
{
Debug.Log($"设置图形API完成: {VARIABLE}");
}
_isEnableURP = true;
}
}