Files
2026-11-01 23:39:55 +02:00

4.3 KiB

uid
uid
input-system-touch-devices-intro

Touch devices introduction

You can receive and process touch input from touch devices with the following APIs:

For a list of platforms that support touch devices, refer to Supported devices reference.

High-level touch support

The EnhancedTouch.Touch API provides access to touch information along two dimensions:

Refer to the EnhancedTouch.Touch API documentation for more information.

Note

The Touch and Finger APIs don't allocate managed memory, and therefore don't cause garbage collection. The bulk of the data is stored in unmanaged memory that's indexed by wrapper structs. All arrays are pre-allocated.

Low-level touch support

At the lowest level, a touch screen is represented by an InputSystem.Touchscreen device which captures the touchscreen's raw state. Touch screens are based on the pointer layout, and they implement some additional controls outlined in the Touchscreen API documentation.

To query the touch screen that was last used or last added, use Touchscreen.current.

API controls

A touch screen device consists of multiple TouchControl instances. Each of these represents a finger which is touching the device. The primaryTouch control represents the touch which is currently driving the pointer representation, and which should be used to interact with the UI.

The primaryTouch control usually represents the first finger that touches the screen and is always identical to one of the entries in the touches array. The touches array contains all the touches that the system can track. This array has a fixed size, regardless of how many touches are currently active. If you need an API that only represents active touches, refer to the higher-level EnhancedTouch.Touch class.

Testing touch devices

To test your app on iOS or Android in the unity Editor with touch input from your mobile device, use the Unity Remote.