5 namespace UnityStandardAssets.ImageEffects
7 [CustomEditor (typeof(SunShafts))]
10 SerializedObject serObj;
12 SerializedProperty sunTransform;
13 SerializedProperty radialBlurIterations;
14 SerializedProperty sunColor;
15 SerializedProperty sunThreshold;
16 SerializedProperty sunShaftBlurRadius;
17 SerializedProperty sunShaftIntensity;
18 SerializedProperty useDepthTexture;
19 SerializedProperty resolution;
20 SerializedProperty screenBlendMode;
21 SerializedProperty maxRadius;
24 serObj =
new SerializedObject (target);
26 screenBlendMode = serObj.FindProperty(
"screenBlendMode");
28 sunTransform = serObj.FindProperty(
"sunTransform");
29 sunColor = serObj.FindProperty(
"sunColor");
30 sunThreshold = serObj.FindProperty(
"sunThreshold");
32 sunShaftBlurRadius = serObj.FindProperty(
"sunShaftBlurRadius");
33 radialBlurIterations = serObj.FindProperty(
"radialBlurIterations");
35 sunShaftIntensity = serObj.FindProperty(
"sunShaftIntensity");
37 resolution = serObj.FindProperty(
"resolution");
39 maxRadius = serObj.FindProperty(
"maxRadius");
41 useDepthTexture = serObj.FindProperty(
"useDepthTexture");
45 public override void OnInspectorGUI () {
48 EditorGUILayout.BeginHorizontal();
50 EditorGUILayout.PropertyField (useDepthTexture,
new GUIContent (
"Rely on Z Buffer?"));
51 if ((target as
SunShafts).GetComponent<Camera>())
52 GUILayout.Label(
"Current camera mode: "+ (target as SunShafts).GetComponent<Camera>().depthTextureMode, EditorStyles.miniBoldLabel);
54 EditorGUILayout.EndHorizontal();
67 EditorGUILayout.PropertyField (resolution,
new GUIContent(
"Resolution"));
68 EditorGUILayout.PropertyField (screenBlendMode,
new GUIContent(
"Blend mode"));
70 EditorGUILayout.Separator ();
72 EditorGUILayout.BeginHorizontal();
74 EditorGUILayout.PropertyField (sunTransform,
new GUIContent(
"Shafts caster",
"Chose a transform that acts as a root point for the produced sun shafts"));
75 if ((target as SunShafts).sunTransform && (target as SunShafts).GetComponent<Camera>()) {
76 if (GUILayout.Button(
"Center on " + (target as SunShafts).GetComponent<Camera>().name)) {
77 if (EditorUtility.DisplayDialog (
"Move sun shafts source?",
"The SunShafts caster named "+ (target as SunShafts).sunTransform.name +
"\n will be centered along "+(target as SunShafts).GetComponent<Camera>().name+
". Are you sure? ",
"Please do",
"Don't")) {
78 Ray ray = (target as SunShafts).GetComponent<Camera>().ViewportPointToRay(
new Vector3(0.5f,0.5f,0));
79 (target as SunShafts).sunTransform.position = ray.origin + ray.direction * 500.0f;
80 (target as SunShafts).sunTransform.LookAt ((target as SunShafts).transform);
85 EditorGUILayout.EndHorizontal();
87 EditorGUILayout.Separator ();
89 EditorGUILayout.PropertyField (sunThreshold,
new GUIContent (
"Threshold color"));
90 EditorGUILayout.PropertyField (sunColor,
new GUIContent (
"Shafts color"));
91 maxRadius.floatValue = 1.0f - EditorGUILayout.Slider (
"Distance falloff", 1.0f - maxRadius.floatValue, 0.1f, 1.0f);
93 EditorGUILayout.Separator ();
95 sunShaftBlurRadius.floatValue = EditorGUILayout.Slider (
"Blur size", sunShaftBlurRadius.floatValue, 1.0f, 10.0f);
96 radialBlurIterations.intValue = EditorGUILayout.IntSlider (
"Blur iterations", radialBlurIterations.intValue, 1, 3);
98 EditorGUILayout.Separator ();
100 EditorGUILayout.PropertyField (sunShaftIntensity,
new GUIContent(
"Intensity"));
102 serObj.ApplyModifiedProperties();