Skip to content

Instantly share code, notes, and snippets.

@Arakade
Created February 15, 2016 23:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Arakade/aeeb6cc50faf7bd76fc5 to your computer and use it in GitHub Desktop.
Save Arakade/aeeb6cc50faf7bd76fc5 to your computer and use it in GitHub Desktop.
A* Project patch to enable ASTARDEBUG shift-mouse-over displaying path information
diff --git "a/C:\\Users\\User\\AppData\\Local\\Temp\\TortoiseGit\\Gri8182.tmp\\GridGeneratorEditor-c900cb4-left.cs" "b/C:\\Users\\User\\AppData\\Local\\Temp\\TortoiseGit\\Gri8162.tmp\\GridGeneratorEditor-bd6560d-right.cs"
index b636bd5..1facb21 100644
--- "a/C:\\Users\\User\\AppData\\Local\\Temp\\TortoiseGit\\Gri8182.tmp\\GridGeneratorEditor-c900cb4-left.cs"
+++ "b/C:\\Users\\User\\AppData\\Local\\Temp\\TortoiseGit\\Gri8162.tmp\\GridGeneratorEditor-bd6560d-right.cs"
@@ -1,3 +1,5 @@
+#define ASTARDEBUG
+
using UnityEngine;
using UnityEditor;
using Pathfinding.Serialization.JsonFx;
@@ -690,14 +692,19 @@ namespace Pathfinding {
Handles.matrix = Matrix4x4.identity;
- #if ASTARDEBUG
- //Draws some info over the node closest to the mouse
- Ray ray = HandleUtility.GUIPointToWorldRay (Event.current.mousePosition);
+#if ASTARDEBUG
+ if (Event.current.shift) {
+ //Draws some info over the node closest to the mouse
+ //Handles.SetCamera(Camera.current);
- Vector3 p = ray.GetPoint (100);
+ Ray ray = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);
+ var layerMask = graph.collision.heightMask;
+ RaycastHit hitInfo;
+ if (!Physics.Raycast(ray, out hitInfo, float.MaxValue, layerMask))
+ return;
- if (Event.current.shift) {
+ Vector3 p = hitInfo.point;
GraphNode close = graph.GetNearest (p).node;
@@ -709,16 +716,23 @@ namespace Pathfinding {
return;
}
- Handles.SphereCap (0,(Vector3)node1.position,Quaternion.identity,graph.nodeSize*0.5F);
-
-
- //Node node = node1;
+ Handles.SphereCap (0, (Vector3)node1.position, Quaternion.identity, graph.nodeSize*0.5F);
+
+ string txt = string.Format("Position : {0}\nWalkable : {1}\nTag : {2}\nArea : {3}\nPenalty(graph) : {4}", node1.position, node1.Walkable, node1.Tag, node1.Area, node1.Penalty);
+ PathHandler debugData = AstarPath.active.debugPathData;
+ if (null != debugData) {
+ PathNode node = debugData.GetPathNode(node1);
+ txt += string.Format("\nG : {0}\nH : {1}\nF : {2}", node.G, node.H, node.F);
+ } else {
+ txt += "\n(no active path)";
+ }
+
GUI.color = Color.white;
- //Handles.Label((Vector3)node.position + Vector3.up*2,"G : "+node.+"\nH : "+node.h+"\nF : "+node.f+"\nPosition : "+node.position.ToString (),EditorStyles.whiteBoldLabel);
+ Handles.Label((Vector3)node1.position + Vector3.up * 2f * graph.nodeSize, txt, EditorStyles.whiteBoldLabel);
}
- #endif
+#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment