GridGraph Load Exception (using Pro)

I’m building a grid at runtime based on data files. I have my own query mechanism to my model, and it currently is working correctly.

    private void InitializeNodes( ) {
        GridGraph GRID =;
        for ( int X = 0; X < GRID.width; X++ ) {
            for ( int Y = 0; Y < GRID.depth; Y++ ) {
                GridNodeBase GNB = GRID.GetNode( X , Y );
                Vector3      POS = (Vector3)GNB.position;
                GNB.Walkable = _UnwalkableTypes.IndexOf( CityUtility.QueryMap( POS.x , POS.y )[0].TheObjectType ) == -1;
        GRID.GetNodes( NODE => GRID.CalculateConnections( NODE as GridNodeBase ) );

After it’s done this processing, I can save the graph (and it writes out graph.bytes). The problem comes in trying to load the data with something like:

Caught exception while deserializing data.
Pathfinding.Ionic.Zip.BadReadException: bad read of entry graph0_references.binary from compressed archive.
  at Pathfinding.Ionic.Zip.ZipEntry._CheckRead (System.Int32 nbytes) [0x0001b] in <99f15b4793f0442da95084e2e79a92c8>:0 
  at Pathfinding.Ionic.Zip.ZipEntry.ExtractOne (System.IO.Stream output) [0x00090] in <99f15b4793f0442da95084e2e79a92c8>:0 
  at Pathfinding.Ionic.Zip.ZipEntry.InternalExtract (System.String baseDir, System.IO.Stream outstream, System.String password) [0x002d3] in <99f15b4793f0442da95084e2e79a92c8>:0 
  at Pathfinding.Ionic.Zip.ZipEntry.Extract (System.IO.Stream stream) [0x00000] in <99f15b4793f0442da95084e2e79a92c8>:0 
  at Pathfinding.Serialization.AstarSerializer.GetBinaryReader (Pathfinding.Ionic.Zip.ZipEntry entry) [0x00007] in F:\VS 2013 Unity\v40Crystal\Solution-develop2\Crystal\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:763 
  at Pathfinding.Serialization.AstarSerializer.DeserializeNodeReferences (Pathfinding.NavGraph graph, Pathfinding.GraphNode[] int2Node) [0x00055] in F:\VS 2013 Unity\v40Crystal\Solution-develop2\Crystal\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:674 
  at Pathfinding.Serialization.AstarSerializer.DeserializeExtraInfo () [0x00060] in F:\VS 2013 Unity\v40Crystal\Solution-develop2\Crystal\Assets\AstarPathfindingProject\Core\Serialization\JsonSerializer.cs:710 
  at Pathfinding.AstarData.DeserializeGraphsPartAdditive (Pathfinding.Serialization.AstarSerializer sr) [0x0006d] in F:\VS 2013 Unity\v40Crystal\Solution-develop2\Crystal\Assets\AstarPathfindingProject\Core\AstarData.cs:402 
  at Pathfinding.AstarData.DeserializeGraphsAdditive (System.Byte[] bytes) [0x00030] in F:\VS 2013 Unity\v40Crystal\Solution-develop2\Crystal\Assets\AstarPathfindingProject\Core\AstarData.cs:369 
Pathfinding.AstarData:DeserializeGraphsAdditive(Byte[]) (at Assets/AstarPathfindingProject/Core/AstarData.cs:379)
Pathfinding.AstarData:DeserializeGraphs(Byte[]) (at Assets/AstarPathfindingProject/Core/AstarData.cs:352)
Pathfinding.AstarPathEditor:DeserializeGraphs(Byte[]) (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:1411)
Pathfinding.AstarPathEditor:DrawSerializationSettings() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:871)
Pathfinding.AstarPathEditor:DrawMainArea() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:393)
Pathfinding.AstarPathEditor:OnInspectorGUI() (at Assets/AstarPathfindingProject/Editor/AstarPathEditor.cs:272)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)

My best guess, is I need to do something before I save the grid? (Using Pro, Unity v2019.4.14 LTS)

The work-around for now is to not use the load/save mechanism, or figure out why I cannot use recast (even though I am generating mesh planes). Would be better if I could save/load.


Sorry for the late reply, I’ve been sick these last few weeks.

Hmm, this might be caused by an annoying bug in the zip library. Do you think you could try changing your grid dimensions slightly (+1 node or -1 node on some axis)?

Yup! That did it. Thanks so much.

P.S. no worries about being absent, I spent a month in the hospital and know how it goes.

1 Like