コード例 #1
0
 /** 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.Serialization.AstarSerializer sr)
 {
     sr.SerializeGraphs(graphs);
     sr.SerializeUserConnections(userConnections);
     sr.SerializeNodes();
     sr.SerializeExtraInfo();
 }
コード例 #2
0
ファイル: AstarData.cs プロジェクト: stjordanis/gridworld
        /** 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;
            }
        }
コード例 #3
0
ファイル: AstarData.cs プロジェクト: Cocanuta/Queues
        /** 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.Serialization.AstarSerializer sr)
        {
            ClearGraphs();
            graphs = sr.DeserializeGraphs();
            if (graphs != null)
            {
                for (int i = 0; i < graphs.Length; i++)
                {
                    if (graphs[i] != null)
                    {
                        graphs[i].graphIndex = (uint)i;
                    }
                }
            }

            userConnections = sr.DeserializeUserConnections();
            //sr.DeserializeNodes();
            sr.DeserializeExtraInfo();

            //Assign correct graph indices.
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                graphs[i].GetNodes(delegate(GraphNode node) {
                    node.GraphIndex = (uint)i;
                    return(true);
                });
            }

            sr.PostDeserialization();
        }
コード例 #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)
        {
            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();
        }
コード例 #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);
            }
        }
コード例 #6
0
		/** 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.Serialization.AstarSerializer sr) {
			if (graphs == null) graphs = new NavGraph[0];

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

			// Set an offset so that the deserializer will load
			// the graphs with the correct graph indexes
			sr.SetGraphIndexOffset(gr.Count);

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

			//Assign correct graph indices. Issue #21
			for (int i = 0; i < graphs.Length; i++) {
				if (graphs[i] == null) continue;
				graphs[i].GetNodes(node => {
					node.GraphIndex = (uint)i;
					return true;
				});
			}

			sr.DeserializeExtraInfo();
			sr.PostDeserialization();

			for (int i = 0; i < graphs.Length; i++) {
				for (int j = i+1; j < graphs.Length; j++) {
					if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid) {
						Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
						graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
						break;
					}
				}
			}
		}
コード例 #7
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();
        }
コード例 #8
0
ファイル: AstarData.cs プロジェクト: stjordanis/gridworld
 /** 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.Serialization.AstarSerializer sr)
 {
     graphs          = sr.DeserializeGraphs();
     userConnections = sr.DeserializeUserConnections();
     sr.DeserializeNodes();
     sr.DeserializeExtraInfo();
     sr.PostDeserialization();
 }
コード例 #9
0
        /** 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
         *
         * In most cases you should use the #DeserializeGraphs or #DeserializeGraphsAdditive method instead.
         */
        public void DeserializeGraphsPart(Pathfinding.Serialization.AstarSerializer sr)
        {
            var graphLock = AssertSafe();

            ClearGraphs();
            DeserializeGraphsPartAdditive(sr);
            graphLock.Release();
        }
コード例 #10
0
ファイル: AstarData.cs プロジェクト: stjordanis/gridworld
 /** 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.Serialization.SerializeSettings settings, out uint checksum)
 {
     Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this, settings);
     sr.OpenSerialize();
     SerializeGraphsPart(sr);
     byte[] bytes = sr.CloseSerialize();
     checksum = sr.GetChecksum();
     return(bytes);
 }
コード例 #11
0
ファイル: AstarData.cs プロジェクト: Galahad91/Evoquer
        /** Main serializer function.
         * Serializes all graphs to a byte array
         * A similar function exists in the AstarPathEditor.cs script to save additional info */
        public byte[] SerializeGraphs(Pathfinding.Serialization.SerializeSettings settings, out uint checksum)
        {
            var graphLock = active.PausePathfinding();
            var sr        = new Pathfinding.Serialization.AstarSerializer(this, settings);

            sr.OpenSerialize();
            SerializeGraphsPart(sr);
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
            graphLock.Release();
            return(bytes);
        }
