public bool OpenDeserialize(byte[] bytes)
 {
     this.zipStream = new MemoryStream();
     this.zipStream.Write(bytes, 0, bytes.Length);
     this.zipStream.Position = 0L;
     try
     {
         this.zip = ZipFile.Read(this.zipStream);
     }
     catch (Exception arg)
     {
         Debug.LogError("Caught exception when loading from zip\n" + arg);
         this.zipStream.Dispose();
         return(false);
     }
     if (this.ContainsEntry("meta.json"))
     {
         this.meta = this.DeserializeMeta(this.GetEntry("meta.json"));
     }
     else
     {
         if (!this.ContainsEntry("meta.binary"))
         {
             throw new Exception("No metadata found in serialized data.");
         }
         this.meta = this.DeserializeBinaryMeta(this.GetEntry("meta.binary"));
     }
     if (AstarSerializer.FullyDefinedVersion(this.meta.version) > AstarSerializer.FullyDefinedVersion(AstarPath.Version))
     {
         Debug.LogWarning(string.Concat(new object[]
         {
             "Trying to load data from a newer version of the A* Pathfinding Project\nCurrent version: ",
             AstarPath.Version,
             " Data version: ",
             this.meta.version,
             "\nThis is usually fine as the stored data is usually backwards and forwards compatible.\nHowever node data (not settings) can get corrupted between versions (even though I try my best to keep compatibility), so it is recommended to recalculate any caches (those for faster startup) and resave any files. Even if it seems to load fine, it might cause subtle bugs.\n"
         }));
     }
     else if (AstarSerializer.FullyDefinedVersion(this.meta.version) < AstarSerializer.FullyDefinedVersion(AstarPath.Version))
     {
         Debug.LogWarning(string.Concat(new object[]
         {
             "Upgrading serialized pathfinding data from version ",
             this.meta.version,
             " to ",
             AstarPath.Version,
             "\nThis is usually fine, it just means you have upgraded to a new version.\nHowever node data (not settings) can get corrupted between versions (even though I try my best to keep compatibility), so it is recommended to recalculate any caches (those for faster startup) and resave any files. Even if it seems to load fine, it might cause subtle bugs.\n"
         }));
     }
     return(true);
 }
Example #2
0
 public bool OpenDeserialize(byte[] bytes)
 {
     this.readerSettings = new JsonReaderSettings();
     this.readerSettings.AddTypeConverter(new VectorConverter());
     this.readerSettings.AddTypeConverter(new BoundsConverter());
     this.readerSettings.AddTypeConverter(new LayerMaskConverter());
     this.readerSettings.AddTypeConverter(new MatrixConverter());
     this.readerSettings.AddTypeConverter(new GuidConverter());
     this.readerSettings.AddTypeConverter(new UnityObjectConverter());
     this.str = new MemoryStream();
     this.str.Write(bytes, 0, bytes.Length);
     this.str.Position = 0L;
     try
     {
         this.zip = ZipFile.Read(this.str);
     }
     catch (Exception arg)
     {
         Debug.LogWarning("Caught exception when loading from zip\n" + arg);
         this.str.Dispose();
         return(false);
     }
     this.meta = this.DeserializeMeta(this.zip["meta.json"]);
     if (AstarSerializer.FullyDefinedVersion(this.meta.version) > AstarSerializer.FullyDefinedVersion(AstarPath.Version))
     {
         Debug.LogWarning(string.Concat(new object[]
         {
             "Trying to load data from a newer version of the A* Pathfinding Project\nCurrent version: ",
             AstarPath.Version,
             " Data version: ",
             this.meta.version,
             "\nThis is usually fine as the stored data is usually backwards and forwards compatible.\nHowever node data (not settings) can get corrupted between versions, so it is recommended to recalculate any caches (those for faster startup) and resave any files. Even if it seems to load fine, it might cause subtle bugs.\n"
         }));
     }
     else if (AstarSerializer.FullyDefinedVersion(this.meta.version) < AstarSerializer.FullyDefinedVersion(AstarPath.Version))
     {
         Debug.LogWarning(string.Concat(new object[]
         {
             "Trying to load data from an older version of the A* Pathfinding Project\nCurrent version: ",
             AstarPath.Version,
             " Data version: ",
             this.meta.version,
             "\nThis is usually fine, it just means you have upgraded to a new version.\nHowever node data (not settings) can get corrupted between versions, so it is recommended to recalculate any caches (those for faster startup) and resave any files. Even if it seems to load fine, it might cause subtle bugs.\n"
         }));
     }
     return(true);
 }