unity3d的键盘和鼠标输入
2024-09-01 22:55:27
一.键盘的输入
•GetKey,GetKeyDown,GetKeyUp三个方法分别获取用户键盘按键的输入
1. GetKey:用户长按按键有效;
bool down = Input.GetKeyDown(KeyCode.Space);
2. GetKeyDown:用户按下按键时有效;
bool held = Input.GetKey(KeyCode.Space);
3.GetKeyUp:用户抬起按键时有效;
bool up = Input.GetKeyUp(KeyCode.Space);
• anyKey,anyKeyDown
anyKey用于监听用户的任意按键输入或鼠标点击,事件触发后返回true。anyKeyDown:当任意按键松开时返回true。
示例
if (Input.anyKey) { }
二.鼠标的输入
•GetMouseButton
1. GetMouseButton 对应的键处于按下状态时返回true
2. GetMouseButtonDown 对应的键被按下时返回true
3. GetMouseButtonUp 对应的键弹起时返回true
示例:
if (Input.GetMouseButton(0)) { //"鼠标左键按下" } else if(Input.GetMouseButton(1)) { //"鼠标右键按下" } else if(Input.GetMouseButton(2)) { // "鼠标中键按下" }
最新文章
- 个人总结深入.NET平台和C#编程
- Android Studio中获取SHA1或MD5的方法
- Core 开发-Logging 使用NLog
- MySQL连表操作之一对多
- 简单实用的Log4net帮助类
- PNote桌面贴小工具 - 项目管理系列文章
- System.currentTimeMillis()计算方式与时间的单位转换
- Android入门:发送HTTP的GET和POST请求
- SQLLite 简介
- wamp虚拟机配置
- 如何解决JavaWeb乱码问题
- 微信小程序数据请求方法wx.request小测试
- python模块 ---logging模块
- npm 如何安装npm包
- Spring Boot 整合 docker
- 单点登录SSO:可一键运行的完整代码
- 14.statefulset服务
- SqlServer查找字段中带空值的项
- mysql添加Federated引擎问题
- os 模块 和 os模块下的path模块
热门文章
- shell编程之if语句
- hdu4107Gangster 线段树
- 你真的理解 if __name__ == '__main__' 的作用么?
- Centos 8 安装 Consul-Template
- 加密解密 Python
- javascript创建函数的方法
- Infrared-Visible Cross-Modal Person Re-Identification with an X Modality (AAAI 2020)
- 【webpack 系列】进阶篇
- 【开源项目系列】如何基于 Spring Cache 实现多级缓存(同时整合本地缓存 Ehcache 和分布式缓存 Redis)
- 2288: 【基础】小X转进制