能否获得动画制作者完成动画所需的总时间?是协程还是更新?
public class AnimatorLoop : MonoBehaviour {
private Animator anim;
// Use this for initialization
void Start () {
anim = GetComponent<Animator>();
StartCoroutine(PlayAnim());
}
// Update is called once per frame
void Update () {
}
IEnumerator PlayAnim()
{
anim.Play("MoveForward", 0, 0);
yield return null;
}
}
答案 0 :(得分:0)
IEnumerator PlayAnim()
{
anim.Play("CubeForward", 0, 0);
yield return new WaitForEndOfFrame();
Debug.Log("current clip length = " + anim.GetCurrentAnimatorStateInfo(0).length);
}
只需添加一条提及长度的行,该行就可以计算出距离和速度以给出时间。