From 6228329b2a4b5c095dea2abf4da99281a100d461 Mon Sep 17 00:00:00 2001 From: shenjianxing <”315615051@qq.com“> Date: Wed, 22 Jan 2025 10:59:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=89=A9=E4=BD=93=E6=9C=AA=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E6=97=B6=E7=9B=B4=E6=8E=A5finish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/Scripts/Actions/AnimationAction.cs | 76 ++++++++++++----------- 1 file changed, 41 insertions(+), 35 deletions(-) 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