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);
}
网友评论