/** 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; }
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; }