diff options
Diffstat (limited to 'Assets/Scripts/Unit')
-rw-r--r-- | Assets/Scripts/Unit/Events/EventEffect.cs | 13 | ||||
-rw-r--r-- | Assets/Scripts/Unit/TimelineEventProxy.cs | 48 |
2 files changed, 36 insertions, 25 deletions
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<FxClear>();
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)
{
|