[Bug] Either Graph.GetNodes() or RecalculateDebugLimits() should be mindful of destroyed nodes

Error log,

IndexOutOfRangeException: Index was outside the bounds of the array.
Pathfinding.PathHandler.GetPathNode (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/PathHandler.cs:196)
AstarPath+<>c__DisplayClass97_0.<RecalculateDebugLimits>b__0 (Pathfinding.GraphNode node) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:721)
Pathfinding.PointGraph.GetNodes (System.Action`1[T] action) (at Assets/AstarPathfindingProject/Generators/PointGenerator.cs:172)
AstarPath.RecalculateDebugLimits () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:715)
AstarPath.OnDrawGizmos () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:788)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)

This happens when a node is destroyed dynamically with node.Destroy().

I only ever call this inside of AstarPath.active.AddWorkItem() or GraphModifier OnPostScan/OnGraphsPostUpdate.

  1. Create node
  2. Draw gizmos
  3. node.Destroy()
  4. Error

My current workaround is to add,


				graphs[i].GetNodes(node => {
					if (node.Destroyed)
                    {
						return;
                    }

to RecalculateDebugLimits()

Hi

Sorry for the late reply.
Node.Destroy should never be called by user code. Are you calling it yourself?
Here’s the documentation for it