private void SaveRuntimeChangableAudioSettings() { XmlDocument xmlDocument = new XmlDocument(); XmlNode rootNode = XmlParser.CreateRootTag(xmlDocument, AudioConstants.XML_ROOT); XmlNode audioNode = xmlDocument.CreateElement(AudioConstants.XML_RUNTIME_TAG); _runtimeAudioSettings.Save(xmlDocument, audioNode); rootNode.AppendChild(audioNode); if (!Directory.Exists(Path.GetDirectoryName(AudioConstants.GetCachePath()))) { Directory.CreateDirectory(Path.GetDirectoryName(AudioConstants.GetCachePath())); } xmlDocument.Save(AudioConstants.GetCachePath()); }
public static XmlDocument Load() { XmlDocument xmlDocument; string path = AudioConstants.GetResourcesPath(); CheckDirectory(Path.GetDirectoryName(path)); if (!File.Exists(path)) { xmlDocument = new XmlDocument(); XmlNode root = XmlParser.CreateRootTag(xmlDocument, "AudioData"); xmlDocument.Save(path); } xmlDocument = XmlParser.LoadFromFile(AudioConstants.GetResourcesPath()); return(xmlDocument); }
private void SaveConfiguration(bool saveAdditionalToResources = false) { XmlDocument xmlDocument = new XmlDocument(); XmlNode root = XmlParser.CreateRootTag(xmlDocument, AudioConstants.XML_ROOT); XmlNode defaultNode = xmlDocument.CreateElement(AudioConstants.XML_RUNTIME_TAG); _runtimeAudioSettings.Save(xmlDocument, defaultNode); root.AppendChild(defaultNode); defaultNode = xmlDocument.CreateElement("AudioConfiguration"); _generalAudioSettings.Save(xmlDocument, defaultNode); //XmlDataParser.AddAttributeToNode (xmlDocument, defaultNode, "SoundSourceCount", soundSourceCount.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "fade", fadeTime.ToString()); XmlDataParser.AddAttributeToNode(xmlDocument, defaultNode, "fadeOn", useFadeOn.ToString()); root.AppendChild(defaultNode); if (audioData != null) { foreach (var item in audioData) { XmlNode blockNode = xmlDocument.CreateElement("AudioBlock"); item.Value.SaveToXml(xmlDocument, blockNode); root.AppendChild(blockNode); } } else { return; } xmlDocument.Save(AudioConstants.GetResourcesPath()); AssetDatabase.Refresh(); }