コード例 #12
0
ファイル: AstarData.cs プロジェクト: isoundy000/moba-1
        /** 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.Serialization.SerializeSettings settings, out uint checksum)
        {
            Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this, settings);
            sr.OpenSerialize();
            SerializeGraphsPart(sr);
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
#if ASTARDEBUG
            Debug.Log("Got a whole bunch of data, " + bytes.Length + " bytes");
#endif
            return(bytes);
        }
コード例 #13
0
        /** Main serializer function.
         * Serializes all graphs to a byte array
         * A similar function exists in the AstarPathEditor.cs script to save additional info */
        public byte[] SerializeGraphs(Pathfinding.Serialization.SerializeSettings settings, out uint checksum)
        {
            AstarPath.active.BlockUntilPathQueueBlocked();

            var sr = new Pathfinding.Serialization.AstarSerializer(this, settings);

            sr.OpenSerialize();
            SerializeGraphsPart(sr);
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
            return(bytes);
        }
コード例 #14
0
        /** Main serializer function.
         * Serializes all graphs to a byte array
         * A similar function exists in the AstarPathEditor.cs script to save additional info */
        public byte[] SerializeGraphs(Pathfinding.Serialization.SerializeSettings settings, out uint checksum)
        {
            var graphLock = AssertSafe();
            var sr        = new Pathfinding.Serialization.AstarSerializer(this, settings);

            sr.OpenSerialize();
            sr.SerializeGraphs(graphs);
            sr.SerializeExtraInfo();
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
            graphLock.Release();
            return(bytes);
        }
コード例 #15
0
        /// <summary>Helper function for deserializing graphs</summary>
        void DeserializeGraphsPartAdditive(Pathfinding.Serialization.AstarSerializer sr)
        {
            if (graphs == null)
            {
                graphs = new NavGraph[0];
            }

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

            // Set an offset so that the deserializer will load
            // the graphs with the correct graph indexes
            sr.SetGraphIndexOffset(gr.Count);

            if (graphTypes == null)
            {
                FindGraphTypes();
            }
            gr.AddRange(sr.DeserializeGraphs(graphTypes));
            graphs = gr.ToArray();

            sr.DeserializeEditorSettingsCompatibility();
            sr.DeserializeExtraInfo();

            //Assign correct graph indices.
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                graphs[i].GetNodes(node => node.GraphIndex = (uint)i);
            }

            for (int i = 0; i < graphs.Length; i++)
            {
                for (int j = i + 1; j < graphs.Length; j++)
                {
                    if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid)
                    {
                        Debug.LogWarning(
                            "Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
                        break;
                    }
                }
            }

            sr.PostDeserialization();
            active.hierarchicalGraph.RecalculateIfNecessary();
        }
コード例 #16
0
        /** Main serializer function.
         * Serializes all graphs to a byte array
         * A similar function exists in the AstarPathEditor.cs script to save additional info */
        public byte[] SerializeGraphs(Pathfinding.Serialization.SerializeSettings settings, out uint checksum)
        {
            var graphLock = AssertSafe();
            var sr        = new Pathfinding.Serialization.AstarSerializer(this, settings);

            sr.OpenSerialize();
            sr.SerializeGraphs(graphs);
            sr.SerializeExtraInfo();
            byte[] bytes = sr.CloseSerialize();
            checksum = sr.GetChecksum();
#if ASTARDEBUG
            Debug.Log("Got a whole bunch of data, " + bytes.Length + " bytes");
#endif
            graphLock.Release();
            return(bytes);
        }
