diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index d5a6a328..813c31c2 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -172,8 +172,8 @@ public class ActionHelper } case "LoadRes": { - var strAction = (XMLTool.StringListAction)act; - return LoadResAction.Allocate(act.Value, strAction.args[0]); + var dictAction = (XMLTool.DictionaryAction)act; + return LoadResAction.Allocate(act.Value, dictAction.args); } case "Audio": { diff --git a/Assets/Scripts/Actions/LoadResAction.cs b/Assets/Scripts/Actions/LoadResAction.cs index ceaa950e..9e8321df 100644 --- a/Assets/Scripts/Actions/LoadResAction.cs +++ b/Assets/Scripts/Actions/LoadResAction.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Xml.Linq; using UnityEngine; using XMLTool; @@ -21,14 +22,16 @@ namespace QFramework string fileName; string type; - public static LoadResAction Allocate(string fileName, string type, System.Action OnFinished = null) + string index; + public static LoadResAction Allocate(string fileName, Dictionary datas, System.Action OnFinished = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.fileName = fileName; - retNode.type = type; + retNode.type = datas.ContainsKey("resType") ? datas["resType"] : string.Empty; + retNode.index = datas.ContainsKey("index") ? datas["index"] : string.Empty; retNode.OnFinished = OnFinished; return retNode; } @@ -55,7 +58,10 @@ namespace QFramework XDocument doc = XDocument.Parse(xmlStr); // 获取根元素 XElement moduleXml = doc.Root; - XmlParser.LoadModule(moduleXml, Global.Instance.appData); + Global.moduleDict.Add(index, moduleXml); + + // 直接加载会导致无序 + //XmlParser.LoadModule(moduleXml, Global.Instance.appData); } } }); diff --git a/Assets/Scripts/Global/Global.cs b/Assets/Scripts/Global/Global.cs index 339953fd..10063865 100644 --- a/Assets/Scripts/Global/Global.cs +++ b/Assets/Scripts/Global/Global.cs @@ -2,6 +2,7 @@ using QFramework; using System; using System.Collections; using System.Collections.Generic; +using System.Xml.Linq; using UnityEngine; using XMLTool; @@ -35,6 +36,6 @@ public class Global : Singleton public static AppType appTpe = AppType.UnKnow; - + public static Dictionary moduleDict = new Dictionary(); } diff --git a/Assets/Scripts/Launch.cs b/Assets/Scripts/Launch.cs index ed089f65..81b66925 100644 --- a/Assets/Scripts/Launch.cs +++ b/Assets/Scripts/Launch.cs @@ -43,6 +43,18 @@ public class Launch : MonoBehaviour { yield return ActionHelper.GetActionAndSub(Global.Instance.appData.preLoad.action).Start(this); } + // 暂时放在这里 + if (Global.moduleDict.Count > 0) + { + for (int i = 0; i < Global.moduleDict.Count; i++) + { + string index = (i + 1).ToString(); + if (Global.moduleDict.ContainsKey(index)) + { + XmlParser.LoadModule(Global.moduleDict[index], Global.Instance.appData); + } + } + } yield return UIKit.OpenPanelAsync(); UIKit.HidePanel(); diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index b3446f46..b894aabf 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -362,7 +362,7 @@ namespace XMLTool var animName = action.Attribute("animName"); if (animName != null) { - act.args.Add("animName",animName.Value); + act.args.Add("animName", animName.Value); } var frame = action.Attribute("frame"); if (frame != null) @@ -585,7 +585,7 @@ namespace XMLTool XAttribute isShow = action.Attribute("isShow"); if (isShow != null) { - act.args.Add("isShow",isShow.Value); + act.args.Add("isShow", isShow.Value); } XAttribute isDevice = action.Attribute("isDevice"); @@ -784,15 +784,16 @@ namespace XMLTool break; case "LoadRes": { - var act = new StringListAction(); + var act = new DictionaryAction(); XAttribute resType = action.Attribute("resType"); if (resType != null) { - act.args.Add(resType.Value); + act.args.Add("resType", resType.Value); } - else + XAttribute index = action.Attribute("index"); + if (index != null) { - act.args.Add(""); + act.args.Add("index", index.Value); } newAction = act; }