Unity 新InputSystem 学习笔记

一、鼠标、键盘按键

1、鼠标按键:

Mouse.current.xxxButton.IsPress //按住

Mouse.current.xxxButton.wasPressedThisFrame //按下

Mouse.current.xxxButton.wasReleasedThisFrame //松开

2、键盘按键:

Keyboard.current.xxxKey.IsPress //按住

Keyboard.current.xxxKey.wasPressedThisFrame //按下

Keyboard.current.xxxKey.wasReleasedThisFrame //松开


二、使用 InputActionAsset

1、在Assets列表右键,创建一个 InputActions

2、双击编辑资源

3、组成:

一个InputActionAsset 可以有多个ActionMaps

一个ActionMaps可以有多个Action对象

一个Action可以有多个Binding

4、代码调用:

① 获取InputActionAsset 的某个ActionMap下的某个Action :

inputActionsAsset.FindActionMap("Map Name").FindAction("Action Name");

② 按钮 InputAction 的 按住、按下、松开、触发

inputAction.IsPressed();//按住

inputAction.WasPressedThisFrame(); //按下

inputAction.WasReleasedThisFrame(); //松开

inputAction.triggered; // 触发 ( 等同于WasPerformedThisFrame() )

inputAction.WasPerformedThisFrame(); //触发

WasPerformedThisFrame 和 WasPressedThisFrame 区别:

相关推荐
西岸行者2 天前
学习笔记:SKILLS 能帮助更好的vibe coding
笔记·学习
starlaky2 天前
Django入门笔记
笔记·django
勇气要爆发2 天前
吴恩达《LangChain LLM 应用开发精读笔记》1-Introduction_介绍
笔记·langchain·吴恩达
悠哉悠哉愿意2 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
勇气要爆发2 天前
吴恩达《LangChain LLM 应用开发精读笔记》2-Models, Prompts and Parsers 模型、提示和解析器
android·笔记·langchain
别催小唐敲代码2 天前
嵌入式学习路线
学习
qianshanxue112 天前
计算机操作的一些笔记标题
笔记
土拨鼠烧电路2 天前
笔记11:数据中台:不是数据仓库,是业务能力复用的引擎
数据仓库·笔记
毛小茛2 天前
计算机系统概论——校验码
学习
土拨鼠烧电路2 天前
笔记14:集成与架构:连接孤岛,构建敏捷响应能力
笔记·架构