BlockerEditor.cs 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections;
  4. [CustomEditor(typeof(Blocker))]
  5. public class BlockerEditor : Editor
  6. {
  7. bool m_debug = false;
  8. public override void OnInspectorGUI()
  9. {
  10. base.OnInspectorGUI();
  11. Blocker obstacle = (Blocker)target;
  12. if (obstacle.m_fluid == null)
  13. {
  14. EditorGUILayout.HelpBox("Fluid not defined", MessageType.Error);
  15. }
  16. // Scale
  17. obstacle.m_useScaleAsSize = !EditorGUILayout.Toggle("Set Size Manually", !obstacle.m_useScaleAsSize);
  18. if (obstacle.m_useScaleAsSize)
  19. {
  20. EditorGUILayout.HelpBox(" Using global scale as size", MessageType.None);
  21. }
  22. else
  23. {
  24. ++EditorGUI.indentLevel;
  25. obstacle.m_radius = EditorGUILayout.Slider("Radius", obstacle.m_radius, 0.0f, 5.0f);
  26. --EditorGUI.indentLevel;
  27. }
  28. // Debug
  29. m_debug = EditorGUILayout.Foldout(m_debug, "Debug");
  30. if (m_debug)
  31. {
  32. ++EditorGUI.indentLevel;
  33. obstacle.m_showGizmo = EditorGUILayout.Toggle("Draw Gizmo", obstacle.m_showGizmo);
  34. --EditorGUI.indentLevel;
  35. }
  36. EditorUtility.SetDirty(obstacle);
  37. }
  38. }