I am trying this code to delete nodes, but it does not seem to work.
If I put the graph on “View areas” it shows the nodes deleted, but on all other graph visualization modes, the deleted nodes still appear
DeleteAllRegionsExcept aThis = target as DeleteAllRegionsExcept;
VisualElement VisualElement = new VisualElement();
Button Button;
VisualElement.Add(Button = new Button(() => {
RecastGraph recastGraph = AstarPath.active.data.recastGraph;
uint[] areas = aThis.RetainNodes.Cast(T => {
NNInfoInternal v = recastGraph.GetNearest(T.position);
return v.node.Area;
}).ToArray();
recastGraph.GetNodes((N) => {
if (Array.IndexOf(areas, N.Area) < 0) {
N.Destroy();
}
AstarPath.active.QueueGraphUpdates();
});
}));
Button.text = "DO IT";
VisualElement.Add(new IMGUIContainer(() => DrawDefaultInspector()));
return VisualElement;