Unity简单操作:设置触发条件 切换Animator动画控制器 里面播放的Animation动画

确保animator里面有多个animation动画剪辑,点击Animator里面[Parameters]添加触发条件

添加连线箭头并且 给箭头连线绑定触发事件

 添加连线箭头并且 给箭头连线绑定触发事件

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

//测试Animator动画控制器里面 用条件切换动画
public class TestAnimator : MonoBehaviour
{ 
    //物体的动画管理器组件
    public Animator catButton_ator; 
    //更改连线条件的按钮
    public Button PressButton;
    public Button PressIntButton;

    void Start()
    {
        PressButton.onClick.AddListener(delegate
        { 
            catButton_ator.SetBool("Press", true);//设置物体的Animator动画管理器组件的连线到指定动画的条件
        });

        PressIntButton.onClick.AddListener(delegate
        {
            catButton_ator.SetBool("Press", false);//设置物体的Animator动画管理器组件的连线到指定动画的条件 
        }); 

    }

    
}

猜你喜欢

转载自blog.csdn.net/weixin_39114763/article/details/130294881
今日推荐