EnviroWAPIEditor.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEditor;
  5. #if WORLDAPI_PRESENT
  6. namespace Enviro
  7. {
  8. [CustomEditor(typeof(EnviroWorldAPI))]
  9. public class EnviroWAPIEditor : Editor {
  10. private GUIStyle boxStyle;
  11. private GUIStyle wrapStyle;
  12. private GUIStyle headerStyle;
  13. SerializedObject serializedObj;
  14. private EnviroWorldAPI myTarget;
  15. SerializedProperty snowPower, wetnessPower, fogPower, seasons, time, cloudCover, location, temperature;
  16. void OnEnable()
  17. {
  18. myTarget = (EnviroWorldAPI)target;
  19. serializedObj = new SerializedObject (myTarget);
  20. snowPower = serializedObj.FindProperty ("snowPower");
  21. wetnessPower = serializedObj.FindProperty ("wetnessPower");
  22. temperature = serializedObj.FindProperty("temperature");
  23. fogPower = serializedObj.FindProperty ("fogPower");
  24. //windDirection = serializedObj.FindProperty ("windDirection");
  25. //windSpeed = serializedObj.FindProperty ("windSpeed");
  26. seasons = serializedObj.FindProperty ("seasons");
  27. time = serializedObj.FindProperty ("time");
  28. cloudCover = serializedObj.FindProperty ("cloudCover");
  29. location = serializedObj.FindProperty ("location");
  30. }
  31. public override void OnInspectorGUI ()
  32. {
  33. if (boxStyle == null)
  34. {
  35. boxStyle = new GUIStyle(GUI.skin.box);
  36. boxStyle.normal.textColor = GUI.skin.label.normal.textColor;
  37. boxStyle.fontStyle = FontStyle.Bold;
  38. boxStyle.alignment = TextAnchor.UpperLeft;
  39. }
  40. if (wrapStyle == null)
  41. {
  42. wrapStyle = new GUIStyle(GUI.skin.label);
  43. wrapStyle.fontStyle = FontStyle.Normal;
  44. wrapStyle.wordWrap = true;
  45. }
  46. if (headerStyle == null)
  47. {
  48. headerStyle = new GUIStyle(GUI.skin.label);
  49. headerStyle.fontStyle = FontStyle.Bold;
  50. headerStyle.wordWrap = true;
  51. }
  52. EditorGUI.BeginChangeCheck ();
  53. GUILayout.BeginVertical("Enviro 3 - WAPI Integration", boxStyle);
  54. GUILayout.Space(20);
  55. EditorGUILayout.LabelField("Welcome to the World Manager Integration for Enviro 3 - Sky and Weather!", wrapStyle);
  56. GUILayout.EndVertical ();
  57. GUILayout.BeginVertical("Controls", boxStyle);
  58. GUILayout.Space(20);
  59. GUILayout.BeginVertical("Time, Season and Location", boxStyle);
  60. GUILayout.Space(20);
  61. EditorGUILayout.PropertyField (time, true, null);
  62. EditorGUILayout.PropertyField (location, true, null);
  63. EditorGUILayout.PropertyField (seasons, true, null);
  64. GUILayout.EndVertical ();
  65. GUILayout.BeginVertical("Weather", boxStyle);
  66. GUILayout.Space(20);
  67. EditorGUILayout.LabelField("Enviro will change weather when using GetFromWAPI mode here to match WAPI values!", wrapStyle);
  68. EditorGUI.indentLevel++;
  69. EditorGUILayout.PropertyField (cloudCover, true, null);
  70. EditorGUILayout.PropertyField (snowPower, true, null);
  71. EditorGUILayout.PropertyField (wetnessPower, true, null);
  72. EditorGUILayout.PropertyField (temperature, true, null);
  73. EditorGUI.indentLevel--;
  74. GUILayout.Space(10);
  75. //GUILayout.Label ("Wind",headerStyle);
  76. //EditorGUI.indentLevel++;
  77. //EditorGUILayout.PropertyField (windSpeed, true, null);
  78. //EditorGUILayout.PropertyField (windDirection, true, null);
  79. //EditorGUI.indentLevel--;
  80. GUILayout.Label ("Fog",headerStyle);
  81. EditorGUI.indentLevel++;
  82. EditorGUILayout.PropertyField (fogPower, true, null);
  83. EditorGUI.indentLevel--;
  84. GUILayout.EndVertical ();
  85. GUILayout.EndVertical ();
  86. if (EditorGUI.EndChangeCheck ()) {
  87. serializedObj.ApplyModifiedProperties ();
  88. }
  89. }
  90. }
  91. }
  92. #endif