c# - unity - 键绑定打开和关闭动画
问题描述
我正在制作一个可以通过键绑定 (I) 访问的库存菜单。单击键绑定时,播放带入菜单的动画,如果再次单击键绑定,则应关闭菜单。不知道我要去哪里错了。
我已将动画控制器附加到 UI。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ShowInventory : MonoBehaviour {
public Animator animator;
// Update is called once per frame
void Update() {
if (Input.GetKeyDown(KeyCode.I)) {
animator.SetBool("isOpen", true);
}
}
}
解决方案
除了代码之外,您还必须确保 Animator Controller 资产中的状态机也已正确设置。如果您还没有,请查看本教程:https ://unity3d.com/learn/tutorials/topics/animation/animator-controller
推荐阅读
- angular - 如何在 Angular 2+ 日历的周视图中实现点击事件?
- javascript - 在更改时使下拉列表值等于其他下拉列表的值
- c# - c#rest api绑定到0.0.0.0
- node.js - Node.js Request() 在一个特定域的页面上失败
- c# - Windows 10 1803 中没有默认字体
- android - 排球错误响应为空
- git - (GitKraken)预提交失败退出代码:1
- enums - 如何返回特定索引处的枚举字符串?
- mysql - 从另一台计算机访问数据库
- powershell - 执行powershell脚本的任务调度程序没有得到对webRequest的响应