No graphs when exiting play mode

Hi, when I don’t have the A* component selected in the hierarchy and then exit play mode, AstarPath.active.graphs.Length is always 0.

It works correctly when I remove [ExecuteInEditMode] from the accessing script (in Start() method) or keep the A* component selected before exiting play mode.

I tried to set script execution order so that A* script always loads first, but that doesn’t seem to fix it.

What to do?

Hi

When outside of play mode, the graphs are not necessarily deserialized yet.
You can deserialize the graphs by calling

myAstarPathObject.astarData.DeserializeGraphs();

Also note that any changes made to the graph settings outside play mode will have to be serialized in order to be stored. You can do this using

myAstarPathObject.astarData.SetData(myAstarPathObject.astarData.SerializeGraphs(), 0);

Thanks, that fixed it.:slight_smile:

1 Like