Struct MouseState
Combine a single pointer with buttons and a scroll wheel.
Implements
Namespace: UnityEngine.InputSystem.LowLevel
Assembly: Unity.InputSystem.dll
Syntax
public struct MouseState : IInputStateTypeInfo
Fields
buttons
Button mask for which buttons on the mouse are currently pressed.
Declaration
public ushort buttons
Field Value
| Type | Description |
|---|---|
| ushort | Button state mask. |
See Also
clickCount
Number of clicks performed in succession.
Declaration
public ushort clickCount
Field Value
| Type | Description |
|---|---|
| ushort | Successive click count. |
See Also
delta
Screen-space motion delta of the mouse in pixels.
Declaration
public Vector2 delta
Field Value
| Type | Description |
|---|---|
| Vector2 | Mouse movement. |
Remarks
On Windows, delta originates from RAWINPUT API. Note: This value might not update every frame, particularly if your project is running at a high frame rates. This value might also update at a different time than the position. If you need a delta value that correlates with position, you should compute it based on the previous position value.
See Also
displayIndex
The index of the display that was moused.
Declaration
public ushort displayIndex
Field Value
| Type | Description |
|---|---|
| ushort |
position
Screen-space position of the mouse in pixels.
Declaration
public Vector2 position
Field Value
| Type | Description |
|---|---|
| Vector2 | Position of mouse on screen. |
Remarks
On Windows, delta originates from RAWINPUT API. Note: This value might not update every frame, particularly if your project is running at a high frame rates. This value might also update at a different time than the delta. If you need a delta value that correlates with position, you should compute it based on the previous position value.
See Also
scroll
Scroll-wheel delta of the mouse.
Declaration
public Vector2 scroll
Field Value
| Type | Description |
|---|---|
| Vector2 | Scroll wheel delta. |
See Also
Properties
Format
Memory format identifier for MouseState.
Declaration
public static FourCC Format { get; }
Property Value
| Type | Description |
|---|---|
| FourCC | Returns "MOUS". |
See Also
format
Returns Format.
Declaration
public FourCC format { get; }
Property Value
| Type | Description |
|---|---|
| FourCC |
See Also
Methods
WithButton(MouseButton, bool)
Set the button mask for the given button.
Declaration
public MouseState WithButton(MouseButton button, bool state = true)
Parameters
| Type | Name | Description |
|---|---|---|
| MouseButton | button | Button whose state to set. |
| bool | state | Whether to set the bit on or off. |
Returns
| Type | Description |
|---|---|
| MouseState | The same MouseState with the change applied. |