Description
The MouseWheel
property provides the current state of the mouse wheel as a Vector2
. This property is static and can be accessed without instantiating the Input
class. It is useful for detecting mouse wheel movements, which can be used for zooming, scrolling, or other input actions in a game.
Usage
To access the mouse wheel state, simply use the MouseWheel
property from the Input
class. The Vector2
returned represents the movement of the mouse wheel, where the X component typically represents horizontal scrolling and the Y component represents vertical scrolling.
Example
// Example of using the MouseWheel property
Vector2 mouseWheelState = Input.MouseWheel;
// Check if the mouse wheel has been scrolled up or down
if (mouseWheelState.y > 0)
{
// Mouse wheel scrolled up
// Implement zoom in or scroll up functionality
}
else if (mouseWheelState.y < 0)
{
// Mouse wheel scrolled down
// Implement zoom out or scroll down functionality
}