示例#1
0
        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());
        }
        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();
        }