EnviroReflectionProbeEditor.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEditor;
  5. using UnityEditorInternal;
  6. namespace Enviro
  7. {
  8. [CustomEditor(typeof(Enviro.EnviroReflectionProbe))]
  9. public class EnviroReflectionProbeEditor : Editor {
  10. GUIStyle boxStyle;
  11. GUIStyle boxStyleModified;
  12. GUIStyle wrapStyle;
  13. GUIStyle wrapStyle2;
  14. GUIStyle clearStyle;
  15. Enviro.EnviroReflectionProbe myTarget;
  16. public bool showAudio = false;
  17. public bool showFog = false;
  18. public bool showSeason = false;
  19. public bool showClouds = false;
  20. public bool showGeneral = false;
  21. public bool showPostProcessing = false;
  22. public bool showThirdParty = false;
  23. private Color boxColor1;
  24. SerializedObject serializedObj;
  25. void OnEnable()
  26. {
  27. myTarget = (Enviro.EnviroReflectionProbe)target;
  28. serializedObj = new SerializedObject (myTarget);
  29. boxColor1 = new Color(0.95f, 0.95f, 0.95f,1f);
  30. }
  31. public override void OnInspectorGUI ()
  32. {
  33. myTarget = (Enviro.EnviroReflectionProbe)target;
  34. serializedObj.UpdateIfRequiredOrScript ();
  35. //Set up the box style
  36. if (boxStyle == null)
  37. {
  38. boxStyle = new GUIStyle(GUI.skin.box);
  39. boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
  40. boxStyle.fontStyle = FontStyle.Bold;
  41. boxStyle.alignment = TextAnchor.UpperLeft;
  42. }
  43. if (boxStyleModified == null)
  44. {
  45. boxStyleModified = new GUIStyle(EditorStyles.helpBox);
  46. boxStyleModified.normal.textColor = GUI.skin.label.normal.textColor;
  47. boxStyleModified.fontStyle = FontStyle.Bold;
  48. boxStyleModified.fontSize = 11;
  49. boxStyleModified.alignment = TextAnchor.UpperLeft;
  50. }
  51. //Setup the wrap style
  52. if (wrapStyle == null)
  53. {
  54. wrapStyle = new GUIStyle(GUI.skin.label);
  55. wrapStyle.fontStyle = FontStyle.Bold;
  56. wrapStyle.wordWrap = true;
  57. }
  58. if (wrapStyle2 == null)
  59. {
  60. wrapStyle2 = new GUIStyle(GUI.skin.label);
  61. wrapStyle2.fontStyle = FontStyle.Normal;
  62. wrapStyle2.wordWrap = true;
  63. }
  64. if (clearStyle == null) {
  65. clearStyle = new GUIStyle(GUI.skin.label);
  66. clearStyle.normal.textColor = GUI.skin.label.normal.textColor;
  67. clearStyle.fontStyle = FontStyle.Bold;
  68. clearStyle.alignment = TextAnchor.UpperRight;
  69. }
  70. GUILayout.BeginVertical(" Enviro - Reflection Probe", boxStyle);
  71. GUILayout.Space(30);
  72. GUI.backgroundColor = boxColor1;
  73. GUILayout.BeginVertical("Information", boxStyleModified);
  74. GUI.backgroundColor = Color.white;
  75. GUILayout.Space(20);
  76. EditorGUILayout.LabelField("Use this component to update your realtime reflection probes with Enviro Sky. You also can enable the 'Custom Rendering' to have enviro effects in your reflection probes!", wrapStyle2);
  77. EditorGUILayout.LabelField("Please enable 'Standalone Probe' if you use this component on your own places reflection probes.", wrapStyle2);
  78. GUILayout.EndVertical();
  79. GUI.backgroundColor = boxColor1;
  80. GUILayout.BeginVertical("Setup", boxStyleModified);
  81. GUI.backgroundColor = Color.white;
  82. GUILayout.Space(20);
  83. myTarget.standalone = EditorGUILayout.Toggle("Standalone Probe", myTarget.standalone);
  84. if (myTarget.standalone)
  85. {
  86. GUILayout.Space(10);
  87. #if ENVIRO_HD
  88. GUI.backgroundColor = boxColor1;
  89. GUILayout.BeginVertical("Enviro Effects Rendering", boxStyleModified);
  90. GUI.backgroundColor = Color.white;
  91. GUILayout.Space(20);
  92. myTarget.customRendering = EditorGUILayout.Toggle("Render Enviro Effects", myTarget.customRendering);
  93. if(myTarget.customRendering)
  94. {
  95. EditorGUI.BeginChangeCheck();
  96. //myTarget.useFog = EditorGUILayout.Toggle("Use Fog", myTarget.useFog);
  97. if (EditorGUI.EndChangeCheck())
  98. {
  99. serializedObj.ApplyModifiedProperties();
  100. }
  101. }
  102. GUILayout.EndVertical();
  103. #endif
  104. GUI.backgroundColor = boxColor1;
  105. GUILayout.BeginVertical("Update Settings", boxStyleModified);
  106. GUI.backgroundColor = Color.white;
  107. GUILayout.Space(20);
  108. myTarget.reflectionsUpdateTreshhold = EditorGUILayout.FloatField("Update Treshold in GameTime Hours", myTarget.reflectionsUpdateTreshhold);
  109. if (myTarget.customRendering)
  110. {
  111. myTarget.useTimeSlicing = EditorGUILayout.Toggle("Use Time-Slicing", myTarget.useTimeSlicing);
  112. }
  113. GUILayout.EndVertical();
  114. }
  115. GUILayout.EndVertical();
  116. // END
  117. EditorGUILayout.EndVertical ();
  118. EditorUtility.SetDirty (target);
  119. }
  120. }
  121. }