物体未显示时直接finish

This commit is contained in:
shenjianxing 2025-01-22 10:59:25 +08:00
parent a28f22f38a
commit 6228329b2a

View File

@ -65,55 +65,61 @@ namespace QFramework
if (obj.activeSelf == false) if (obj.activeSelf == false)
{ {
Debug.LogError(obj.name + "当前是隐藏状态"); Debug.LogError(obj.name + "当前是隐藏状态");
this.Finish();
} }
try else
{ {
anim = obj.GetComponent<Animation>(); try
if (string.IsNullOrEmpty(frame) == false && frame != "-1")
{ {
int curFrame = 0; anim = obj.GetComponent<Animation>();
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);
}
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.Play(animName);
anim[animName].normalizedTime = 1; this.Finish();
animDot = DOTween.To(() => anim[animName].normalizedTime, v => anim[animName].normalizedTime = v, 0, anim[animName].length / Math.Abs(curSpeed));
animDot.onComplete = () =>
{
anim.Stop();
};
} }
else else
{ {
anim[animName].speed = curSpeed; float curSpeed = 1;
anim.Play(animName); if (string.IsNullOrEmpty(speed) == false)
if (anim[animName].wrapMode == WrapMode.Loop)
{ {
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<Animation>();
Debug.LogError($"{path} ²¥·Å¶¯»­ {animName} ³ö´í");
} }
} }
catch (Exception)
{
Debug.LogError($"{path} ²¥·Å¶¯»­ {animName} ³ö´í");
}
} }
else else