You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.0 KiB

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