private void LoadRuntimeChangableAudioSettings() { XmlDocument xmlDocument; bool needSave = false; // Check if exists runtime/resources data file and load xmlDocument if (!File.Exists(AudioConstants.GetCachePath())) { if (!File.Exists(AudioConstants.GetResourcesPath())) { SaveRuntimeChangableAudioSettings(); xmlDocument = XmlParser.LoadFromFile(AudioConstants.GetCachePath()); Debug.LogError("Couldn't find configuration file in resources"); } else { xmlDocument = XmlParser.LoadFromResources(AudioConstants.GetReadableRuntimeResourcesPath()); needSave = true; } } else { xmlDocument = XmlParser.LoadFromFile(AudioConstants.GetCachePath()); } // Parsing audio data if (!XmlParser.IsExistRootTag(xmlDocument, AudioConstants.XML_ROOT)) { Debug.Log("Couldn't find root tag"); return; } XmlNode rootNode = XmlParser.GetRootTag(xmlDocument, AudioConstants.XML_ROOT); if (!XmlDataParser.IsAnyTagInChildExist(rootNode, AudioConstants.XML_RUNTIME_TAG)) { Debug.Log(string.Format("{0} tag not founded", AudioConstants.XML_RUNTIME_TAG)); return; } XmlNode audioNode = XmlDataParser.FindUniqueTagInChild(rootNode, AudioConstants.XML_RUNTIME_TAG); _runtimeAudioSettings.Load(audioNode); _runtimeAudioSettings.SoundVolume = _runtimeAudioSettings.SoundVolume; if (needSave) { SaveRuntimeChangableAudioSettings(); } }
private void InitConfiguration(XmlDocument xmlDocument) { if (audioData == null) { audioData = new Dictionary <string, AudioBlock> (); } else { audioData.Clear(); } XmlNode rootNode = XmlParser.GetRootTag(xmlDocument, AudioConstants.XML_ROOT); if (XmlDataParser.IsAnyTagInChildExist(rootNode, AudioConstants.XML_RUNTIME_TAG)) { XmlNode defaultNode = XmlDataParser.FindUniqueTagInChild(rootNode, AudioConstants.XML_RUNTIME_TAG); _runtimeAudioSettings.Load(defaultNode); } if (XmlDataParser.IsAnyTagInChildExist(rootNode, "AudioConfiguration")) { XmlNode configNode = XmlDataParser.FindUniqueTagInChild(rootNode, "AudioConfiguration"); _generalAudioSettings.Load(configNode); //soundSourceCount = int.Parse (configNode.Attributes ["SoundSourceCount"].Value); fadeTime = float.Parse(configNode.Attributes ["fade"].Value); useFadeOn = bool.Parse(configNode.Attributes ["fadeOn"].Value); } if (!XmlDataParser.IsAnyTagInChildExist(rootNode, "AudioBlock")) { return; } foreach (XmlNode item in XmlDataParser.FindAllTagsInChild(rootNode, "AudioBlock")) { string key = item.Attributes ["Name"].Value; if (!audioData.ContainsKey(key)) { audioData.Add(key, new AudioBlock()); audioData [key].LoadFromXml(item); } else { Debug.LogError("Some equals audio blocks name"); } } }