diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index ebd121cd..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": { @@ -213,6 +213,12 @@ public class ActionHelper { return StrEventAction.Allocate(act.Name, act.Value); } + case "SkinnedBake": + { + var dictAction = (XMLTool.DictionaryAction)act; + return SkinnedBakeAction.Allocate(act.Value, dictAction.args); + } + default: Debug.LogError($"没有找到此Action的类型{act.Type}"); break; 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/Actions/SkinnedBakeAction.cs b/Assets/Scripts/Actions/SkinnedBakeAction.cs new file mode 100644 index 00000000..ce06c035 --- /dev/null +++ b/Assets/Scripts/Actions/SkinnedBakeAction.cs @@ -0,0 +1,81 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using QFramework; +using System; +using QFramework.Example; +using DG.Tweening; +using System.ComponentModel.Design; +public class SkinnedBakeAction : IAction +{ + public ulong ActionID { get; set; } + public bool Deinited { get; set; } + public bool Paused { get; set; } + public ActionStatus Status { get; set; } + + + private static readonly SimpleObjectPool mPool = + new SimpleObjectPool(() => new SkinnedBakeAction(), null, 10); + string path; + string deviceName; + public static SkinnedBakeAction 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; + retNode.deviceName = datas.ContainsKey("deviceName") ? datas["deviceName"] : string.Empty; + return retNode; + } + + + + public void Deinit() + { + if (!Deinited) + { + Deinited = true; + mPool.Recycle(this); + } + } + + public void OnExecute(float dt) + { + } + + public void OnFinish() + { + } + + public void OnStart() + { + GameObject obj = null; + if (string.IsNullOrEmpty(deviceName) == false) + { + obj = DeviceController.Instance.GetDeviceObj(deviceName); + } + else + { + obj = Utility.FindObj(path); + } + if (obj == null) + { + Debug.LogError("没有找到物体 :" + path); + } + else + { + Mesh mesh = new Mesh(); + obj.GetComponent().BakeMesh(mesh); + obj.GetComponent().sharedMesh = mesh; + } + this.Finish(); + + } + + public void Reset() + { + Status = ActionStatus.NotStart; + Paused = false; + } +} diff --git a/Assets/Scripts/Actions/SkinnedBakeAction.cs.meta b/Assets/Scripts/Actions/SkinnedBakeAction.cs.meta new file mode 100644 index 00000000..5d2f3f92 --- /dev/null +++ b/Assets/Scripts/Actions/SkinnedBakeAction.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 71a414df74a04624792f2a9e050ea506 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Xml/XmlParser.cs b/Assets/Scripts/Xml/XmlParser.cs index c7fb8bc0..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; } @@ -1009,6 +1010,17 @@ namespace XMLTool newAction = act; } break; + case "SkinnedBake": + { + var act = new DictionaryAction(); + XAttribute deviceName = action.Attribute("deviceName"); + if (deviceName != null) + { + act.args.Add("deviceName", deviceName.Value); + } + newAction = act; + } + break; default: newAction = new Action(); break; diff --git a/Doc/Xml閰嶇疆鏂囨。.xml b/Doc/Xml閰嶇疆鏂囨。.xml index 080cfa82..8844d63e 100644 --- a/Doc/Xml閰嶇疆鏂囨。.xml +++ b/Doc/Xml閰嶇疆鏂囨。.xml @@ -17,8 +17,8 @@ - - + + @@ -60,8 +60,10 @@ 瀹藉害涓嶈灏忎簬500 鍚﹀垯杩涘害鏉$湅涓嶅お娓呮--> - - + + @@ -120,7 +122,8 @@ --> - + +