Input 输入

键盘输入监听

// 监听键盘字母A按下
Input.GetKeyDown(KeyCode.A);
// 监听键盘字母A抬起
Input.GetKeyUp(KeyCode.A);
// 监听键盘字母A长按
Input.GetKey(KeyCode.A);

鼠标按键监听

// 监听鼠标左键按下
Input.GetMouseButtonDown(0);
// 监听鼠标左键长按
Input.GetMouseButton(0);
// 监听鼠标左键抬起
Input.GetMouseButtonUp(0);

获得鼠标轴向

// 鼠标按下Y轴偏移量
Input.GetAxis("Mouse Y");
// 鼠标按下X轴偏移量
Input.GetAxis("Mouse X");

通过获得轴向来获得对应的向量,WASD

Vector3 dir = new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"));

获得鼠标坐标

Input.mousePosition;

键盘监听的按键在默认的枚举中已实现
鼠标监听的按钮左键表示0,右键表示1,滚轮表示2。

posted @ 2022-10-28 14:57  坞中客  阅读(118)  评论(0)    收藏  举报