using System; #if UNITY_EDITOR using UnityEditor; using UnityEditor.Rendering; #endif namespace UnityEngine.Rendering.HighDefinition { /// /// Graphics Settings container for the default used by the . /// /// /// To change those settings, go to Editor > Project Settings in the Graphics tab (HDRP). /// Changing this through API is only allowed in the Editor. In the Player, this raises an error. /// /// /// /// Here is an example of how to get the default volume profile used by HDRP. /// /// using UnityEngine.Rendering; /// using UnityEngine.Rendering.HighDefinition; /// /// public static class URPDefaultVolumeProfileHelper /// { /// public static VolumeProfile volumeProfile /// { /// get /// { /// var gs = GraphicsSettings.GetRenderPipelineSettings<URPDefaultVolumeProfileSettings>(); /// if (gs == null) //not in HDRP /// return null; /// return gs.volumeProfile; /// } /// } /// } /// /// [Serializable] [SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))] [Categorization.CategoryInfo(Name = "Volume", Order = 0)] [Categorization.ElementInfo(Order = 0)] public class HDRPDefaultVolumeProfileSettings : IDefaultVolumeProfileSettings { #region Version internal enum Version : int { Initial = 0, } [SerializeField][HideInInspector] Version m_Version; /// Current version of this settings container. Used only for upgrading the project. public int version => (int)m_Version; #endregion [SerializeField] VolumeProfile m_VolumeProfile; /// /// The default volume profile asset. /// public VolumeProfile volumeProfile { get => m_VolumeProfile; set => this.SetValueAndNotify(ref m_VolumeProfile, value); } } #if UNITY_EDITOR //Overriding "Reset" in menu that is not called at HDRPDefaultVolumeProfileSettings creation such Reset() struct ResetImplementation : IRenderPipelineGraphicsSettingsContextMenu2 { public void PopulateContextMenu(HDRPDefaultVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu) { void Reset() { if (EditorGraphicsSettings.TryGetRenderPipelineSettingsForPipeline(out var rpgs)) { RenderPipelineGraphicsSettingsEditorUtility.Rebind( new HDRPDefaultVolumeProfileSettings() { volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(rpgs.defaultVolumeProfile) }, typeof(HDRenderPipeline) ); } } menu.AddItem(new GUIContent("Reset"), false, Reset); } } #endif }