summaryrefslogtreecommitdiff
path: root/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs
diff options
context:
space:
mode:
authorchai <215380520@qq.com>2024-05-23 10:08:29 +0800
committerchai <215380520@qq.com>2024-05-23 10:08:29 +0800
commit8722a9920c1f6119bf6e769cba270e63097f8e25 (patch)
tree2eaf9865de7fb1404546de4a4296553d8f68cc3b /Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs
parent3ba4020b69e5971bb0df7ee08b31d10ea4d01937 (diff)
+ astar project
Diffstat (limited to 'Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs')
-rw-r--r--Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs47
1 files changed, 47 insertions, 0 deletions
diff --git a/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs
new file mode 100644
index 0000000..4d125ef
--- /dev/null
+++ b/Other/AstarPathfindingDemo/Packages/com.arongranberg.astar/Editor/ProceduralGridMoverEditor.cs
@@ -0,0 +1,47 @@
+using UnityEngine;
+using UnityEditor;
+using System.Collections.Generic;
+
+namespace Pathfinding {
+ [CustomEditor(typeof(ProceduralGraphMover))]
+ [CanEditMultipleObjects]
+ public class ProceduralGridMoverEditor : EditorBase {
+ GUIContent[] graphLabels = new GUIContent[32];
+
+ protected override void Inspector () {
+ // 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
+ AstarPath.FindAstarPath();
+
+ for (int i = 0; i < graphLabels.Length; i++) {
+ if (AstarPath.active == null || AstarPath.active.data.graphs == null || i >= AstarPath.active.data.graphs.Length || AstarPath.active.data.graphs[i] == null) {
+ graphLabels[i] = new GUIContent("Graph " + i + (i == 31 ? "+" : ""));
+ } else {
+ graphLabels[i] = new GUIContent(AstarPath.active.data.graphs[i].name + " (graph " + i + ")");
+ }
+ }
+
+ Popup("graphIndex", graphLabels, "Graph");
+ PropertyField("target");
+
+ // Only show the update distance field if the graph is a grid graph, or if we are not sure which graph type it is
+ var graphIndexProp = FindProperty("graphIndex");
+ bool showField = true;
+ if (!graphIndexProp.hasMultipleDifferentValues && AstarPath.active != null) {
+ var graphIndex = graphIndexProp.intValue;
+ if (graphIndex >= 0 && graphIndex < AstarPath.active.data.graphs.Length) {
+ var graph = AstarPath.active.data.graphs[graphIndex];
+ if (graph is GridGraph) {
+ // NOOP
+ } else if (graph is RecastGraph) {
+ showField = false;
+ } else {
+ EditorGUILayout.HelpBox("The selected graph is not a grid, layered grid or recast graph", MessageType.Warning);
+ }
+ }
+ }
+ if (showField) {
+ PropertyField("updateDistance");
+ }
+ }
+ }
+}