diff options
author | chai <chaifix@163.com> | 2021-08-27 18:53:44 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2021-08-27 18:53:44 +0800 |
commit | e2284510c40e2d637c28108b50df2e403d51ec1c (patch) | |
tree | c85bdd331359d9ce8d9e29a9d7b876ca90429951 /Assets/Scripts/Unit/Component/UnitAnimation.cs | |
parent | 9f447daa59fe9393904206499e6872068a11e7f8 (diff) |
*crossfade
Diffstat (limited to 'Assets/Scripts/Unit/Component/UnitAnimation.cs')
-rw-r--r-- | Assets/Scripts/Unit/Component/UnitAnimation.cs | 50 |
1 files changed, 43 insertions, 7 deletions
diff --git a/Assets/Scripts/Unit/Component/UnitAnimation.cs b/Assets/Scripts/Unit/Component/UnitAnimation.cs index 5649206e..a6a7f3eb 100644 --- a/Assets/Scripts/Unit/Component/UnitAnimation.cs +++ b/Assets/Scripts/Unit/Component/UnitAnimation.cs @@ -1,4 +1,5 @@ -using System;
+#define ANIM_CROSS_FADE
+using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -102,7 +103,7 @@ public class AnimatorLayerInfo {
get
{
- return stateInfo.normalizedTime * clipInfo[0].clip.length;
+ return playbackNomralizedTime * clipInfo[0].clip.length;
}
}
@@ -343,15 +344,23 @@ public class UnitAnimation : UnitComponent public void AnimIdle()
{
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("Idle", 0.2f, 0);
+#else
ResetAllTriggers();
- m_Animator.SetTrigger(ETrigger.ToIdle.ToString());
- }
+ m_Animator.SetTrigger(ETrigger.ToIdle.ToString());
+#endif
+ }
public void AnimMove()
{
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("Move", 0.01f, 0);
+#else
ResetAllTriggers();
m_Animator.SetTrigger(ETrigger.ToMove.ToString());
- }
+#endif
+ }
public void AnimAttack()
{
@@ -367,20 +376,42 @@ public class UnitAnimation : UnitComponent public void AnimJump()
{
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("Jump", 0.01f);
+#else
ResetAllTriggers();
SetTrigger(ETrigger.ToJump);
- }
+#endif
+ }
- public void AnimAirAttack()
+ public void AnimAirAttack(int id)
{
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("AirAttack" + id, 0.05f);
+#else
ResetAllTriggers();
SetTrigger(ETrigger.ToAirAttack);
+#endif
}
public void AnimLanding()
{
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("Landing", 0.05f);
+#else
ResetAllTriggers();
SetTrigger(ETrigger.ToLanding);
+#endif
+ }
+
+ public void AnimLandingGround()
+ {
+#if ANIM_CROSS_FADE
+ m_Animator.CrossFade("LandingGround", 0.00f);
+#else
+ ResetAllTriggers();
+ SetTrigger(ETrigger.ToLanding);
+#endif
}
void ResetAllTriggers()
@@ -392,4 +423,9 @@ public class UnitAnimation : UnitComponent }
}
+ private void Play(string animState, float fade = 0.1f, float offset = 0f, int layer = 0)
+ {
+ m_Animator.CrossFade(animState, fade, layer, offset);
+ }
+
}
|