代码如下:
//对键盘的输入需要逐帧读取,因此放入Update
void Update()
{
//鼠标的点击
//按下鼠标 0左键 1右键 2滚轮
if(input.GetMouseButtonDown(0)){
Debug.log("按下了鼠标左键");
}
//持续按下鼠标
if(input.GetMouseButton(0)){
Debug.log("持续按下鼠标左键");
}
//抬起鼠标
if(input.GetMouseButtonUp(0)){
Debug.log("抬起了鼠标左键");
}
//按下键盘按键 KeyCode.A <=> a != A
if(input.GetKeyDown(KeyCode.A)){
Debug.log("按下了A");
}
//持续按下按键
if(input.GetKey(KeyCode.A)){
Debug.log("持续按下A");
}
//抬起键盘按键
if(input.GetKeyUp(KeyCode.A)){
Debug.log("松开了A");
}
}