Esempio n. 1
0
		/** Deserializes graph editor settings.
		 * For future compatibility this method does not assume that the \a graphEditors array matches the #graphs array in order and/or count.
		 * It searches for a matching graph (matching if graphEditor.target == graph) for every graph editor.
		 * Multiple graph editors should not refer to the same graph.\n
		 * \note Stored in files named "graph#_editor.json" where # is the graph number.
		 */
		public void DeserializeEditorSettings (GraphEditorBase[] graphEditors) {
#if !ASTAR_NO_JSON
			if (graphEditors == null) return;
			
			for (int i=0;i<graphEditors.Length;i++) {
				if (graphEditors[i] == null) continue;
				for (int j=0;j<graphs.Length;j++) {
					if (graphs[j] == null || graphEditors[i].target != graphs[j]) continue;
					
					ZipEntry entry = zip["graph"+j+"_editor"+jsonExt];
					if (entry == null) continue;
					
					string entryText = GetString (entry);
					
					var reader = new JsonReader(entryText,readerSettings);
					GraphEditorBase graphEditor = graphEditors[i];
					reader.PopulateObject (ref graphEditor);
					graphEditors[i] = graphEditor;
					break;
				}
			}
#endif
		}
Esempio n. 2
0
		public void SerializeEditorSettings (GraphEditorBase[] editors) {
			if (editors == null || !settings.editorSettings) return;

#if !ASTAR_NO_JSON
			for (int i=0;i<editors.Length;i++) {
				if (editors[i] == null) return;
				
				var output = GetStringBuilder ();
				var writer = new JsonWriter (output,writerSettings);
				writer.Write (editors[i]);
				
				var bytes = encoding.GetBytes (output.ToString());
				
				//Less or equal to 2 bytes means that nothing was saved (file is "{}")
				if (bytes.Length <= 2)
					continue;
				
				AddChecksum(bytes);
				zip.AddEntry ("graph"+i+"_editor"+jsonExt,bytes);
			}
#endif
		}