BuiltinDebugViewsEditor.cs
4.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
using UnityEngine.PostProcessing;
namespace UnityEditor.PostProcessing
{
using Mode = BuiltinDebugViewsModel.Mode;
using Settings = BuiltinDebugViewsModel.Settings;
[PostProcessingModelEditor(typeof(BuiltinDebugViewsModel), alwaysEnabled: true)]
public class BuiltinDebugViewsEditor : PostProcessingModelEditor
{
struct DepthSettings
{
public SerializedProperty scale;
}
struct MotionVectorsSettings
{
public SerializedProperty sourceOpacity;
public SerializedProperty motionImageOpacity;
public SerializedProperty motionImageAmplitude;
public SerializedProperty motionVectorsOpacity;
public SerializedProperty motionVectorsResolution;
public SerializedProperty motionVectorsAmplitude;
}
SerializedProperty m_Mode;
DepthSettings m_Depth;
MotionVectorsSettings m_MotionVectors;
public override void OnEnable()
{
m_Mode = FindSetting((Settings x) => x.mode);
m_Depth = new DepthSettings
{
scale = FindSetting((Settings x) => x.depth.scale)
};
m_MotionVectors = new MotionVectorsSettings
{
sourceOpacity = FindSetting((Settings x) => x.motionVectors.sourceOpacity),
motionImageOpacity = FindSetting((Settings x) => x.motionVectors.motionImageOpacity),
motionImageAmplitude = FindSetting((Settings x) => x.motionVectors.motionImageAmplitude),
motionVectorsOpacity = FindSetting((Settings x) => x.motionVectors.motionVectorsOpacity),
motionVectorsResolution = FindSetting((Settings x) => x.motionVectors.motionVectorsResolution),
motionVectorsAmplitude = FindSetting((Settings x) => x.motionVectors.motionVectorsAmplitude),
};
}
public override void OnInspectorGUI()
{
EditorGUILayout.PropertyField(m_Mode);
int mode = m_Mode.intValue;
if (mode == (int)Mode.Depth)
{
EditorGUILayout.PropertyField(m_Depth.scale);
}
else if (mode == (int)Mode.MotionVectors)
{
EditorGUILayout.HelpBox("Switch to play mode to see motion vectors.", MessageType.Info);
EditorGUILayout.LabelField("Source Image", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_MotionVectors.sourceOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Motion Vectors (overlay)", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
if (m_MotionVectors.motionImageOpacity.floatValue > 0f)
EditorGUILayout.HelpBox("Please keep opacity to 0 if you're subject to motion sickness.", MessageType.Warning);
EditorGUILayout.PropertyField(m_MotionVectors.motionImageOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUILayout.PropertyField(m_MotionVectors.motionImageAmplitude, EditorGUIHelper.GetContent("Amplitude"));
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.LabelField("Motion Vectors (arrows)", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsOpacity, EditorGUIHelper.GetContent("Opacity"));
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsResolution, EditorGUIHelper.GetContent("Resolution"));
EditorGUILayout.PropertyField(m_MotionVectors.motionVectorsAmplitude, EditorGUIHelper.GetContent("Amplitude"));
EditorGUI.indentLevel--;
}
else
{
CheckActiveEffect(mode == (int)Mode.AmbientOcclusion && !profile.ambientOcclusion.enabled, "Ambient Occlusion");
CheckActiveEffect(mode == (int)Mode.FocusPlane && !profile.depthOfField.enabled, "Depth Of Field");
CheckActiveEffect(mode == (int)Mode.EyeAdaptation && !profile.eyeAdaptation.enabled, "Eye Adaptation");
CheckActiveEffect((mode == (int)Mode.LogLut || mode == (int)Mode.PreGradingLog) && !profile.colorGrading.enabled, "Color Grading");
CheckActiveEffect(mode == (int)Mode.UserLut && !profile.userLut.enabled, "User Lut");
}
}
void CheckActiveEffect(bool expr, string name)
{
if (expr)
EditorGUILayout.HelpBox(string.Format("{0} isn't enabled, the debug view won't work.", name), MessageType.Warning);
}
}
}