How can I access second Grid graph in same scene?

I made nine grid graph in same scene.

Because of making Huge Grid Graph, I devide a huge grid graph by nine small grid graph. I will update these graph one by one. So I access by script ‘gg=AstarPath.active.astarData.gridGraph;’. But I can`t access other one.

How can I access second Grid graph in same scene?

Thanks!

Hi

AstarPath.active.astarData.graphs //contains all graphs in the scene

See http://arongranberg.com/astar/docs/class_pathfinding_1_1_astar_data.php for more useful stuff.

1 Like

If you mean that you want to scan them one by one, consider slowly iterating the AstarPath.active.ScanLoop function.
`
StartCoroutine(ScanSlowly());

public IEnumerator ScanSlowly () {
IEnumerator st = AstarPath.active.ScanLoop ();
while (st.MoveNext ()) {
yield return null;
}
}
`

At first, I success to access nine small graph by below code.

foreach (GridGraph graph in AstarPath.active.astarData.FindGraphsOfType (typeof(GridGraph))) { // Do something } }

Then I can change position that graphs. Thanks!

Next, I want to scan small grid graphs one by one. So, And I tried your script.

StartCoroutine(ScanSlowly());

public IEnumerator ScanSlowly () {
IEnumerator st = AstarPath.active.ScanLoop ();
while (st.MoveNext ()) {
yield return null;
}
}

But Unity print error message.

error CS1501: No overload for method `ScanLoop' takes `0' arguments.

Other script in AstarPath.cs file occur same error.

foreach (Progress progress in AstarPath.active.ScanLoop ()) { Debug.Log ("Scanning... " + progress.description + " - " + (progress.progress*100).ToString ("0") + "%"); }

Hm…

Sorry, I forgot I changed that method a bit a few versions ago.
It is no longer possible to just loop through it unfortunately.

You can solve it though if you mod the AstarPath.cs script.
Change the
public void ScanLoop (OnScanStatus statusCallback) {
method to return IEnumerator, and put a
yield return null
after each iteration of the large loop inside it. Also you will need to change all
return;
statements to
yield break