Mouse devices introduction
The Input System represents mouse input with the MouseState device layout that the Mouse class implements.
Important
The Input System doesn't support input from multiple mice at the platform level, or identifying the current display a mouse is on.
The Mouse class is based on the pointer layout so inherits its controls. It also implements additional controls outlined in the Mouse API documentation.
Mice on mobile platforms
On mobile platforms, a mouse isn't usually connected, so don't assume that a Mouse device exists:
- On iOS and tvOS, the Input System doesn't detect mice. It doesn't add a
Mousedevice when the user connects a mouse, soMouse.currentisnullunless your application adds a virtual mouse, for example with the Virtual Mouse component. - On Android, the Input System adds a
Mousedevice only when the user connects a mouse or a trackpad. Until then,Mouse.currentisnull. - Touch input doesn't create or move a
Mousedevice. The Input System reports touch input through theTouchscreendevice.
To check whether the platform supports mice, use Mouse.isSupported. To check whether a Mouse device is available, check that Mouse.current isn't null. This includes virtual mice that your application adds, so it doesn't always mean that a physical mouse is connected. To read input from the pointer that the user used last, including touch, use Pointer.current.
For a list of platforms that support mice, refer to Supported devices reference.