Clearing a graph of all nodes by script

Hello again :smile:
I am still trying to get my procedural point graph node generation to work. I have managed to add point nodes via script, but I am currently stuck with the following question: How do I make a point graph a ā€œblank slateā€, so to speak? Basically, would would happen if I clicked on the Scan button in the Astar inspector. All nodes in the graph should be destroyed so I can add new ones to a clean node array. I have looked into the Astar code to see how it does it but it only seems to call ā€œAstarPath.active.astarData.DeserializeGraphs ()ā€. I only need to clear one graph, though.

Edit: Would it be easiest to just declare the graph anew?

        PointGraph pointGraph = AstarPath.active.graphs[1] as PointGraph;
	pointGraph = new PointGraph();

Hi

Currently the best way is probably to do something like

AstarPath.RegisterSafeUpdate (() => {
     var pointGraph = ...;
     // Internal destroy method
     pointGraph.GetNodes(node => { node.Destroy(); return true; });
     pointGraph.nodes = new PointNode[4]; // Small initial buffer
     pointGraph.nodeCount = 0;
}

I have not tried this, but something similar should work.