using System;
using UnityEditor.Rendering;
using UnityEditor;
namespace UnityEngine.Rendering.HighDefinition
{
///
/// A graphics settings container for the used by LookDev with .
///
///
/// To change those settings, go to Editor > Project Settings in the Graphics tab (HDRP).
/// 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 get the default volume profile used by the LookDev in HDRP.
///
/// using UnityEngine.Rendering;
/// using UnityEngine.Rendering.HighDefinition;
///
/// public static class HDRPLookDevVolumeProfileHelper
/// {
/// public static VolumeProfile volumeProfile
/// {
/// get
/// {
/// var gs = GraphicsSettings.GetRenderPipelineSettings<LookDevVolumeProfileSettings>();
/// if (gs == null) //not in HDRP or in a Player
/// return null;
/// return gs.volumeProfile;
/// }
/// }
/// }
///
///
[Serializable]
[SupportedOnRenderPipeline(typeof(HDRenderPipelineAsset))]
[Categorization.CategoryInfo(Name = "Volume", Order = 0)]
[Categorization.ElementInfo(Order = 10)]
public class LookDevVolumeProfileSettings : IRenderPipelineGraphicsSettings
{
#region Version
internal enum Version : int
{
Initial = 0,
}
[SerializeField][HideInInspector]
Version m_Version;
/// Current version of these settings container. Used only for upgrading a project.
public int version => (int)m_Version;
#endregion
[SerializeField]
VolumeProfile m_VolumeProfile;
///
/// The volume profile to be used for LookDev.
///
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(LookDevVolumeProfileSettings setting, SerializedProperty _, ref GenericMenu menu)
{
void Reset()
{
if (EditorGraphicsSettings.TryGetRenderPipelineSettingsForPipeline(out var rpgs))
{
RenderPipelineGraphicsSettingsEditorUtility.Rebind(
new LookDevVolumeProfileSettings() { volumeProfile = VolumeUtils.CopyVolumeProfileFromResourcesToAssets(rpgs.lookDevVolumeProfile, true) },
typeof(HDRenderPipeline)
);
}
}
menu.AddItem(new GUIContent("Reset"), false, Reset);
}
}
#endif
}
}