5 namespace UnityStandardAssets.ImageEffects
7 [CustomEditor (typeof(BloomAndFlares))]
10 SerializedProperty tweakMode;
11 SerializedProperty screenBlendMode;
13 SerializedObject serObj;
15 SerializedProperty hdr;
16 SerializedProperty sepBlurSpread;
17 SerializedProperty useSrcAlphaAsMask;
19 SerializedProperty bloomIntensity;
20 SerializedProperty bloomthreshold;
21 SerializedProperty bloomBlurIterations;
23 SerializedProperty lensflares;
25 SerializedProperty hollywoodFlareBlurIterations;
27 SerializedProperty lensflareMode;
28 SerializedProperty hollyStretchWidth;
29 SerializedProperty lensflareIntensity;
30 SerializedProperty lensflarethreshold;
31 SerializedProperty flareColorA;
32 SerializedProperty flareColorB;
33 SerializedProperty flareColorC;
34 SerializedProperty flareColorD;
36 SerializedProperty lensFlareVignetteMask;
39 serObj =
new SerializedObject (target);
41 screenBlendMode = serObj.FindProperty(
"screenBlendMode");
42 hdr = serObj.FindProperty(
"hdr");
44 sepBlurSpread = serObj.FindProperty(
"sepBlurSpread");
45 useSrcAlphaAsMask = serObj.FindProperty(
"useSrcAlphaAsMask");
47 bloomIntensity = serObj.FindProperty(
"bloomIntensity");
48 bloomthreshold = serObj.FindProperty(
"bloomThreshold");
49 bloomBlurIterations = serObj.FindProperty(
"bloomBlurIterations");
51 lensflares = serObj.FindProperty(
"lensflares");
53 lensflareMode = serObj.FindProperty(
"lensflareMode");
54 hollywoodFlareBlurIterations = serObj.FindProperty(
"hollywoodFlareBlurIterations");
55 hollyStretchWidth = serObj.FindProperty(
"hollyStretchWidth");
56 lensflareIntensity = serObj.FindProperty(
"lensflareIntensity");
57 lensflarethreshold = serObj.FindProperty(
"lensflareThreshold");
58 flareColorA = serObj.FindProperty(
"flareColorA");
59 flareColorB = serObj.FindProperty(
"flareColorB");
60 flareColorC = serObj.FindProperty(
"flareColorC");
61 flareColorD = serObj.FindProperty(
"flareColorD");
62 lensFlareVignetteMask = serObj.FindProperty(
"lensFlareVignetteMask");
64 tweakMode = serObj.FindProperty(
"tweakMode");
68 public override void OnInspectorGUI () {
71 GUILayout.Label(
"HDR " + (hdr.enumValueIndex == 0 ?
"auto detected, " : (hdr.enumValueIndex == 1 ?
"forced on, " :
"disabled, ")) + (useSrcAlphaAsMask.floatValue < 0.1f ?
" ignoring alpha channel glow information" :
" using alpha channel glow information"), EditorStyles.miniBoldLabel);
73 EditorGUILayout.PropertyField (tweakMode,
new GUIContent(
"Tweak mode"));
74 EditorGUILayout.PropertyField (screenBlendMode,
new GUIContent(
"Blend mode"));
75 EditorGUILayout.PropertyField (hdr,
new GUIContent(
"HDR"));
80 if (screenBlendMode.enumValueIndex==0 && ((cam.hdr && hdr.enumValueIndex==0) || (hdr.enumValueIndex==1))) {
81 EditorGUILayout.HelpBox(
"Screen blend is not supported in HDR. Using 'Add' instead.", MessageType.Info);
85 if (1 == tweakMode.intValue)
86 EditorGUILayout.PropertyField (lensflares,
new GUIContent(
"Cast lens flares"));
88 EditorGUILayout.Separator ();
90 EditorGUILayout.PropertyField (bloomIntensity,
new GUIContent(
"Intensity"));
91 bloomthreshold.floatValue = EditorGUILayout.Slider (
"threshold", bloomthreshold.floatValue, -0.05f, 4.0f);
92 bloomBlurIterations.intValue = EditorGUILayout.IntSlider (
"Blur iterations", bloomBlurIterations.intValue, 1, 4);
93 sepBlurSpread.floatValue = EditorGUILayout.Slider (
"Blur spread", sepBlurSpread.floatValue, 0.1f, 10.0f);
95 if (1 == tweakMode.intValue)
96 useSrcAlphaAsMask.floatValue = EditorGUILayout.Slider (
new GUIContent(
"Use alpha mask",
"Make alpha channel define glowiness"), useSrcAlphaAsMask.floatValue, 0.0f, 1.0f);
98 useSrcAlphaAsMask.floatValue = 0.0f;
100 if (1 == tweakMode.intValue) {
101 EditorGUILayout.Separator ();
103 if (lensflares.boolValue) {
106 if (0 != tweakMode.intValue)
107 EditorGUILayout.PropertyField (lensflareMode,
new GUIContent(
"Lens flare mode"));
109 lensflareMode.enumValueIndex = 0;
111 EditorGUILayout.PropertyField(lensFlareVignetteMask,
new GUIContent(
"Lens flare mask",
"This mask is needed to prevent lens flare artifacts"));
113 EditorGUILayout.PropertyField (lensflareIntensity,
new GUIContent(
"Local intensity"));
114 lensflarethreshold.floatValue = EditorGUILayout.Slider (
"Local threshold", lensflarethreshold.floatValue, 0.0f, 1.0f);
116 if (lensflareMode.intValue == 0) {
118 EditorGUILayout.BeginHorizontal ();
119 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
"1st Color"));
120 EditorGUILayout.PropertyField (flareColorB,
new GUIContent(
"2nd Color"));
121 EditorGUILayout.EndHorizontal ();
123 EditorGUILayout.BeginHorizontal ();
124 EditorGUILayout.PropertyField (flareColorC,
new GUIContent(
"3rd Color"));
125 EditorGUILayout.PropertyField (flareColorD,
new GUIContent(
"4th Color"));
126 EditorGUILayout.EndHorizontal ();
128 else if (lensflareMode.intValue == 1) {
130 EditorGUILayout.PropertyField (hollyStretchWidth,
new GUIContent(
"Stretch width"));
131 hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (
"Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
133 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
"Tint Color"));
135 else if (lensflareMode.intValue == 2) {
137 EditorGUILayout.PropertyField (hollyStretchWidth,
new GUIContent(
"Stretch width"));
138 hollywoodFlareBlurIterations.intValue = EditorGUILayout.IntSlider (
"Blur iterations", hollywoodFlareBlurIterations.intValue, 1, 4);
140 EditorGUILayout.BeginHorizontal ();
141 EditorGUILayout.PropertyField (flareColorA,
new GUIContent(
"1st Color"));
142 EditorGUILayout.PropertyField (flareColorB,
new GUIContent(
"2nd Color"));
143 EditorGUILayout.EndHorizontal ();
145 EditorGUILayout.BeginHorizontal ();
146 EditorGUILayout.PropertyField (flareColorC,
new GUIContent(
"3rd Color"));
147 EditorGUILayout.PropertyField (flareColorD,
new GUIContent(
"4th Color"));
148 EditorGUILayout.EndHorizontal ();
152 lensflares.boolValue =
false;
154 serObj.ApplyModifiedProperties();