private static void ZaladujZasoby(string zasobXML)
        {
            //            XDocument dokument = Funkcje.ZaladujZasobXMLJakoDoc(zasobXML, null);
            //          XElement zawartosc = dokument.Element("ciagi");
            //        IEnumerable<XElement> nodeList = zawartosc.Descendants("ciag");
            XmlDataInfo info = Utils.LoadXmlAssetFile(zasobXML, "resources");

            foreach (XElement node in info.MainNodeElements)
            {
                string nazwa = node.Attribute("name").Value;
                string tekst = node.Value;
                tekst = tekst.Replace("\n", " ");
                tekst = tekst.Replace("\\n", "\n");
                if (nazwa == null)
                {
                    Debug.LogError("ciąg ma wartość null: " + tekst + " w " + zasobXML);
                }
                if (_dane.ContainsKey(nazwa))
                {
                    _dane[nazwa] = tekst;
                }
                else
                {
                    _dane.Add(nazwa, tekst);
                }
            }
        }
示例#2
0
        //util xml loading func, from Resources or loaded asset bundles
        public static XmlDataInfo LoadXmlAssetFile(string assetName, string mainNode)
        {
            TextAsset txt = LoadObjectFromAssets(typeof(TextAsset), assetName) as TextAsset;

            if (txt == null)
            {
                Debug.LogError("Cant load : " + assetName);
                return(null);
            }
            else
            {
                StringBuilder content = new StringBuilder();
                StringReader  reader  = new StringReader(txt.text);
                content.Append(reader.ReadToEnd());
                reader.Close();
                string      cnt  = content.ToString();
                XDocument   doc  = XDocument.Parse(cnt);
                XmlDataInfo info = new XmlDataInfo(doc, mainNode);
                return(info);
            }
        }
示例#3
0
        private void LoadFromResources()
        {
            XmlDataInfo entInfo = Utils.LoadXmlAssetFile("data/config", "config");

            foreach (XElement element in entInfo.MainNodeElements)
            {
                if (element.Name.ToString() == "setting")
                {
                    this[element.Attribute("name").Value] = element.Value;
                }
                if (element.Name.ToString() == "assetBundle")
                {
                    ABInfo abInfo = new ABInfo()
                    {
                        Name = element.Attribute("name").Value, IsInitializingAB = element.Attribute("initializing") != null, ObjectsToLoad = new List <string>()
                    };
                    foreach (XElement subElement in element.Elements())
                    {
                        if (subElement.Name.ToString() == "load")
                        {
                            abInfo.ObjectsToLoad.Add(subElement.Value);
                        }
                    }
                    if (abInfo.IsInitializingAB)
                    {
                        InitializingAssetBundle = abInfo;
                    }
                    else
                    {
                        _assetBundles.Add(abInfo.Name, abInfo);
                    }
                }
                if (element.Name.ToString() == "module")
                {
                    ModulesToLoad.Add(element.Value);
                }
            }
        }