Having trouble saving/loading serialized graphs (v4.1.14 beta)

So I read this: Saving and Loading Graphs

But still cannot seem to get it working in the latest Beta (did not try before this version… should I?).

  • If I uncheck Cache Startup, then check Scan on Awake, it works just fine.
  • If I uncheck Scan on Awake, then check Cache Startup and Save to File (and select the file), it does not work.

There’s no errors, the AI just traverse everything. Any idea what I might be doing wrong?


That’s odd. Your way of doing it should work, however more easily the only thing you should have to do is to click the ‘Generate Cache’ button (and make sure it you say ‘yes’ when it asks you to scan the graph if it is not already scanned). You do not have to uncheck ‘Scan On Awake’, the ‘cache startup’ option will override that and make sure the cached graph is loaded instead of scanning anything.

I know the latest beta has some issues with scanning recast graphs, but for other graph types it should be fine.

It seems to load the graph settings just fine, but not the actual node information. Also, I’m using a single grid graph.

I wrote this simple script:

private void Start() {
	Scene scene = AstarPath.active.gameObject.scene;
	string asset = scene.name.Replace("Scene", "Graph");
	TextAsset data = Resources.Load<TextAsset>("Graphs/" + asset);

So this does not work, nor does the Generate cache or Load from file options. It seems that only Scan on Awake works for whatever reason. I’m going to try and reproduce it in a fresh project and see what happens. And not sure if this matters, but I’m using Unity 2017.3.0f3.

Oh! And I do click Include node data and Scan when I click Saving to file.

EDIT: Save to file does not refresh the Asset database immediately when creating a new file…aka it won’t show in project window unless, right click -> refresh. Also, a fresh project appears to work just fine. I also tried re-importing the package and deleting the Library folder to no avail. Not sure what else to try/do. o.0 Any ideas?

Oh, so you mean loading from the cache works perfectly fine if you create a new project?
That is strange. Do you use the same Unity version and build target? (the serialization method differs slightly depending on the build target).

Yeah - no problems in a new project. I tried my project and a new project in both Unity 2017.3.0f3 and 2017.3.1f1, and got the same results for each. Build target is the same too: Windows 64 bit. I see you recently posted 4.1.15 - tried that and no luck here either. I’m going to step through the code and see if I can get more information. I’ll also see if I can get it to break in a fresh project. I’ll follow up with you later today or tomorrow.

Here’s the graph.txt (1.6 KB) which I believe is just the meta data. This looks normal, right?

JsonSerializer.DeserializeGraph just serializes the graph settings, correct? And it looks like JsonSerializer.DeserializeExtraInfo handles deserializing the actual nodes at the end:

// Deserialize map from old node indices to new nodes
var int2Node = DeserializeNodeReferenceMap();

// Deserialize node references
for (int i = 0; i < graphs.Length; i++) {
    DeserializeNodeReferences(graphs[i], int2Node);


In my attempts, it seems to be return before this occurs:

if (!anyDeserialized) {
    return; // Returns here when using my script or cache

I also noticed that when I choose GraphCache as the file to load it shows node information in the AstarPath inspector, but it doesn’t actually work. Just to clarify, Scan on awake does works everytime. Ok now it looks like the graph straight up disappears on play. I see no graph, only Add New Graph.

EDIT: I deleted my Astar prefab and re-set it up from scratch and seems to be working. No idea what the heck happened, but I’ll post if the issues return.

Weird… I have no idea what could have caused that. Oh well. If you encounter it again, please let me know.