Exemplo n.º 1
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 System.ArgumentNullException ("bytes");
				}
				active.VerifyIntegrity ();
			} catch (System.Exception e) {
				Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
				data_backup = bytes;
			}
			
		}
Exemplo n.º 2
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) {
					var sr = new 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");
				}
				active.VerifyIntegrity ();
			} catch (System.Exception e) {
				Debug.LogWarning ("Caught exception while deserializing data.\n"+e);
			}
			
		}
Exemplo n.º 3
0
        void DeserializeGraphs (byte[] bytes) {

            AstarPath.active.AddWorkItem (new AstarPath.AstarWorkItem (force => {
                                                                                    var sr = new AstarSerializer(script.astarData);
                                                                                    if (sr.OpenDeserialize(bytes)) {
                                                                                        script.astarData.DeserializeGraphsPart (sr);

                                                                                        // Make sure every graph has a graph editor
                                                                                        CheckGraphEditors ();
                                                                                        sr.DeserializeEditorSettings (graphEditors);

                                                                                        sr.CloseDeserialize();
                                                                                    } else {
                                                                                        Debug.LogWarning ("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");
                                                                                        // Make sure every graph has a graph editor
                                                                                        CheckGraphEditors ();
                                                                                    }
                                                                                    return true;
            }));

            // Make sure the above work item is run directly
            AstarPath.active.FlushWorkItems();
        }