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

相关推荐
Horn Still Sounds14 分钟前
IMX6ULL裸机|I2C通信协议 + ADC模数转换学习笔记
arm开发·笔记·单片机·嵌入式硬件
每天题库1 小时前
架子工脚手架工题库:安全操作考点与模拟题练习指南
学习·安全·考试·题库·考证
yangmu32032 小时前
Codex 提示词优化教程:用四要素把模糊需求变成可执行任务
人工智能·学习
无敌贵点大王2 小时前
RTThread学习记录13——关于要使用一个外设,RTThread与cubemx到底要怎么配合?
c语言·stm32·学习·rtthread
有范先生3 小时前
这次户外断粮危机后,我更在意主食能不能扛住极端环境了
笔记
喜欢打篮球的普通人4 小时前
MiniMind 学习笔记(十二):Pretrain 实操——从版本梳理到 8GB 显卡上的真实训练
人工智能·笔记·学习
m4Rk_5 小时前
【论文阅读】Agent 记忆机制(87):VizoMem——把文本历史转化为可检索的视觉记忆
论文阅读·人工智能·学习·开源·github
坤坤子吖5 小时前
算法学习——高精度加减乘除
c++·笔记·学习·算法
HY小宝F6 小时前
树莓派智能摄像头系统 30 天重学计划之 Day 03 · 网络基础:建立“包“的思维 —— 学习总结
网络·学习
dadaobusi6 小时前
学习:AXI协议
学习