Structure describing the status of a finger touching the screen.
Devices can track a number of different pieces of data about a touch on a touchscreen, including its phase
of the touch lifecycle, its position and whether the touch was a single contact or several taps. Furthermore, the continuity of a touch between frame updates can be detected by the device, so a consistent ID number can be reported across frames and used to determine how a particular finger is moving.
The touch lifecycle describes the state of a touch in any given frame:
Began - A user has touched their finger to the screen this frame
Stationary - A finger is on the screen but the user has not moved it this frame
Moved - A user moved their finger this frame
Ended - A user lifted their finger from the screen this frame
Cancelled - The touch was interrupted this frame
The Touch struct is used by Unity to store data relating to a single touch instance and is returned by the Input.GetTouch function. Fresh calls to GetTouch will be required on each frame update to obtain the latest touch information from the device but the fingerId property can be used to identify the same touch between frames.
Note: On iOS devices, any Touch information that is being held in memory (for example, when you are part way through the touch lifecycle) will be lost if the application is minimized. This happens because iOS calls ResetTouch() and wipes all touch data from memory. The lifecycle of that touch ends there and any functionality that relies on later phases of the touch lifecycle is not executed. If you experience this problem, you should move the functionality that is not being executed into MonoBehaviour.OnApplicationFocus or MonoBehaviour.OnApplicationPause.
See Also: Input.GetTouch, TouchPhase enum.
altitudeAngle | Value of 0 radians indicates that the stylus is parallel to the surface, pi/2 indicates that it is perpendicular. |
azimuthAngle | Value of 0 radians indicates that the stylus is pointed along the x-axis of the device. |
deltaPosition | The position delta since last change in pixel coordinates. |
deltaTime | Amount of time that has passed since the last recorded change in Touch values. |
fingerId | The unique index for the touch. |
maximumPossiblePressure | The maximum possible pressure value for a platform. If Input.touchPressureSupported returns false, the value of this property will always be 1.0f. |
phase | Describes the phase of the touch. |
position | The position of the touch in screen space pixel coordinates. |
pressure | The current amount of pressure being applied to a touch. 1.0f is considered to be the pressure of an average touch. If Input.touchPressureSupported returns false, the value of this property will always be 1.0f. |
radius | An estimated value of the radius of a touch. Add radiusVariance to get the maximum touch size, subtract it to get the minimum touch size. |
radiusVariance | This value determines the accuracy of the touch radius. Add this value to the radius to get the maximum touch size, subtract it to get the minimum touch size. |
rawPosition | The first position of the touch contact in screen space pixel coordinates. |
tapCount | Number of taps. |
type | A value that indicates whether a touch was of Direct, Indirect (or remote), or Stylus type. |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.