post processing
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.6 / PostProcessing / Editor / PostProcessDebugEditor.cs
blob49729d28af074a53e973034c296ce1f7b738c1a0
1 using UnityEngine;
2 using UnityEngine.Rendering.PostProcessing;
4 namespace UnityEditor.Rendering.PostProcessing
6 [CustomEditor(typeof(PostProcessDebug))]
7 sealed class PostProcessDebugEditor : BaseEditor<PostProcessDebug>
9 SerializedProperty m_PostProcessLayer;
10 SerializedProperty m_LightMeterEnabled;
11 SerializedProperty m_HistogramEnabled;
12 SerializedProperty m_WaveformEnabled;
13 SerializedProperty m_VectorscopeEnabled;
14 SerializedProperty m_Overlay;
16 SerializedObject m_LayerObject;
18 SerializedProperty m_LightMeterShowCurves;
19 SerializedProperty m_HistogramChannel;
20 SerializedProperty m_WaveformExposure;
21 SerializedProperty m_VectorscopeExposure;
23 SerializedProperty m_LinearDepth;
24 SerializedProperty m_MotionColorIntensity;
25 SerializedProperty m_MotionGridSize;
26 SerializedProperty m_ColorBlindness;
27 SerializedProperty m_ColorBlindnessStrength;
29 void OnEnable()
31 m_PostProcessLayer = FindProperty(x => x.postProcessLayer);
32 m_LightMeterEnabled = FindProperty(x => x.lightMeter);
33 m_HistogramEnabled = FindProperty(x => x.histogram);
34 m_WaveformEnabled = FindProperty(x => x.waveform);
35 m_VectorscopeEnabled = FindProperty(x => x.vectorscope);
36 m_Overlay = FindProperty(x => x.debugOverlay);
38 if (m_PostProcessLayer.objectReferenceValue != null)
39 RebuildProperties();
42 void RebuildProperties()
44 if (m_PostProcessLayer.objectReferenceValue == null)
45 return;
47 m_LayerObject = new SerializedObject(m_Target.postProcessLayer);
49 m_LightMeterShowCurves = m_LayerObject.FindProperty("debugLayer.lightMeter.showCurves");
50 m_HistogramChannel = m_LayerObject.FindProperty("debugLayer.histogram.channel");
51 m_WaveformExposure = m_LayerObject.FindProperty("debugLayer.waveform.exposure");
52 m_VectorscopeExposure = m_LayerObject.FindProperty("debugLayer.vectorscope.exposure");
54 m_LinearDepth = m_LayerObject.FindProperty("debugLayer.overlaySettings.linearDepth");
55 m_MotionColorIntensity = m_LayerObject.FindProperty("debugLayer.overlaySettings.motionColorIntensity");
56 m_MotionGridSize = m_LayerObject.FindProperty("debugLayer.overlaySettings.motionGridSize");
57 m_ColorBlindness = m_LayerObject.FindProperty("debugLayer.overlaySettings.colorBlindnessType");
58 m_ColorBlindnessStrength = m_LayerObject.FindProperty("debugLayer.overlaySettings.colorBlindnessStrength");
61 public override void OnInspectorGUI()
63 serializedObject.Update();
65 using (var changed = new EditorGUI.ChangeCheckScope())
67 EditorGUILayout.PropertyField(m_PostProcessLayer);
68 serializedObject.ApplyModifiedProperties(); // Needed to rebuild properties after a change
69 serializedObject.Update();
71 if (changed.changed)
72 RebuildProperties();
75 if (m_PostProcessLayer.objectReferenceValue != null)
77 m_LayerObject.Update();
79 // Overlays
80 EditorGUILayout.Space();
81 EditorGUILayout.LabelField(EditorUtilities.GetContent("Overlay"), EditorStyles.boldLabel);
82 EditorGUI.indentLevel++;
83 EditorGUILayout.PropertyField(m_Overlay);
84 DoOverlayGUI(DebugOverlay.Depth, m_LinearDepth);
85 DoOverlayGUI(DebugOverlay.MotionVectors, m_MotionColorIntensity, m_MotionGridSize);
86 DoOverlayGUI(DebugOverlay.ColorBlindnessSimulation, m_ColorBlindness, m_ColorBlindnessStrength);
88 // Special cases
89 if (m_Overlay.intValue == (int)DebugOverlay.NANTracker && m_Target.postProcessLayer.stopNaNPropagation)
90 EditorGUILayout.HelpBox("Disable \"Stop NaN Propagation\" in the Post-process layer or NaNs will be overwritten!", MessageType.Warning);
92 EditorGUI.indentLevel--;
94 // Monitors
95 EditorGUILayout.Space();
96 EditorGUILayout.LabelField(EditorUtilities.GetContent("Monitors"), EditorStyles.boldLabel);
97 EditorGUI.indentLevel++;
98 DoMonitorGUI(EditorUtilities.GetContent("Light Meter"), m_LightMeterEnabled, m_LightMeterShowCurves);
99 DoMonitorGUI(EditorUtilities.GetContent("Histogram"), m_HistogramEnabled, m_HistogramChannel);
100 DoMonitorGUI(EditorUtilities.GetContent("Waveform"), m_WaveformEnabled, m_WaveformExposure);
101 DoMonitorGUI(EditorUtilities.GetContent("Vectoscope"), m_VectorscopeEnabled, m_VectorscopeExposure);
102 EditorGUI.indentLevel--;
104 m_LayerObject.ApplyModifiedProperties();
107 serializedObject.ApplyModifiedProperties();
110 void DoMonitorGUI(GUIContent content, SerializedProperty prop, params SerializedProperty[] settings)
112 EditorGUILayout.PropertyField(prop, content);
114 if (settings == null || settings.Length == 0)
115 return;
117 if (prop.boolValue)
119 EditorGUI.indentLevel++;
120 foreach (var p in settings)
121 EditorGUILayout.PropertyField(p);
122 EditorGUI.indentLevel--;
126 void DoOverlayGUI(DebugOverlay overlay, params SerializedProperty[] settings)
128 if (m_Overlay.intValue != (int)overlay)
129 return;
131 if (settings == null || settings.Length == 0)
132 return;
134 foreach (var p in settings)
135 EditorGUILayout.PropertyField(p);