コード例 #17
0
		/** 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.Serialization.AstarSerializer sr) {
			ClearGraphs();
			graphs = sr.DeserializeGraphs();

			sr.DeserializeExtraInfo();

			//Assign correct graph indices.
			for (int i = 0; i < graphs.Length; i++) {
				if (graphs[i] == null) continue;
				graphs[i].GetNodes(node => {
					node.GraphIndex = (uint)i;
					return true;
				});
			}

			sr.PostDeserialization();
		}
コード例 #18
0
        /** 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.Serialization.AstarSerializer sr)
        {
            ClearGraphs();
            graphs = sr.DeserializeGraphs();
            if (graphs != null)
            {
                for (int i = 0; i < graphs.Length; i++)
                {
                    if (graphs[i] != null)
                    {
                        graphs[i].graphIndex = (uint)i;
                    }
                }
            }

            userConnections = sr.DeserializeUserConnections();
            //sr.DeserializeNodes();
            sr.DeserializeExtraInfo();
            sr.PostDeserialization();
        }
コード例 #19
0
ファイル: AstarData.cs プロジェクト: stjordanis/gridworld
        /** 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.Serialization.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();

            for (int i = 0; i < graphs.Length; i++)
            {
                for (int j = i + 1; j < graphs.Length; j++)
                {
                    if (graphs[i].guid == graphs[j].guid)
                    {
                        Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
                        break;
                    }
                }
            }
        }
コード例 #20
0
 /** 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
  *
  * In most cases you should use the DeserializeGraphs or DeserializeGraphsAdditive method instead.
  */
 public void DeserializeGraphsPart(Pathfinding.Serialization.AstarSerializer sr)
 {
     ClearGraphs();
     DeserializeGraphsPartAdditive(sr);
 }
コード例 #21
0
ファイル: AstarData.cs プロジェクト: TimEckhoff/GGJ13_Chill
        /** 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;
            }
        }
コード例 #22
0
        /** 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.Serialization.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();
            if (graphs != null)
            {
                for (int i = 0; i < graphs.Length; i++)
                {
                    if (graphs[i] != null)
                    {
                        graphs[i].graphIndex = (uint)i;
                    }
                }
            }

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

            conns.AddRange(sr.DeserializeUserConnections());
            userConnections = conns.ToArray();
            sr.DeserializeNodes();

            //Assign correct graph indices. Issue #21
            for (int i = 0; i < graphs.Length; i++)
            {
                if (graphs[i] == null)
                {
                    continue;
                }
                graphs[i].GetNodes(delegate(GraphNode node) {
                    //GraphNode[] nodes = graphs[i].nodes;
                    node.GraphIndex = (uint)i;
                    return(true);
                });
            }

            sr.DeserializeExtraInfo();
            sr.PostDeserialization();

            for (int i = 0; i < graphs.Length; i++)
            {
                for (int j = i + 1; j < graphs.Length; j++)
                {
                    if (graphs[i] != null && graphs[j] != null && graphs[i].guid == graphs[j].guid)
                    {
                        Debug.LogWarning("Guid Conflict when importing graphs additively. Imported graph will get a new Guid.\nThis message is (relatively) harmless.");
                        graphs[i].guid = Pathfinding.Util.Guid.NewGuid();
                        break;
                    }
                }
            }
        }
コード例 #23
0
		/** Main serializer function.
		 * Serializes all graphs to a byte array
		  * A similar function exists in the AstarPathEditor.cs script to save additional info */
		public byte[] SerializeGraphs (Pathfinding.Serialization.SerializeSettings settings, out uint checksum) {
			
			AstarPath.active.BlockUntilPathQueueBlocked();
			
			var sr = new Pathfinding.Serialization.AstarSerializer(this, settings);
			sr.OpenSerialize();
			SerializeGraphsPart (sr);
			byte[] bytes = sr.CloseSerialize();
			checksum = sr.GetChecksum ();
			return bytes;
		}
