Simple way to clear

Hi,
The astarpath component is fixed in the scene and it never destroyed while running the game. I just try to remove all graphs which are used and no longer needed instead of recreating the astarpath component whenever loading new game stage.
But I’m not sure the way I’m using is correct or not. The cleaning all information of the astarpath is performed by below code.
AstarData data = AstarPath.active.astarData; NavGraph[] graphs = data.graphs; foreach( NavGraph graph in graphs ) { data.RemoveGraph( graph ); }
is this okay? or is there any easy way for that? I’m worried about other bugs that could be caused by missing things for new Graph data.

Is all the graphs can be removed at once?

Hi

That should be ok.

In 3.6 version, this causes an error. the message is

IndexOutOfRangeException: Array index is out of range. (wrapper stelemref) object:stelemref (object,intptr,object) Pathfinding.GridNode.SetGridGraph (Int32 graphIndex, Pathfinding.GridGraph graph) (at Assets/AstarPathfindingProject/Generators/NodeClasses/GridNode.cs:33) Pathfinding.GridGraph.RemoveGridGraphFromStatic () (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:87) Pathfinding.GridGraph.OnDestroy () (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:83) AstarPath.PerformBlockingActions (Boolean force, Boolean unblockOnComplete) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:897) AstarPath.Update () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:857)

something changed to clear all graphs in this version?

Im using this one for latest 2D pathfinding free

            //get all active graph
            AstarData data = AstarPath.active.data;

            //empty all data graph
            System.Array.Clear(data.graphs, 0, data.graphs.Length);