I’m interested in catching the completion of the graph generation. Is it possible to hook up to a “scan complete” event? I saw public override void ScanInternal (OnScanStatus statusCallback)
but the statusCallback
parameter doesn’t seem to be implemented yet.
You can try using the OnPostScan method like this:
AstarPath.OnPostScan += new OnScanDelegate((AstarPath script) => {
// Do stuff here
});
Thanks, but I just tried it but it doesn’t seem to be working? The delegate never gets called.
Where did you add that code? I’ve used this several times now and it works.
I assume you are invoking the Scan method or clicking the “Scan” button in the inspector.
You need to make sure the scan doesn’t occur before the delegate is added so that could mean disabling “Scan on Awake” in the Settings.
Then you have to manually scan using this:
AstarPath.active.Scan();
Ah, that must be why. I didn’t use AstarPath.active.Scan()
because I didn’t want to perform a scan on all GridGraph
objects in the scene. Instead, I call on newGridGraph.ScanInternal()
when I add the new GridGraph
so the other graphs don’t get touched.
Do you know of another solution which will work with ScanInternal()
?
Scanning is synchronous anyway, so this will hold
// Scanning is not done
AstarPath.active.Scan();
// Scanning is complete
All graphs need to be scanned at the same time at the moment. If you want to update only a single graph you can usually use graph updates instead, see http://arongranberg.com/astar/docs/graph-updates.php
Awesome. Thanks for clearing that up!