private static void DisplayParseWindow() { if (ParseWindow == null) { ParseWindow = (ParseWindow)CreateInstance("ParseWindow"); } try { ParseWindow.setFilePath(currentXMLFilePath); ParseWindow.LoadFile(); ParseWindow.ParseFile(); ParseWindow.ShowWindow(); } catch (FileNotFoundException) { Debug.LogError("No XML file found at filepath " + currentXMLFilePath); } }
void OnDestroy() { //When the user tries to close the ParseWindow if (changes) { int popup = EditorUtility.DisplayDialogComplex("Save Changes?", "You have made unfinished changes to the XML file. Would you like to save your changes?", "Yes", "No", "Cancel"); if (popup == 0) //if the user selects "Yes" { SaveChanges(); } //if the user selects "No", proceed to close the window without any further action else if (popup == 2) //if the user selects "Cancel" { //Create an identical ParseWindow that will remain after this ParseWindow closes //allowing all changes to be preserved ParseWindow newWindow = (ParseWindow)ScriptableObject.CreateInstance("ParseWindow"); newWindow.setFilePath(xmlFilePath); newWindow.setCurrentDoc(doc); newWindow.setParseWindow(this); newWindow.ShowWindow(); } } }