示例#1
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(astarSerializer);
             astarSerializer.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + arg);
     }
 }
示例#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 AstarSerializer();

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

            UpdateShortcuts();
            graphLock.Release();
        }
示例#3
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     PathProcessor.GraphUpdateLock graphUpdateLock = this.AssertSafe(false);
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(astarSerializer);
             astarSerializer.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");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogError("Caught exception while deserializing data.\n" + arg);
         this.graphs      = new NavGraph[0];
         this.data_backup = bytes;
     }
     this.UpdateShortcuts();
     graphUpdateLock.Release();
 }
示例#4
0
 public void DeserializeGraphs(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("bytes");
         }
         AstarSerializer astarSerializer = new AstarSerializer(this);
         if (astarSerializer.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPart(astarSerializer);
             astarSerializer.CloseDeserialize();
             this.UpdateShortcuts();
         }
         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");
         }
         AstarData.active.VerifyIntegrity();
     }
     catch (Exception arg)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + arg);
         this.data_backup = bytes;
     }
 }
示例#5
0
 public void DeserializeGraphsAdditive(byte[] bytes)
 {
     AstarPath.active.BlockUntilPathQueueBlocked();
     try
     {
         if (bytes == null)
         {
             throw new ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
         }
         AstarSerializer sr = new AstarSerializer(this);
         if (sr.OpenDeserialize(bytes))
         {
             this.DeserializeGraphsPartAdditive(sr);
             sr.CloseDeserialize();
         }
         else
         {
             Debug.Log("Invalid data file (cannot read zip).");
         }
         this.active.VerifyIntegrity();
     }
     catch (Exception exception)
     {
         Debug.LogWarning("Caught exception while deserializing data.\n" + exception);
     }
 }
示例#6
0
        /** Deserializes graphs from the specified byte array.
         * If an error occured, 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)
                {
                    var sr = new AstarSerializer(this);

                    if (sr.OpenDeserialize(bytes))
                    {
                        DeserializeGraphsPart(sr);
                        sr.CloseDeserialize();
                        UpdateShortcuts();
                    }
                    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 ArgumentNullException("Bytes should not be null when passed to DeserializeGraphs");
                }
                active.VerifyIntegrity();
            } catch (Exception e) {
                Debug.LogWarning("Caught exception while deserializing data.\n" + e);
                data_backup = bytes;
            }
        }
示例#7
0
        /** Main deserializer function (old). Loads from \a bytes variable \deprecated */
        public void DeserializeGraphs_oldInternal(AstarSerializer serializer, byte[] bytes)
        {
            System.DateTime startTime = System.DateTime.UtcNow;

            if (bytes == null || bytes.Length == 0)
            {
                Debug.Log("No previous data, assigning default");
                graphs = new NavGraph[0];
                return;
            }

            Debug.Log("Deserializing...");

            serializer = serializer.OpenDeserialize(bytes);

            DeserializeGraphsPart(serializer);

            serializer.Close();

            System.DateTime endTime = System.DateTime.UtcNow;
            Debug.Log("Deserialization complete - Process took " + ((endTime - startTime).Ticks * 0.0001F).ToString("0.00") + " ms");
        }
示例#8
0
        /** Main deserializer function (old). Loads from \a bytes variable \deprecated */
        public void DeserializeGraphs_oldInternal(AstarSerializer serializer, byte[] bytes)
        {
            System.DateTime startTime = System.DateTime.UtcNow;

            if (bytes == null || bytes.Length == 0) {
                Debug.Log ("No previous data, assigning default");
                graphs = new NavGraph[0];
                return;
            }

            Debug.Log ("Deserializing...");

            serializer = serializer.OpenDeserialize (bytes);

            DeserializeGraphsPart (serializer);

            serializer.Close ();

            System.DateTime endTime = System.DateTime.UtcNow;
            Debug.Log ("Deserialization complete - Process took "+((endTime-startTime).Ticks*0.0001F).ToString ("0.00")+" ms");
        }
    public void DeserializeGraphs(AstarSerializer serializer, byte[] data)
    {
        serializer = serializer.OpenDeserialize (data);

        //Deserialize the main bulk of the data
        script.astarData.DeserializeGraphsPart (serializer);

        CheckGraphEditors ();

        //Deserialize editor data
        for (int i=0;i<script.graphs.Length;i++) {
            NavGraph graph = script.graphs[i];

            GraphEditor graphEditor = graphEditors[i];

            if (serializer.MoveToAnchor ("EditorSettings_"+i)) {
                ISerializableGraphEditor serializableEditor = graphEditor as ISerializableGraphEditor;
                if (serializableEditor != null) {
                    //Set an unique prefix for all variables in this graph
                    serializer.sPrefix = i.ToString ()+"E";
                    serializer.DeSerializeEditorSettings (graph,serializableEditor,script);
                    //serializableEditor.DeSerializeSettings (graph,serializer);
                }
            }
        }

        serializer.Close ();
    }