I am trying to access a GridGraph in order to relocate it:
AstarPath.active.astarData.gridGraph // returns null
var g : AstarPath = grid.GetComponent("AstarPath") as AstarPath;
Debug.Log(g.astarData.gridGraph); // also returns null
I only have one graph in my scene, it’s gizmo shows up and I’m able to modify it with AstarPath.active.UpdateGraphs. Any idea why can’t I seem to retrieve the instance?
When are you calling this?
All graphs are scanned in Awake, and shortcuts are also set up in Awake.
So make sure you execute this code in Start or later.
I’m calling it within Start. I just tried it again and its working now, it must have been caused by something else.
Figured it out. This happens after generating a cache for the grid graph. If there is a cache, I can’t reference it. If there is no cache, it works as expected.
Confirmed bug. Thanks for spotting it.
I have fixed it in my dev version. To solve this, move the astarData.UpdateShortcuts () call from the ScanLoop method in AstarPath.cs to the Initialize method.