准备工作:Asset Store 下载一套免费的animation导入unity
步骤一:创建空物体Creat Empty
在空物体GameObject里面
添加两个按钮 以及 把Prefabs的Sword snd shie拉进来
(按钮改名称略过说明)
(完全零基础小白,你可以和我下载一样的资源Sword and Shield Pack)
步骤二:创建脚本并挂载在空物体GameObject上
using UnityEngine;
using UnityEngine.UI;
public class ChacterC : MonoBehaviour
{
public Animator animator; // 动画控制器
public Button idleButton; // 待机按钮
public Button attackButton; // 攻击按钮
private void Start()
{
// 给待机按钮添加OnClick事件
idleButton