修复倒播动画的问题

This commit is contained in:
shenjianxing 2025-01-14 10:16:29 +08:00
parent 2c23d0d41c
commit aed257f957
2 changed files with 23 additions and 5 deletions

View File

@ -73,7 +73,7 @@ SpriteRenderer:
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 700820383005de14fba6008141269066, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0

View File

@ -1,3 +1,4 @@
using DG.Tweening;
using System;
using System.Collections.Generic;
using UnityEngine;
@ -81,13 +82,30 @@ namespace QFramework
{
float.TryParse(speed, out curSpeed);
}
anim[animName].speed = curSpeed;
if (curSpeed < 0)
{
anim.Play(animName);
if (anim[animName].wrapMode== WrapMode.Loop)
anim[animName].normalizedTime = 1;
DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed)).onComplete = () =>
{
anim.Stop();
};
}
else
{
anim[animName].speed = curSpeed;
anim.Play(animName);
if (anim[animName].wrapMode == WrapMode.Loop)
{
this.Finish();
}
}
}
}
catch (Exception)
{