NavMeshModifierEditor.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using UnityEngine.AI;
  2. namespace UnityEditor.AI
  3. {
  4. [CanEditMultipleObjects]
  5. [CustomEditor(typeof(NavMeshModifier))]
  6. class NavMeshModifierEditor : Editor
  7. {
  8. SerializedProperty m_AffectedAgents;
  9. SerializedProperty m_Area;
  10. SerializedProperty m_IgnoreFromBuild;
  11. SerializedProperty m_OverrideArea;
  12. void OnEnable()
  13. {
  14. m_AffectedAgents = serializedObject.FindProperty("m_AffectedAgents");
  15. m_Area = serializedObject.FindProperty("m_Area");
  16. m_IgnoreFromBuild = serializedObject.FindProperty("m_IgnoreFromBuild");
  17. m_OverrideArea = serializedObject.FindProperty("m_OverrideArea");
  18. NavMeshVisualizationSettings.showNavigation++;
  19. }
  20. void OnDisable()
  21. {
  22. NavMeshVisualizationSettings.showNavigation--;
  23. }
  24. public override void OnInspectorGUI()
  25. {
  26. serializedObject.Update();
  27. EditorGUILayout.PropertyField(m_IgnoreFromBuild);
  28. EditorGUILayout.PropertyField(m_OverrideArea);
  29. if (m_OverrideArea.boolValue)
  30. {
  31. EditorGUI.indentLevel++;
  32. NavMeshComponentsGUIUtility.AreaPopup("Area Type", m_Area);
  33. EditorGUI.indentLevel--;
  34. }
  35. NavMeshComponentsGUIUtility.AgentMaskPopup("Affected Agents", m_AffectedAgents);
  36. EditorGUILayout.Space();
  37. serializedObject.ApplyModifiedProperties();
  38. }
  39. }
  40. }