Esempio n. 1
0
        /** Deserializes graphs from the specified byte array additively.
         * An error will be logged if deserialization fails.
         * This function will add loaded graphs to the current ones.
         */
        public void DeserializeGraphsAdditive(byte[] bytes)
        {
            var graphLock = AssertSafe();

            try {
                if (bytes != null)
                {
                    var sr = new AstarSerializer();

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPartAdditive(sr);
                        sr.CloseDeserialize();
                    }
                    else
                    {
                        Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
                    }
                }
                else
                {
                    throw new System.ArgumentNullException("bytes");
                }
                AstarPath.active.VerifyIntegrity();
            } catch (System.Exception e) {
                Debug.LogError("Caught exception while deserializing data.\n" + e);
                graphs = new NavGraph[0];
            }

            UpdateShortcuts();
            graphLock.Release();
        }
Esempio n. 2
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(astarSerializer);
             astarSerializer.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogError("Caught exception while deserializing data.\n" + arg);
         this.graphs      = new NavGraph[0];
         this.data_backup = bytes;
     }
     this.UpdateShortcuts();
     graphUpdateLock.Release();
 }
Esempio n. 3
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(astarSerializer);
             astarSerializer.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + arg);
     }
 }
Esempio n. 4
0
 public void DeserializeGraphs(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPart(astarSerializer);
             astarSerializer.CloseDeserialize();
             this.UpdateShortcuts();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + arg);
         this.data_backup = bytes;
     }
 }
Esempio n. 5
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
         }
         AstarSerializer sr = new AstarSerializer(this);
         if (sr.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(sr);
             sr.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).");
         }
         this.active.VerifyIntegrity();
     }
     catch (Exception exception)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + exception);
     }
 }
Esempio n. 6
0
        /** Deserializes graphs from the specified byte array.
         * If an error occured, it will try to deserialize using the old deserializer.
         * A warning will be logged if all deserializers failed.
         */
        public void DeserializeGraphs(byte[] bytes)
        {
            AstarPath.active.BlockUntilPathQueueBlocked();

            try {
                if (bytes != null)
                {
                    var sr = new AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPart(sr);
                        sr.CloseDeserialize();
                        UpdateShortcuts();
                    }
                    else
                    {
                        Debug.Log("Invalid data file (cannot read zip).\nThe data is either corrupt or it was saved using a 3.0.x or earlier version of the system");
                    }
                }
                else
                {
                    throw new ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
                }
                active.VerifyIntegrity();
            } catch (Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
                data_backup = bytes;
            }
        }