Exemple #1
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 (SerializeSettings settings, out uint checksum) {
			
			AstarPath.active.BlockUntilPathQueueBlocked();
			
			var sr = new 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;
		}
Exemple #2
0
		/** Serializes all graphs settings and optionally node data to a byte array.
		 * \see DeserializeGraphs(byte[])
		 * \see Pathfinding.Serialization.SerializeSettings
		 */
		public byte[] SerializeGraphs (SerializeSettings settings) {
			uint checksum;
			return SerializeGraphs (settings, out checksum);
		}
		public AstarSerializer (AstarData data, SerializeSettings settings) {
			this.data = data;
			this.settings = settings;
		}
        public byte[] SerializeGraphs (SerializeSettings settings, out uint checksum) {
            byte[] bytes = null;
            uint ch = 0;

            // Add a work item since we cannot be sure that pathfinding (or graph updates)
            // is not running at the same time
            AstarPath.active.AddWorkItem (new AstarPath.AstarWorkItem (force => {
                                                                                    var sr = new AstarSerializer(script.astarData, settings);
                                                                                    sr.OpenSerialize();
                                                                                    script.astarData.SerializeGraphsPart (sr);
                                                                                    sr.SerializeEditorSettings (graphEditors);
                                                                                    bytes = sr.CloseSerialize();
                                                                                    ch = sr.GetChecksum ();
#if ASTARDEBUG
			Debug.Log ("Got a whole bunch of data, "+bytes.Length+" bytes");
	#endif
                                                                                    return true;
            }));

            // Make sure the above work item is executed immediately
            AstarPath.active.FlushWorkItems();
            checksum = ch;
            return bytes;
        }
		public AstarSerializer (AstarData data) {
			this.data = data;
			settings = SerializeSettings.Settings;
		}