Re-Scan after activating Astar Path

Instead of loading/unloading Scenes in my Game I just activate/deactivate.
I know that Scanning happens in Awake so I need to manually Scan a Scene whenever it activates.
I tried using AstarPath.active.Scan(); but that returns error: NullReferenceException: Object reference not set to an instance of an object.

I can see in my editor that it is active, so not sure what is wrong.

Realized it’s a singleton and added
AstarPath.active = FindObjectOfType<AstarPath>(); AstarPath.active.Scan();
Then it works. Not pretty but I guess that is my only way around it.

Hi

Hm… It should set the ‘active’ static field when AstarPath.Awake runs. Are you sure you call AstarPath.active.Scan() after you have made the GameObject active?

Also. Maybe you want to have a look at loading graphs from files. Take a look at https://www.arongranberg.com/astar/docs/save-load-graphs.php