1 using UnityEngine;
2 using
UnityEditor;
3
4
5 namespace
UnityStandardAssets.Water
6 {
7     
[CustomEditor(typeof(PlanarReflection))]
8     
public class PlanarReflectionEditor : Editor
9     {
10         
private SerializedObject serObj;
11
12         
//private SerializedProperty wavesFrequency;
13
14         
// reflection
15         
private SerializedProperty reflectionMask;
16         
private SerializedProperty reflectSkybox;
17         
private SerializedProperty clearColor;
18
19         
bool showKidsWithReflectionHint = false;
20
21         
public void OnEnable()
22         {
23             serObj =
new SerializedObject(target);
24
25             reflectionMask = serObj.FindProperty(
"reflectionMask");
26             reflectSkybox = serObj.FindProperty(
"reflectSkybox");
27             clearColor = serObj.FindProperty(
"clearColor");
28         }
29
30         
public override void OnInspectorGUI()
31         {
32             GUILayout.Label(
"Render planar reflections and use GrabPass for refractions", EditorStyles.miniBoldLabel);
33
34             
if (!SystemInfo.supportsRenderTextures)
35                 EditorGUILayout.HelpBox(
"Realtime reflections not supported", MessageType.Warning);
36
37             serObj.Update();
38
39             EditorGUILayout.PropertyField(reflectionMask,
new GUIContent("Reflection layers"));
40             EditorGUILayout.PropertyField(reflectSkybox,
new GUIContent("Use skybox"));
41             EditorGUILayout.PropertyField(clearColor,
new GUIContent("Clear color"));
42
43             showKidsWithReflectionHint = EditorGUILayout.BeginToggleGroup(
"Show all tiles", showKidsWithReflectionHint);
44             
if (showKidsWithReflectionHint)
45             {
46                 
int i = 0;
47                 
foreach (Transform t in ((PlanarReflection)target).transform)
48                 {
49                     
if (t.GetComponent<WaterTile>())
50                     {
51                         
if (i % 2 == 0)
52                             EditorGUILayout.BeginHorizontal();
53                         EditorGUILayout.ObjectField(t,
typeof(Transform), true);
54                         
if (i % 2 == 1)
55                             EditorGUILayout.EndHorizontal();
56                         i = (i +
1) % 2;
57                     }
58                 }
59                 
if (i > 0)
60                     EditorGUILayout.EndHorizontal();
61             }
62             EditorGUILayout.EndToggleGroup();
63
64             serObj.ApplyModifiedProperties();
65         }
66
67     }
68 }