From ed940235afa448234cba8deb79178d84bb7d6e19 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Thu, 2 Jan 2025 14:19:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95show=E7=9A=84=E5=8F=82?= =?UTF-8?q?=E6=95=B0=20=E6=94=AF=E6=8C=81deviceName=20animAction=20?= =?UTF-8?q?=E6=94=AF=E6=8C=81deviceName?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/ActionHelper.cs | 4 +-- Assets/Scripts/Actions/AnimationAction.cs | 12 ++++++++- Assets/Scripts/Actions/ShowAction.cs | 31 +++++++++++++++-------- Assets/Scripts/Xml/XmlParser.cs | 21 +++++++-------- Doc/Xml配置文档.xml | 10 +++++--- 5 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index 1e1f460a..464d9f09 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -130,8 +130,8 @@ public class ActionHelper return SetVarAction.Allocate(act.Name, act.Value); case "Show": { - var strAction = (XMLTool.StringListAction)act; - return ShowAction.Allocate(act.Value, strAction.args[0], strAction.args[1]); + var strAction = (XMLTool.DictionaryAction)act; + return ShowAction.Allocate(act.Value, strAction.args); } case "TextTip": { diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index 103cffbd..16660014 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -25,6 +25,7 @@ namespace QFramework Animation anim; string frame; string speed; + string deviceName; public static AnimationAction Allocate(string path, Dictionary datas, System.Action OnFinished = null) { var retNode = mPool.Allocate(); @@ -35,6 +36,7 @@ namespace QFramework retNode.animName = datas.ContainsKey("animName") ? datas["animName"] : ""; retNode.frame = datas.ContainsKey("frame") ? datas["frame"] : ""; retNode.speed = datas.ContainsKey("speed") ? datas["speed"] : ""; + retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : ""; retNode.OnFinished = OnFinished; return retNode; } @@ -43,7 +45,15 @@ namespace QFramework public void OnStart() { - GameObject obj = Utility.FindObj(path); + GameObject obj = null; + if (string.IsNullOrEmpty(deviceName)) + { + obj = Utility.FindObj(path); + } + else + { + obj = DeviceController.Instance.GetDeviceObj(deviceName); + } if (obj != null) { try diff --git a/Assets/Scripts/Actions/ShowAction.cs b/Assets/Scripts/Actions/ShowAction.cs index 0f80c46e..d92ba11c 100644 --- a/Assets/Scripts/Actions/ShowAction.cs +++ b/Assets/Scripts/Actions/ShowAction.cs @@ -17,17 +17,19 @@ public class ShowAction : IAction private static readonly SimpleObjectPool mPool = new SimpleObjectPool(() => new ShowAction(), null, 10); string path; - bool isShow = true; - bool isDevice = false; - public static ShowAction Allocate(string path, string isShow, string isDevice, System.Action onDelayFinish = null) + string isShow = string.Empty; + string deviceName = string.Empty; + string isDevice = string.Empty; + public static ShowAction Allocate(string path, Dictionary datas, System.Action onDelayFinish = null) { var retNode = mPool.Allocate(); retNode.ActionID = ActionKit.ID_GENERATOR++; retNode.Deinited = false; retNode.Reset(); retNode.path = path; - bool.TryParse(isShow, out retNode.isShow); - bool.TryParse(isDevice, out retNode.isDevice); + retNode.isShow = datas.ContainsKey("isShow") ? datas["isShow"] : string.Empty; + retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty; + retNode.isDevice = datas.ContainsKey("isDevice") ? datas["isDevice"] : string.Empty; return retNode; } @@ -53,22 +55,31 @@ public class ShowAction : IAction public void OnStart() { GameObject obj = null; - if (isDevice) + if (string.IsNullOrEmpty(deviceName) == false) { - obj = DeviceController.Instance.GetDeviceObj(path); + obj = DeviceController.Instance.GetDeviceObj(deviceName); } else { - - obj = Utility.FindObj(path); + if (string.IsNullOrEmpty(isDevice) == false && isDevice == "true") + { + obj = DeviceController.Instance.GetDeviceObj(path); + } + else + { + obj = Utility.FindObj(path); + } } + if (obj == null) { Debug.LogError("ûҵ :" + path); } else { - obj.SetActive(isShow); + bool isActive = true; + bool.TryParse(isShow, out isActive); + obj.SetActive(isActive); } this.Finish(); diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index 3251b45a..d4f57513 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -374,7 +374,11 @@ namespace XMLTool { act.args.Add("speed", speed.Value); } - + var deviceName = action.Attribute("deviceName"); + if (deviceName != null) + { + act.args.Add("deviceName", deviceName.Value); + } newAction = act; } break; @@ -572,25 +576,22 @@ namespace XMLTool break; case "Show": { - var act = new StringListAction(); + var act = new DictionaryAction(); XAttribute isShow = action.Attribute("isShow"); if (isShow != null) { - act.args.Add(isShow.Value); - } - else - { - act.args.Add("true"); + act.args.Add("isShow",isShow.Value); } XAttribute isDevice = action.Attribute("isDevice"); if (isDevice != null) { - act.args.Add(isDevice.Value); + act.args.Add("isDevice", isDevice.Value); } - else + XAttribute deviceName = action.Attribute("deviceName"); + if (deviceName != null) { - act.args.Add("false"); + act.args.Add("deviceName", deviceName.Value); } newAction = act; } diff --git a/Doc/Xml配置文档.xml b/Doc/Xml配置文档.xml index 34ff2697..8844d63e 100644 --- a/Doc/Xml配置文档.xml +++ b/Doc/Xml配置文档.xml @@ -17,8 +17,8 @@ - - + + @@ -60,8 +60,10 @@ 宽度不要小于500 否则进度条看不太清楚--> - - + +