Unity 学习笔记 animator 参数传递

animator在代码中设置参数时经常要传递字符型变量,但是有些移动平台在传递字符时会发生错误,因此官方推荐使用整型来传递:

int groundID;
Animator anim;

void Start(){
    anim = GetComponent<Animator>();
    groundID = Animator.StringToHash("isOnGround");  
}

void Update(){
    //传入参数
    anim.SetBool(groundID, movement.isOnGround);
}

 

posted @ 2020-12-22 20:07  瞬闪影  阅读(695)  评论(0编辑  收藏  举报