动画停止

This commit is contained in:
shenjianxing 2025-01-16 18:48:37 +08:00
parent 1b22d00ff5
commit b5a79921a9

View File

@ -1,8 +1,11 @@
using DG.Tweening; using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using UnityEngine.Rendering.Universal; using UnityEngine.Rendering.Universal;
using static OperationController;
namespace QFramework namespace QFramework
{ {
@ -45,7 +48,7 @@ namespace QFramework
} }
public ulong ActionID { get; set; } public ulong ActionID { get; set; }
public ActionStatus Status { get; set; } public ActionStatus Status { get; set; }
TweenerCore<float, float, FloatOptions> animDot;
public void OnStart() public void OnStart()
{ {
GameObject obj = null; GameObject obj = null;
@ -89,7 +92,8 @@ namespace QFramework
{ {
anim.Play(animName); anim.Play(animName);
anim[animName].normalizedTime = 1; anim[animName].normalizedTime = 1;
DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)).onComplete = () => animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed));
animDot.onComplete = () =>
{ {
anim.Stop(); anim.Stop();
}; };
@ -119,6 +123,7 @@ namespace QFramework
} }
} }
public void OnExecute(float dt) public void OnExecute(float dt)
{ {
totalTime -= Time.deltaTime; totalTime -= Time.deltaTime;
@ -144,6 +149,8 @@ namespace QFramework
{ {
if (!Deinited) if (!Deinited)
{ {
animDot?.Kill();
anim?.Stop();
OnFinished = null; OnFinished = null;
Deinited = true; Deinited = true;
mPool.Recycle(this); mPool.Recycle(this);