Esempio n. 1
0
        /** Deserializes graphs from the specified byte array additively.
         * If an error ocurred, it will try to deserialize using the old deserializer.
         * A warning will be logged if all deserializers failed.
         * This function will add loaded graphs to the current ones
         */
        public void DeserializeGraphsAdditive(byte[] bytes)
        {
            AstarPath.active.BlockUntilPathQueueBlocked();

            try {
                if (bytes != null)
                {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPartAdditive(sr);
                        sr.CloseDeserialize();
                    }
                    else
                    {
                        Debug.Log("Invalid data file (cannot read zip).");
                    }
                }
                else
                {
                    throw new System.ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
                }
                active.VerifyIntegrity();
            } catch (System.Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
            }
        }
Esempio n. 2
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 Pathfinding.Serialization.AstarSerializer(this);

                    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");
                }
                active.VerifyIntegrity();
            }
            catch (System.Exception e)
            {
                Debug.LogError("Caught exception while deserializing data.\n" + e);
                graphs = new NavGraph[0];
            }

            UpdateShortcuts();
            graphLock.Release();
        }
Esempio n. 3
0
        /** Deserializes graphs from the specified byte array.
         * If an error ocurred, 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)
                {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPart(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 should not be null when passed to DeserializeGraphs");
                }
                active.VerifyIntegrity();
            } catch (System.Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
                data_backup = bytes;
            }

            UpdateShortcuts();
        }
Esempio n. 4
0
        /** Deserializes graphs from the specified byte array.
         * If an error ocurred, it will try to deserialize using the old deserializer.
         * A warning will be logged if all deserializers failed.
         */
        public void DeserializeGraphs(byte[] bytes)
        {
            try {
                if (bytes != null)
                {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPart(sr);
                        sr.CloseDeserialize();
                    }
                    else
                    {
                        Debug.Log("Invalid data file (cannot read zip). Trying to load with old deserializer (pre 3.1)...");
                        AstarSerializer serializer = new AstarSerializer(active);
                        DeserializeGraphs_oldInternal(serializer);
                    }
                }
                else
                {
                    throw new System.ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
                }
                active.DataUpdate();
            } catch (System.Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
                data_backup = bytes;
            }
        }
Esempio n. 5
0
		/** Deserializes graphs from the specified byte array additively.
		 * If an error ocurred, it will try to deserialize using the old deserializer.
		 * A warning will be logged if all deserializers failed.
		 * This function will add loaded graphs to the current ones
		  */
		public void DeserializeGraphsAdditive (byte[] bytes) {
			
			AstarPath.active.BlockUntilPathQueueBlocked();
			
			try {
				if (bytes != null) {
					Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);
					
					if (sr.OpenDeserialize(bytes)) {
						DeserializeGraphsPartAdditive (sr);
						sr.CloseDeserialize();
					} else {
						Debug.Log ("Invalid data file (cannot read zip).");
					}
				} else {
					throw new System.ArgumentNullException ("Bytes should not be null when passed to DeserializeGraphs");
				}
				active.VerifyIntegrity ();
			} catch (System.Exception e) {
				Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
			}
			
		}
Esempio n. 6
0
		/** Deserializes graphs from the specified byte array.
		 * If an error ocurred, 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) {
					Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);
					
					if (sr.OpenDeserialize(bytes)) {
						DeserializeGraphsPart (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 should not be null when passed to DeserializeGraphs");
				}
				active.VerifyIntegrity ();
			} catch (System.Exception e) {
				Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
				data_backup = bytes;
			}
			
		}
Esempio n. 7
0
        /** Deserializes graphs from the specified byte array.
         * If an error ocurred, it will try to deserialize using the old deserializer.
         * A warning will be logged if all deserializers failed.
          */
        public void DeserializeGraphs(byte[] bytes)
        {
            try {
                if (bytes != null) {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes)) {
                        DeserializeGraphsPart (sr);
                        sr.CloseDeserialize();
                    } else {
                        Debug.Log ("Invalid data file (cannot read zip). Trying to load with old deserializer (pre 3.1)...");
                        AstarSerializer serializer = new AstarSerializer (active);
                        DeserializeGraphs_oldInternal (serializer);
                    }
                } else {
                    throw new System.ArgumentNullException ("Bytes should not be null when passed to DeserializeGraphs");
                }
                active.DataUpdate ();
            } catch (System.Exception e) {
                Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
                data_backup = bytes;
            }
        }