Custom Graph losing all nodes at runtime or when re-opening scene (pro version)

I’ve tried following the custom graph example in the docs, but it is losing all my generated nodes when entering play mode or re opening the scene.

I am using:
using Pathfinding.Serialization.JsonFx;
using Pathfinding.Serialization;

and my class looks like this
[JsonOptIn]
public class MOBDGraph : NavGraph

I’ve also tried generating a cache, saving to file, both of those load empty graphs- even in editor after loading from the cache of bytes file.

Any ideas? I’m in Unity 4.7 on A Star version 3.6.0.0

EDIT
Also the Polar graph example doesn’t seem to serialize either, same issue, node count zero at runtime or after reloading scene.

Hi

Graphs normally do not serialize nodes. Normally graphs are scanned when the game starts.
The PolarGraph tutorial does not include how to get caching working. For that to work you will have to override the SerializeExtraInfo and DeserializeExtraInfo methods. Take a look at for example the GridGraph or PointGraph to see how they have implemented those methods.

thanks for the quick reply! I just was noticing how the regular PointGraph works with load from cache, overriding those two methods worked great, very easy solution!

1 Like