A* Pathfinding Project

Extending debug features (OnDrawGizmos) for a custom graph



Sorry if this was asked before, couldn’t find anything in forums.

The question is, how do we extend debug (drawing gizmos) features for custom graph? There are some settings for a general case, like drawing unwalkable nodes, tags, areas, etc. We would like to add new settings to debug additional parameters added in my custom graph.

What is the best/right way to do it? For now, I’ve changed GraphGizmoHelper class, the drawback is that on any update it will be changed back.




You override the OnDrawGizmos method in your graph class. You can take a look at how the other graph classes have done it. The code is a bit more complex because it does a lot of caching to improve performance. You can if you want use the Unity Gizmos class, but that will be less performant. Generally I don’t think you would need to change the GraphGizmoHelper class.


I was hoping to use your optimizations to draw gismos and just add additional options to it, like extend color selection for nodes, draw nodes similar to how unwalkable are, etc.

Seems I’ll have to go the long way :slight_smile:




If your graph is similar to one of the existing graph types you can probably just copy and paste that code and modify it to fit your graph. The color selection box in the inspector can be extended, but then you will have to modify some code.