/** 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)
        {
            try {
                if (bytes != null)
                {
                    Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.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.DataUpdate();
            } catch (System.Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
            }
        }
        /** 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.Serialize.AstarSerializer sr = new Pathfinding.Serialize.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;
            }
        }
 /** Serializes common info to the serializer.
  * Common info is what is shared between the editor serialization and the runtime serializer.
  * This is mostly everything except the graph inspectors which serialize some extra data in the editor
  */
 public void SerializeGraphsPart(Pathfinding.Serialize.AstarSerializer sr)
 {
     sr.SerializeGraphs(graphs);
     sr.SerializeUserConnections(userConnections);
     sr.SerializeNodes();
     sr.SerializeExtraInfo();
 }
 /** Deserializes common info.
  * Common info is what is shared between the editor serialization and the runtime serializer.
  * This is mostly everything except the graph inspectors which serialize some extra data in the editor
  */
 public void DeserializeGraphsPart(Pathfinding.Serialize.AstarSerializer sr)
 {
     graphs          = sr.DeserializeGraphs();
     userConnections = sr.DeserializeUserConnections();
     sr.DeserializeNodes();
     sr.DeserializeExtraInfo();
     sr.PostDeserialization();
 }
 /** Main serializer function.
  * Serializes all graphs to a byte array
  * A similar function exists in the AstarEditor.cs script to save additional info */
 public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
 {
     Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(this, settings);
     sr.OpenSerialize();
     SerializeGraphsPart(sr);
     byte[] bytes = sr.CloseSerialize();
     checksum = sr.GetChecksum();
     return(bytes);
 }
Exemple #6
0
        /** Main serializer function.
         * Serializes all graphs to a byte array
         * A similar function exists in the AstarEditor.cs script to save additional info */
        public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
        {
            Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(this, settings);
            sr.OpenSerialize();
            SerializeGraphsPart(sr);
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
#if DEBUG
            Debug.Log("Got a whole bunch of data, " + bytes.Length + " bytes");
#endif
            return(bytes);
        }
        /** Deserializes common info additively
         * Common info is what is shared between the editor serialization and the runtime serializer.
         * This is mostly everything except the graph inspectors which serialize some extra data in the editor
         */
        public void DeserializeGraphsPartAdditive(Pathfinding.Serialize.AstarSerializer sr)
        {
            if (graphs == null)
            {
                graphs = new NavGraph[0];
            }
            if (userConnections == null)
            {
                userConnections = new UserConnection[0];
            }

            List <NavGraph> gr = new List <NavGraph>(graphs);

            gr.AddRange(sr.DeserializeGraphs());
            graphs = gr.ToArray();

            List <UserConnection> conns = new List <UserConnection>(userConnections);

            conns.AddRange(sr.DeserializeUserConnections());
            userConnections = conns.ToArray();
            sr.DeserializeNodes();
            sr.DeserializeExtraInfo();
            sr.PostDeserialization();
        }
Exemple #8
0
 /** Main serializer function.
  * Serializes all graphs to a byte array
   * A similar function exists in the AstarEditor.cs script to save additional info */
 public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
 {
     Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(this, settings);
     sr.OpenSerialize();
     SerializeGraphsPart (sr);
     byte[] bytes = sr.CloseSerialize();
     checksum = sr.GetChecksum ();
     return bytes;
 }
Exemple #9
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)
        {
            try {
                if (bytes != null) {
                    Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.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.DataUpdate ();
            } catch (System.Exception e) {
                Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
            }
        }
Exemple #10
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.Serialize.AstarSerializer sr = new Pathfinding.Serialize.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;
            }
        }
Exemple #11
0
 /** Main serializer function.
  * Serializes all graphs to a byte array
   * A similar function exists in the AstarEditor.cs script to save additional info */
 public byte[] SerializeGraphs(Pathfinding.Serialize.SerializeSettings settings, out uint checksum)
 {
     Pathfinding.Serialize.AstarSerializer sr = new Pathfinding.Serialize.AstarSerializer(this, settings);
     sr.OpenSerialize();
     SerializeGraphsPart (sr);
     byte[] bytes = sr.CloseSerialize();
     checksum = sr.GetChecksum ();
     #if DEBUG
     Debug.Log ("Got a whole bunch of data, "+bytes.Length+" bytes");
     #endif
     return bytes;
 }