Unity 动画播完时关闭动画

Returns an AnimatorStateInfo with the information on the current state.

this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0)

 

代码如下: 

public class AnimationAutoDestory : MonoBehaviour {

 

    public float delay = 1f;
    // Use this for initialization
    void Start () {
        Destroy(gameObject, this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length + delay);
    }
// Update is called once per frame
void Update () {
}
}
posted @ 2019-06-12 19:13  三里路异乡客  阅读(1065)  评论(0编辑  收藏  举报