public void DeserializeEditorSettings(GraphEditorBase[] graphEditors) { if (graphEditors == null) { return; } for (int i = 0; i < graphEditors.Length; i++) { if (graphEditors[i] != null) { for (int j = 0; j < this.graphs.Length; j++) { if (this.graphs[j] != null && graphEditors[i].target == this.graphs[j]) { ZipEntry zipEntry = this.zip["graph" + j + "_editor.json"]; if (zipEntry != null) { string @string = this.GetString(zipEntry); JsonReader jsonReader = new JsonReader(@string, this.readerSettings); GraphEditorBase graphEditorBase = graphEditors[i]; jsonReader.PopulateObject <GraphEditorBase>(ref graphEditorBase); graphEditors[i] = graphEditorBase; break; } } } } } }
/** 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 (graphEditors[i].target != graphs[j]) { continue; } var zipIndex = graphIndexInZip[graphs[j]]; ZipEntry entry = zip["graph" + zipIndex + "_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 }
/** 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 (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); JsonReader reader = new JsonReader(entryText, readerSettings); GraphEditorBase graphEditor = graphEditors[i]; reader.PopulateObject(ref graphEditor); graphEditors[i] = graphEditor; break; } } }
//#if UNITY_EDITOR /** 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 (var i=0;i<graphEditors.Length;i++) { if (graphEditors[i] == null) continue; for (var j=0;j<graphs.Length;j++) { if (graphs[j] == null || graphEditors[i].target != graphs[j]) continue; var entry = zip["graph"+j+"_editor"+jsonExt]; if (entry == null) continue; var entryText = GetString (entry); var reader = new JsonReader(entryText,readerSettings); var graphEditor = graphEditors[i]; reader.PopulateObject (ref graphEditor); graphEditors[i] = graphEditor; break; } } #endif }
//#if UNITY_EDITOR public void SerializeEditorSettings (GraphEditorBase[] editors) { if (editors == null || !settings.editorSettings) return; #if !ASTAR_NO_JSON for (var i=0;i<editors.Length;i++) { if (editors[i] == null) return; var output = GetStringBuilder ();//new System.Text.StringBuilder(); 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 }