public static void merge(DialogueEditorMasterObject newData)
		{
			if (data == null || newData == null) {
				Debug.LogWarning("Data is empty, not merging.");
				return;
			}

			// Start IDs at the end of previous IDs
			int id = __data.data.dialogues.Count;

			// Merge
			for (int newIndex = 0; newIndex < newData.dialogues.Count; newIndex++) {
				DialogueEditorDialogueObject newDlg = newData.dialogues[newIndex];
				bool match = false;
				
				for (int oldIndex = 0; oldIndex < __data.data.dialogues.Count; oldIndex++) {
					DialogueEditorDialogueObject oldDlg = __data.data.dialogues[oldIndex];

					// On name match, merge
					if (oldDlg.name == newDlg.name) {
						__data.data.dialogues[oldIndex] = newData.dialogues[newIndex];
						match = true;
					}
				}
				
				// No match, append it to the list
				if (!match) {
					newDlg.id = id++;
					__data.data.dialogues.Add(newDlg);
				}
			}
		}
		private static void load(){
			bool assetExists = System.IO.File.Exists(@DialogueEditorFileStatics.PATH + DialogueEditorFileStatics.DIALOGUE_DATA_FILENAME);
			if(assetExists){
				//Debug.Log ("Ouput Folder Exists: Loading Data");
				data = null;
				XmlSerializer deserializer = new XmlSerializer(typeof(DialogueEditorMasterObject));
				TextReader textReader = new StreamReader(@DialogueEditorFileStatics.PATH + DialogueEditorFileStatics.DIALOGUE_DATA_FILENAME);
				data = (DialogueEditorMasterObject)deserializer.Deserialize(textReader);
				textReader.Close();
			}else{
				//Debug.Log("Output Folder Does Not Exist: Creating New Folders");
				data = new DialogueEditorMasterObject();
				save();
				AssetDatabase.Refresh();
			}
		}
Beispiel #3
0
        public static void loadXml()
        {
            string path = EditorUtility.OpenFilePanel("Import Dialogue XML", "", "xml");

            if (path.Length < 1)
            {
                return;
            }

            XmlSerializer deserializer = new XmlSerializer(typeof(DialogueEditorMasterObject));
            TextReader    textReader   = new StreamReader(path);

            data = (DialogueEditorMasterObject)deserializer.Deserialize(textReader);
            textReader.Close();

            save();
        }
Beispiel #4
0
        private static void load()
        {
            bool assetExists = System.IO.File.Exists(@DialogueEditorFileStatics.PATH + DialogueEditorFileStatics.DIALOGUE_DATA_FILENAME);

            if (assetExists)
            {
                //Debug.Log ("Ouput Folder Exists: Loading Data");
                data = null;
                XmlSerializer deserializer = new XmlSerializer(typeof(DialogueEditorMasterObject));
                TextReader    textReader   = new StreamReader(@DialogueEditorFileStatics.PATH + DialogueEditorFileStatics.DIALOGUE_DATA_FILENAME);
                data = (DialogueEditorMasterObject)deserializer.Deserialize(textReader);
                textReader.Close();
            }
            else
            {
                //Debug.Log("Output Folder Does Not Exist: Creating New Folders");
                data = new DialogueEditorMasterObject();
                save();
                AssetDatabase.Refresh();
            }
        }
		public static void loadXml(){
			
			string path = EditorUtility.OpenFilePanel("Import Dialogue XML", "", "xml");
			if (path.Length < 1) return;

			XmlSerializer deserializer = new XmlSerializer(typeof(DialogueEditorMasterObject));
			TextReader textReader = new StreamReader(path);
			data = (DialogueEditorMasterObject)deserializer.Deserialize(textReader);
			textReader.Close();

			save();
		}