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 区别:

相关推荐
xx~t几秒前
嵌入式学习22
数据结构·学习·算法·排序算法
Wang's Blog1 小时前
PostgreSQL笔记20: 实例、集群、模板数据库与表空间 —— 逻辑体系架构深度解析
数据库·笔记·postgresql
Linux-lucky8 小时前
21-Linux学习之旅之HTTPS和安全加固
linux·运维·学习·ubuntu·https
wp123_18 小时前
硬件元器件笔记|IPX8 防水 Type‑C 母座安费诺 124018802112A 与 TONEVEE TY48086‑24A 分析
c语言·开发语言·笔记
mifengxing9 小时前
操作系统 文件系统
笔记·操作系统·计算机408
学运维的Kysan10 小时前
暑假运维学习打卡第二十六天8.17
学习
无聊的菜鸟11 小时前
TMS320F2806X学习笔记(零)—— C2000、CCS、新建工程
笔记·mcu·c2000·f2806x
dear_bi_MyOnly11 小时前
AI人工智能分类识别——机器如何学习
人工智能·学习·分类
ljt272496066112 小时前
Compose笔记(八十三)--onVisibilityChanged
笔记
启雀AI13 小时前
培训平台移动端离线学习方案设计与实现:视频缓存、断点续传与进度同步的工程实践
android·学习·缓存·音视频·企业lms