using System;
using UnityEngine.Serialization;
namespace UnityEngine.Rendering.Universal
{
///
/// A Graphics Settings container for settings related to shader stripping for .
///
///
/// To change those settings, go to Editor > Project Settings in the Graphics tab (URP).
/// Changing this through the API is only allowed in the Editor. In the Player, this raises an error.
///
/// This container is removed from all build Players.
///
///
///
/// Here is an example of how to determine if your project strips shader variants when building a Player with URP.
///
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.Universal;
///
/// public static class URPShaderStrippingHelper
/// {
/// public static bool enabled
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings<URPShaderStrippingSetting>();
/// if (gs == null) //not in URP or in a Player
/// return false;
/// return gs.stripUnusedVariants;
/// }
/// }
/// }
///
///
[Serializable]
[SupportedOnRenderPipeline(typeof(UniversalRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Additional Shader Stripping Settings", Order = 40)]
[Categorization.ElementInfo(Order = 10)]
public class URPShaderStrippingSetting : IRenderPipelineGraphicsSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
private Version m_Version;
/// Indicates the current version of this settings container. Used exclusively for project upgrades.
public int version => (int)m_Version;
#endregion
#region SerializeFields
[SerializeField, FormerlySerializedAs("m_StripUnusedPostProcessingVariants")]
[Tooltip("Controls whether to automatically strip post processing shader variants and resources based on VolumeProfile components. Stripping is done based on VolumeProfiles in project, their usage in scenes is not considered.")]
bool m_StripUnusedPostProcessingVariantsAndResources = false;
[SerializeField]
[Tooltip("Controls whether to strip variants if the feature is disabled.")]
bool m_StripUnusedVariants = true;
[SerializeField]
[Tooltip("Controls whether Screen Coordinates Override shader variants are automatically stripped.")]
bool m_StripScreenCoordOverrideVariants = true;
[SerializeField]
[Tooltip("Controls whether unused 2D light shader variants are stripped based on scene analysis.")]
bool m_Strip2DUnusedVariants = false;
#endregion
#region Data Accessors
///
/// Controls whether to automatically strip post processing shader variants and resources based on
/// components. Stripping is done based on VolumeProfiles in project, their usage
/// in scenes is not considered.
///
public bool stripUnusedPostProcessingVariants
{
get => m_StripUnusedPostProcessingVariantsAndResources;
set => this.SetValueAndNotify(ref m_StripUnusedPostProcessingVariantsAndResources, value);
}
///
/// Controls whether to strip variants if the feature is disabled.
///
public bool stripUnusedVariants
{
get => m_StripUnusedVariants;
set => this.SetValueAndNotify(ref m_StripUnusedVariants, value);
}
///
/// Controls whether Screen Coordinates Override shader variants are automatically stripped.
///
public bool stripScreenCoordOverrideVariants
{
get => m_StripScreenCoordOverrideVariants;
set => this.SetValueAndNotify(ref m_StripScreenCoordOverrideVariants, value);
}
///
/// Controls whether unused 2D light shader variants are stripped based on scene analysis.
///
public bool strip2DUnusedVariants
{
get => m_Strip2DUnusedVariants;
set => this.SetValueAndNotify(ref m_Strip2DUnusedVariants, value);
}
#endregion
}
}