diff --git a/Assets/Scripts/Actions/ActionHelper.cs b/Assets/Scripts/Actions/ActionHelper.cs index ebd121cd..1e1f460a 100644 --- a/Assets/Scripts/Actions/ActionHelper.cs +++ b/Assets/Scripts/Actions/ActionHelper.cs @@ -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/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..3251b45a 100644 --- a/Assets/Scripts/Xml/XmlParser.cs +++ b/Assets/Scripts/Xml/XmlParser.cs @@ -1009,6 +1009,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;