// Reads and Serializes a specific XML file private void LoadXmlFileData(string fileName) { string xmlPath = Path.Combine(xmlDirectory, fileName); if (Path.GetExtension(xmlPath) == string.Empty) { xmlPath += ".xml"; } else if (Path.GetExtension(xmlPath) != ".xml") { Path.ChangeExtension(xmlPath, ".xml"); } if (File.Exists(Path.Combine(Application.dataPath, xmlPath))) { currentSceneDialog = XML_Loader.Deserialize <SceneDialogs> ((Path.Combine(Application.dataPath, xmlPath))); if (currentSceneDialog.allDialogsInScene [0] != null) { SelectDialogByID(0); selectedDialogLine = null; /*if (selectedDialog.DialogLines.Count != 0) { * SelectDialogLine (0); * }*/ } } else { Debug.LogError("XML File: " + (Path.Combine(Application.dataPath, xmlPath)) + " is not found."); } }
public override void OnValueChanged(string branch, TutorialDialogType value) { activeDialog = null; foreach (var dialog in dialogs) { bool enable = value.Equals(dialog.type); dialog.dialog.SetActive(enable); if (enable) { activeDialog = dialog; } } }
// Loads the Dialogs out of an XML file from "Resources/XML_Files/SceneDialogs", and the passed file name. // This is called during OnNewLevelLoaded function in the GameManager public void LoadDialog(string fileName) { //Creates a path to an xml file, and only an xml file. string xmlPath = Path.Combine("Resources/XML_Files/SceneDialogs", fileName); if (Path.GetExtension(xmlPath) == string.Empty) { xmlPath += ".xml"; } else if (Path.GetExtension(xmlPath) != ".xml") { Path.ChangeExtension(xmlPath, ".xml"); } if (File.Exists(Path.Combine(Application.dataPath, xmlPath))) { sceneDialogs = XML_Loader.Deserialize <SceneDialogs> ((Path.Combine(Application.dataPath, xmlPath))); } else { Debug.LogError("XML File: " + (Path.Combine(Application.dataPath, xmlPath)) + " is not found."); } }