diff options
-rw-r--r-- | Erika/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/Erika/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs b/Erika/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs index f80a8312..74c33626 100644 --- a/Erika/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs +++ b/Erika/Assets/Scripts/Unit/Components/UnitAnimation/PCAnimation.cs @@ -74,7 +74,26 @@ public class PCAnimation : UnitAnimation public bool applyRootMotion { get; set; } public bool applyRootCurve { get; set; } // 程序生成的root motion - public bool updateAnimationAuto { get; private set; } // 自动更新动画 + private bool m_AutoUpdate; + public bool updateAnimationAuto
+ {
+ get
+ {
+ return m_AutoUpdate;
+ }
+ private set
+ {
+ m_AutoUpdate = value;
+ if (value)
+ {
+ m_Animator.speed = 1;
+ }
+ else
+ {
+ m_Animator.speed = 0;
+ }
+ }
+ } private AnimatorOverrideController controller
{
@@ -91,8 +110,6 @@ public class PCAnimation : UnitAnimation m_Animator = this.m_Owner.unitObj.GetComponent<Animator>(); - m_Animator.speed = 0; - m_LayerInfo = new AnimatorLayerInfo[2]; m_LayerInfo[0] = new AnimatorLayerInfo(this, m_Animator, (int)ELayer.Basic); //m_LayerInfo[1] = new AnimatorLayerInfo(this, m_Animator, ELayer.Attack); @@ -100,10 +117,10 @@ public class PCAnimation : UnitAnimation if (m_Animator == null) { LogHelper.LogError("没有挂Animator组件"); + return; } applyRootMotion = true; - updateAnimationAuto = true; } @@ -128,14 +145,14 @@ public class PCAnimation : UnitAnimation } void UpdateAnimation() - { - if(updateAnimationAuto)
- {
- m_Animator.speed = 1;
- m_Animator.Update(Time.deltaTime);
- m_Animator.speed = 0; - }
- } + {
+ if (!updateAnimationAuto)
+ {
+ m_Animator.speed = 1;
+ m_Animator.Update(Time.deltaTime);
+ m_Animator.speed = 0;
+ }
+ } void UpdateRootMotion() { |