diff --git a/Assets/Scripts/Actions/AnimationAction.cs b/Assets/Scripts/Actions/AnimationAction.cs index d22a624f..edee41a5 100644 --- a/Assets/Scripts/Actions/AnimationAction.cs +++ b/Assets/Scripts/Actions/AnimationAction.cs @@ -27,6 +27,8 @@ namespace QFramework string frame; string speed; string deviceName; + + float totalTime; public static AnimationAction Allocate(string path, Dictionary datas, System.Action OnFinished = null) { var retNode = mPool.Allocate(); @@ -95,16 +97,13 @@ namespace QFramework else { anim[animName].speed = curSpeed; - anim.Play(animName); - if (anim[animName].wrapMode == WrapMode.Loop) { this.Finish(); } } - - + totalTime = Math.Abs(anim[animName].length / curSpeed); } } catch (Exception) @@ -122,7 +121,8 @@ namespace QFramework public void OnExecute(float dt) { - if (anim != null && anim.isPlaying == false) + totalTime -= Time.deltaTime; + if (anim != null && (anim.isPlaying == false || totalTime <= 0)) { this.Finish(); }