5 namespace UnityStandardAssets.ImageEffects
7 [CustomEditor (typeof(ColorCorrectionCurves))]
9 SerializedObject serObj;
11 SerializedProperty mode;
13 SerializedProperty redChannel;
14 SerializedProperty greenChannel;
15 SerializedProperty blueChannel;
17 SerializedProperty useDepthCorrection;
19 SerializedProperty depthRedChannel;
20 SerializedProperty depthGreenChannel;
21 SerializedProperty depthBlueChannel;
23 SerializedProperty zCurveChannel;
25 SerializedProperty saturation;
27 SerializedProperty selectiveCc;
28 SerializedProperty selectiveFromColor;
29 SerializedProperty selectiveToColor;
31 private bool applyCurveChanges =
false;
34 serObj =
new SerializedObject (target);
36 mode = serObj.FindProperty (
"mode");
38 saturation = serObj.FindProperty (
"saturation");
40 redChannel = serObj.FindProperty (
"redChannel");
41 greenChannel = serObj.FindProperty (
"greenChannel");
42 blueChannel = serObj.FindProperty (
"blueChannel");
44 useDepthCorrection = serObj.FindProperty (
"useDepthCorrection");
46 zCurveChannel = serObj.FindProperty (
"zCurve");
48 depthRedChannel = serObj.FindProperty (
"depthRedChannel");
49 depthGreenChannel = serObj.FindProperty (
"depthGreenChannel");
50 depthBlueChannel = serObj.FindProperty (
"depthBlueChannel");
52 serObj.ApplyModifiedProperties ();
54 selectiveCc = serObj.FindProperty (
"selectiveCc");
55 selectiveFromColor = serObj.FindProperty (
"selectiveFromColor");
56 selectiveToColor = serObj.FindProperty (
"selectiveToColor");
59 void CurveGui (
string name, SerializedProperty animationCurve, Color color) {
62 EditorGUILayout.PropertyField (animationCurve,
new GUIContent (name));
64 applyCurveChanges =
true;
68 applyCurveChanges =
false;
72 if (applyCurveChanges) {
73 serObj.ApplyModifiedProperties ();
79 public override void OnInspectorGUI () {
82 GUILayout.Label (
"Use curves to tweak RGB channel colors", EditorStyles.miniBoldLabel);
84 saturation.floatValue = EditorGUILayout.Slider(
"Saturation", saturation.floatValue, 0.0f, 5.0f);
86 EditorGUILayout.PropertyField (mode,
new GUIContent (
"Mode"));
87 EditorGUILayout.Separator ();
91 CurveGui (
" Red", redChannel, Color.red);
92 CurveGui (
" Green", greenChannel, Color.green);
93 CurveGui (
" Blue", blueChannel, Color.blue);
95 EditorGUILayout.Separator ();
97 if (mode.intValue > 0)
98 useDepthCorrection.boolValue =
true;
100 useDepthCorrection.boolValue =
false;
102 if (useDepthCorrection.boolValue) {
103 CurveGui (
" Red (depth)", depthRedChannel, Color.red);
104 CurveGui (
" Green (depth)", depthGreenChannel, Color.green);
105 CurveGui (
" Blue (depth)", depthBlueChannel, Color.blue);
106 EditorGUILayout.Separator ();
107 CurveGui (
" Blend Curve", zCurveChannel, Color.grey);
110 EditorGUILayout.Separator ();
111 EditorGUILayout.PropertyField (selectiveCc,
new GUIContent (
"Selective"));
112 if (selectiveCc.boolValue) {
113 EditorGUILayout.PropertyField (selectiveFromColor,
new GUIContent (
" Key"));
114 EditorGUILayout.PropertyField (selectiveToColor,
new GUIContent (
" Target"));
120 if (!applyCurveChanges)
121 serObj.ApplyModifiedProperties ();