From 0449b9f500d01bc40f35d8a36d0bb1edf0fd1379 Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 13 Sep 2021 12:36:28 +0800 Subject: *misc --- Assets/Scripts/Unit/Events/EventEffect.cs | 13 +++++++-- Assets/Scripts/Unit/TimelineEventProxy.cs | 48 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 25 deletions(-) (limited to 'Assets/Scripts/Unit') diff --git a/Assets/Scripts/Unit/Events/EventEffect.cs b/Assets/Scripts/Unit/Events/EventEffect.cs index 9798ed6a..347b92f5 100644 --- a/Assets/Scripts/Unit/Events/EventEffect.cs +++ b/Assets/Scripts/Unit/Events/EventEffect.cs @@ -2,6 +2,12 @@ public class EventEffect : AnimationEventBase { + public enum EAttachNode + { + Unit, + Bone, + } + public override TimelineEventProxy.EEventType type { get { return TimelineEventProxy.EEventType.EventEffect; } } public override string shortName { get { return "E"; } } @@ -9,9 +15,12 @@ public class EventEffect : AnimationEventBase public string effectPath; [Tooltip("Is attached to a bone")] - public bool attached; + public bool attached = true; + + [If("attached")] + public EAttachNode attachNode = EAttachNode.Unit; - [If("attached"), Tooltip("Bone path attach to")] + [When("attachNode", EAttachNode.Bone), Tooltip("Bone path attach to")] public string bone; [Tooltip("Position offset")] diff --git a/Assets/Scripts/Unit/TimelineEventProxy.cs b/Assets/Scripts/Unit/TimelineEventProxy.cs index 6d4650fc..e750def2 100644 --- a/Assets/Scripts/Unit/TimelineEventProxy.cs +++ b/Assets/Scripts/Unit/TimelineEventProxy.cs @@ -81,6 +81,8 @@ public partial class TimelineEventProxy private Transform m_Root; + private Transform m_UnitModel; // 模型的Unit,默认是m_Root的第一个子节点 + public UnitController owner { get; private set; } private UnitAnimation m_UnitAnimation { get { return owner.unitAnimation; } } @@ -92,12 +94,14 @@ public partial class TimelineEventProxy this.owner = owner; m_Root = owner.transform; m_PrevAnimationData = null; + m_UnitModel = m_Root.GetChild(0); } public TimelineEventProxy(Transform root) { m_Root = root; m_PrevAnimationData = null; + m_UnitModel = m_Root.GetChild(0); } public static Type GetTypeByName(string name) @@ -177,32 +181,30 @@ public partial class TimelineEventProxy go.transform.SetParent(root.transform); FxClear onClear = root.AddComponent(); onClear.gameObject.name = prefab.name + "(Clone)"; - if(owner != null) - { - PlayEffectInfo info = new PlayEffectInfo(); - info.path = path; - info.playEffectType = EffectPlayTypes.Oneshot; - info.rootTr = m_Root; - info.posOffset = effect.position; - info.rot = effect.rotation; - info.scale = effect.scale; - info.bAttached = true; - onClear.Initialize(info); - } - else + PlayEffectInfo info = new PlayEffectInfo(); + info.path = path; + info.playEffectType = EffectPlayTypes.Oneshot; + info.posOffset = effect.position; + info.rot = effect.rotation; + info.scale = effect.scale; + info.bAttached = effect.attached; + if(effect.attached) { - PlayEffectInfo info = new PlayEffectInfo(); - info.path = path; - info.playEffectType = EffectPlayTypes.Oneshot; - info.rootTr = m_Root; - info.posOffset = effect.position; - info.rot = effect.rotation; - info.scale = effect.scale; - info.bAttached = true; - - onClear.Initialize(info); + if(effect.attachNode == global::EventEffect.EAttachNode.Unit) + { + info.rootTr = m_Root; + } + else if(effect.attachNode == global::EventEffect.EAttachNode.Bone) + { + if(m_UnitModel != null) + { + info.rootTr = m_UnitModel.Find(effect.bone); + } + } } + + onClear.Initialize(info); #if UNITY_EDITOR if (isInEditMode && registerParticleSystem != null) { -- cgit v1.1-26-g67d0