I’m trying to implement an optimized export feature in unity for my game, and part of it is caching the graph. This is the code I use:
AstarPath.MenuScan();
AstarPath.active.astarData.SaveCacheData(Pathfinding.Serialize.SerializeSettings.All);
After this when I run the game I get the following error message when I’m trying to update the graph using AstarPath.active.UpdateGraphs(collider.bounds):
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.GridGraph.CalculateConnections (Pathfinding.Node[] nodes, Int32 x, Int32 z, Pathfinding.Nodes.GridNode node) (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:778)
Pathfinding.GridGraph.UpdateArea (Pathfinding.GraphUpdateObject o) (at Assets/AstarPathfindingProject/Generators/GridGenerator.cs:1139)
AstarPath.DoUpdateGraphs () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:934)
AstarPath.RegisterSafeUpdate (.OnVoidDelegate callback, Boolean threadSafe) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1685)
AstarPath.QueueGraphUpdates () (at Assets/AstarPathfindingProject/Core/AstarPath.cs:769)
AstarPath.UpdateGraphs (Pathfinding.GraphUpdateObject ob) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:876)
AstarPath.UpdateGraphs (Bounds bounds) (at Assets/AstarPathfindingProject/Core/AstarPath.cs:840)
UpdateGraphWhenDestroyed.OnDeath () (at Assets/NTD/Scripts/OnDeath/UpdateGraphWhenDestroyed.cs:11)
UnityEngine.Component:BroadcastMessage(String, SendMessageOptions)
SimpleHPHolder:HandleHit(Damager) (at Assets/NTD/Scripts/DestroyOnCondition/SimpleHPHolder.cs:15)
UnityEngine.Component:BroadcastMessage(String, Object, SendMessageOptions)
Hitable:GotHit(Damager) (at Assets/NTD/Scripts/Hitable.cs:176)
Orc:Update() (at Assets/NTD/Scripts/Orc.cs:20)
Furthermore when I stop the game I get this error:
Could not terminate pathfinding thread[0] in 50ms, trying Thread.Abort
UnityEngine.Debug:LogError(Object)
AstarPath:OnDestroy() (at Assets/AstarPathfindingProject/Core/AstarPath.cs:1241)
I’ve never seen these messages before switching to cached loading.
Thanks for the help.