public static void SaveDataToFiles() { if (MerinoData.CurrentFiles.Count > 0) { for (int i = 0; i < MerinoData.CurrentFiles.Count; i++) { TextAsset file = MerinoData.CurrentFiles[i]; if (MerinoData.FileToNodeID.ContainsKey(file)) { if (file == null) { var missingDataID = MerinoData.FileToNodeID[file]; MerinoData.DirtyFiles.Remove(file); // wait how does this work? it's null, but the pointer isn't? MerinoData.CurrentFiles.RemoveAt(i); i--; var missingFileName = MerinoData.GetNode(missingDataID) != null?MerinoData.GetNode(missingDataID).name : "<cannot recover filename>"; if (EditorUtility.DisplayDialog("Can't save file " + missingFileName, "The file has been deleted, moved outside of the project's assets folder, or otherwise hidden. Merino can't find it.", "Save backup of current data as new file", "Do nothing")) { MerinoEditorWindow.GetEditorWindow().CreateNewYarnFile("YarnBackupOfFile", SaveAllNodesAsString(missingDataID)); } continue; } else { File.WriteAllText(AssetDatabase.GetAssetPath(file), SaveFileNodesAsString(MerinoData.FileToNodeID[file])); EditorUtility.SetDirty(file); LastSaveTime = EditorApplication.timeSinceStartup; } } else { MerinoDebug.Log(LoggingLevel.Warning, file.name + " has not been mapped to a NodeID and cannot be saved, reload the file and try again."); } } EditorUtility.SetDirty(MerinoData.Instance); } }
void DeleteSelectedNodes() { MerinoEditorWindow.GetWindow().AddNodeToDelete(GetSelection()); }
void AddNewNode() { MerinoEditorWindow.GetWindow().AddNewNode(GetSelection()); }