diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index e3c9f60c..dd214004 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -65,55 +65,61 @@ namespace QFramework if (obj.activeSelf == false) { Debug.LogError(obj.name + "当前是隐藏状态"); + this.Finish(); } - try + else { - anim = obj.GetComponent(); - - if (string.IsNullOrEmpty(frame) == false && frame != "-1") + try { - int curFrame = 0; - int.TryParse(frame, out curFrame); - anim.clip = anim[animName].clip; - anim[animName].time = curFrame / anim.clip.frameRate; - anim[animName].speed = 0; - anim.Play(animName); - this.Finish(); - } - else - { - float curSpeed = 1; - if (string.IsNullOrEmpty(speed) == false) - { - float.TryParse(speed, out curSpeed); - } + anim = obj.GetComponent(); - if (curSpeed < 0) + if (string.IsNullOrEmpty(frame) == false && frame != "-1") { + int curFrame = 0; + int.TryParse(frame, out curFrame); + anim.clip = anim[animName].clip; + anim[animName].time = curFrame / anim.clip.frameRate; + anim[animName].speed = 0; anim.Play(animName); - anim[animName].normalizedTime = 1; - animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)); - animDot.onComplete = () => - { - anim.Stop(); - }; + this.Finish(); } else { - anim[animName].speed = curSpeed; - anim.Play(animName); - if (anim[animName].wrapMode == WrapMode.Loop) + float curSpeed = 1; + if (string.IsNullOrEmpty(speed) == false) { - this.Finish(); + float.TryParse(speed, out curSpeed); } + + if (curSpeed < 0) + { + anim.Play(animName); + anim[animName].normalizedTime = 1; + animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)); + animDot.onComplete = () => + { + anim.Stop(); + }; + } + else + { + anim[animName].speed = curSpeed; + anim.Play(animName); + if (anim[animName].wrapMode == WrapMode.Loop) + { + this.Finish(); + } + } + totalTime = Math.Abs(anim[animName].length / curSpeed); } - totalTime = Math.Abs(anim[animName].length / curSpeed); + } + catch (Exception) + { + anim = obj.GetComponent(); + Debug.LogError($"{path} 播放动画 {animName} 出错"); } } - catch (Exception) - { - Debug.LogError($"{path} 播放动画 {animName} 出错"); - } + } else