ProceduralGridMoverEditor.cs 1021 B

12345678910111213141516171819202122232425262728
  1. using UnityEngine;
  2. using UnityEditor;
  3. using System.Collections.Generic;
  4. namespace Pathfinding {
  5. [CustomEditor(typeof(ProceduralGridMover))]
  6. [CanEditMultipleObjects]
  7. public class ProceduralGridMoverEditor : EditorBase {
  8. GUIContent[] graphLabels = new GUIContent[32];
  9. protected override void Inspector () {
  10. // Make sure the AstarPath object is initialized and the graphs are loaded, this is required to be able to show graph names in the mask popup
  11. AstarPath.FindAstarPath();
  12. for (int i = 0; i < graphLabels.Length; i++) {
  13. if (AstarPath.active == null || AstarPath.active.data.graphs == null || i >= AstarPath.active.data.graphs.Length || AstarPath.active.data.graphs[i] == null) {
  14. graphLabels[i] = new GUIContent("Graph " + i + (i == 31 ? "+" : ""));
  15. } else {
  16. graphLabels[i] = new GUIContent(AstarPath.active.data.graphs[i].name + " (graph " + i + ")");
  17. }
  18. }
  19. Popup("graphIndex", graphLabels, "Graph");
  20. PropertyField("target");
  21. PropertyField("updateDistance");
  22. }
  23. }
  24. }