コード例 #24
0
        public void exportMethod()
        {
#if UNITY_EDITOR
            var astar = AstarPath.active;
            if (astar == null)
            {
                astar = GameObject.FindObjectOfType <AstarPath>();
            }
            string path = EditorUtility.SaveFilePanel("Save Graphs", "", "graph" + Convert.ToString(mapId) + ".zip", "zip");
            if (path != "")
            {
                if (EditorUtility.DisplayDialog("Scan before saving?", "Do you want to scan the graphs before saving" +
                                                "\nNot scanning can cause node data to be omitted from the file if Save Node Data is enabled", "Scan", "Don't scan"))
                {
                    astar.Scan();
                }


                //uint checksum;
                Pathfinding.Serialization.SerializeSettings settings = Pathfinding.Serialization.SerializeSettings.All;


                byte[] bytes = null;
                //uint ch = 0;
                astar.AddWorkItem(new AstarPath.AstarWorkItem(delegate(bool force) {
                    Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(astar.astarData, settings);
                    sr.OpenSerialize();
                    astar.astarData.SerializeGraphsPart(sr);
                    //sr.SerializeEditorSettings (graphEditors);
                    var start = GameObject.Find("PlayerStart").transform.position;
                    var grid  = Util.CoordToGrid(start.x, start.z);
                    var yOff  = Util.IntYOffset(start.y);

                    SimpleJSON.JSONClass jc = new SimpleJSON.JSONClass();
                    var arr = jc["playerStart"] = new SimpleJSON.JSONArray();

                    arr[-1].AsInt = (int)(grid.x);
                    arr[-1].AsInt = yOff;
                    arr[-1].AsInt = (int)(grid.y);

                    /*
                     * System.IO.MemoryStream stream = new System.IO.MemoryStream();
                     * BinaryWriter outfile = new BinaryWriter(stream);
                     * jc.Serialize(outfile);
                     */
                    Debug.Log("Export " + jc.ToString());
                    var graph = astar.graphs[0] as Pathfinding.GridGraph;
                    var js    = new SimpleJSON.JSONClass();
                    js["unclampedSize"]["x"].AsInt = graph.width;
                    js["unclampedSize"]["y"].AsInt = graph.depth;
                    js["center"]["x"].AsFloat      = graph.center.x;
                    js["center"]["y"].AsFloat      = graph.center.y;
                    js["center"]["z"].AsFloat      = graph.center.z;
                    sr.zip.AddEntry("playerStart" + Convert.ToString(mapId) + ".json", System.Text.Encoding.UTF8.GetBytes(jc.ToString()));
                    sr.zip.AddEntry("graph0.json", System.Text.Encoding.UTF8.GetBytes(js.ToString()));
                    bytes = sr.CloseSerialize();
                    //ch = sr.GetChecksum ();
                    return(true);
                }));

                Pathfinding.Serialization.AstarSerializer.SaveToFile(path, bytes);
                EditorUtility.DisplayDialog("Done Saving", "Done saving graph data.", "Ok");
            }
#endif
        }
コード例 #25
0
ファイル: AstarData.cs プロジェクト: henryj41043/TheUnseen
		/** 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);
			}
			
		}
コード例 #26
0
ファイル: AstarData.cs プロジェクト: henryj41043/TheUnseen
		/** 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;
			}
			
		}
コード例 #27
0
ファイル: AstarData.cs プロジェクト: henryj41043/TheUnseen
		/** 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.Serialization.SerializeSettings settings, out uint checksum) {
			
			AstarPath.active.BlockUntilPathQueueBlocked();
			
			Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this, settings);
			sr.OpenSerialize();
			SerializeGraphsPart (sr);
			byte[] bytes = sr.CloseSerialize();
			checksum = sr.GetChecksum ();
	#if ASTARDEBUG
			Debug.Log ("Got a whole bunch of data, "+bytes.Length+" bytes");
	#endif
			return bytes;
		}
コード例 #28
0
ファイル: AstarData.cs プロジェクト: TimEckhoff/GGJ13_Chill
 /** 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.Serialization.SerializeSettings settings, out uint checksum)
 {
     Pathfinding.Serialization.AstarSerializer sr = new Pathfinding.Serialization.AstarSerializer(this, settings);
     sr.OpenSerialize();
     SerializeGraphsPart (sr);
     byte[] bytes = sr.CloseSerialize();
     checksum = sr.GetChecksum ();
     return bytes;
 }
コード例 #29
0
 /** 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.Serialization.AstarSerializer sr)
 {
     sr.SerializeGraphs(graphs);
     sr.SerializeExtraInfo();
 }