获取Animator的总帧率 和 当前播放帧
2021-04-23 本文已影响0人
RichMartin
private float GetTotalFrame(Animator animator)
{
var clip = animator.GetCurrentAnimatorClipInfo(0)[0].clip;
var length = clip.length;
float frameRate = clip.frameRate;
return length / (1 / frameRate);
}
public void Update(float deltaTime)
{
var currentTime = animator.GetCurrentAnimatorStateInfo(0).normalizedTime;
int currentFrame = (int)(Mathf.Floor(totalFrame * currentTime) % totalFrame);
}