1、创建KeyTest脚本
2、创建一个空物体并绑定脚本
3、常用的鼠标操作
//鼠标的点击
//按下鼠标 0左键 1右键 2滚轮
if (Input.GetMouseButtonDown(0)) {
Debug.Log("鼠标点击左键");
}
//持续按下鼠标
if(Input.GetMouseButton(0))
{
Debug.Log("持续按下鼠标左键");
}
//抬起鼠标
if (Input.GetMouseButtonUp(0))
{
Debug.Log("抬起鼠标左键");
}
4、常用的键盘操作
//按下键盘按键
if (Input.GetKeyDown(KeyCode.A)) {
}
//持续按下按键
if (Input.GetKey(KeyCode.A))
{
}
//抬起键盘按键
if (Input.GetKeyUp(KeyCode.A))
{
}