Mouse interaction for basic use of Unity InputSystem

material

Official documentation

Import the InputSystem package

  1. Package Manager searches for Input System to download
  2. Enabling this package will restart the Unity Editor

Notice

InputSystem can be used with older versions of the input system.
Settings: Project Settings->Player->Other Settings->Configuration->Active Input Handling
parameters are optional: Input Manager (old), Input System Package (New), Both

mouse interaction

Get the current mouse

Mouse.current

Mouse pointer position (screen space)

mouse.position.ReadValue() 类似Input.mousePosition

Interaction of left, right and middle mouse buttons

mouse.leftButton.isPressed 鼠标左键保持按下
mouse.leftButton.wasPressedThisFrame 鼠标左键按下
mouse.leftButton.wasReleasedThisFrame 鼠标左键抬起
mouse.rightButton.isPressed 鼠标右键保持按下
mouse.middleButton.isPressed 鼠标中键保持按下

mouse wheel

mouse.scroll.y.ReadValue() 鼠标滚轮滚动值

mouse movement

mouse.delta.ReadValue() 鼠标移动增量  类似 Mouse X 和Mouse Y的组合

Guess you like

Origin blog.csdn.net/weixin_43796392/article/details/132723978