Struct TouchState
State layout for a single touch.
Namespace: UnityEngine.InputSystem.LowLevel
Syntax
public struct TouchState : IInputStateTypeInfo
Remarks
This is the low-level memory representation of a single touch, i.e the way touches are internally transmitted and stored in the system. To update touches on a Touchscreen, StateEvents containing TouchStates are sent to the screen.
Fields
delta
Screen-space motion delta of the touch in pixels.
Declaration
public Vector2 delta
Field Value
Type | Description |
---|---|
Vector2 | Screen-space movement delta. |
See Also
flags
Declaration
public byte flags
Field Value
Type | Description |
---|---|
Byte |
phaseId
TouchPhase value of the touch.
Declaration
public byte phaseId
Field Value
Type | Description |
---|---|
Byte | Current TouchPhase. |
See Also
position
Screen-space position of the touch in pixels.
Declaration
public Vector2 position
Field Value
Type | Description |
---|---|
Vector2 | Screen-space position of the touch. |
See Also
pressure
Pressure-level of the touch against the touchscreen.
Declaration
public float pressure
Field Value
Type | Description |
---|---|
Single | Pressure of touch. |
Remarks
The core range for this value is [0..1] with 1 indicating maximum pressure. Note, however, that the actual value may go beyond 1 in practice. This is because the system will usually define "maximum pressure" to be less than the physical maximum limit the hardware is capable of reporting so that to achieve maximum pressure, one does not need to press as hard as possible.
See Also
radius
Radius of the touch print on the surface.
Declaration
public Vector2 radius
Field Value
Type | Description |
---|---|
Vector2 | Touch extents horizontally and vertically. |
Remarks
The touch radius is given in screen-space pixel coordinates along X and Y centered in the middle
of the touch. Note that not all screens and systems support radius detection on touches so this
value may be at default
for an otherwise perfectly valid touch.
See Also
startPosition
The position where the touch started.
Declaration
public Vector2 startPosition
Field Value
Type | Description |
---|---|
Vector2 | Screen-space start position of the touch. |
Remarks
This is set automatically by Touchscreen and does not need to be provided by events sent to the touchscreen.
See Also
startTime
Time that the touch was started. Relative to Time.realTimeSinceStartup
.
Declaration
public double startTime
Field Value
Type | Description |
---|---|
Double | Time that the touch was started. |
Remarks
This is set automatically by Touchscreen and does not need to be provided by events sent to the touchscreen.
See Also
tapCount
Declaration
public byte tapCount
Field Value
Type | Description |
---|---|
Byte |
touchId
Numeric ID of the touch.
Declaration
public int touchId
Field Value
Type | Description |
---|---|
Int32 | Numeric ID of the touch. |
Remarks
While a touch is ongoing, it must have a non-zero ID different from all other ongoing touches. Starting with Began and ending with Ended or Canceled, a touch is identified by its ID, i.e. a TouchState with the same ID belongs to the same touch.
After a touch has ended or been canceled, an ID can be reused.
See Also
Properties
format
Declaration
public FourCC format { get; }
Property Value
Type | Description |
---|---|
FourCC |
Implements
Format
Memory format tag for TouchState.
Declaration
public static FourCC Format { get; }
Property Value
Type | Description |
---|---|
FourCC | Returns "TOUC". |
See Also
isIndirectTouch
Declaration
public bool isIndirectTouch { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
isInProgress
Declaration
public bool isInProgress { get; }
Property Value
Type | Description |
---|---|
Boolean |
isNoneEndedOrCanceled
Declaration
public bool isNoneEndedOrCanceled { get; }
Property Value
Type | Description |
---|---|
Boolean |
isPrimaryTouch
Whether TODO
Declaration
public bool isPrimaryTouch { get; set; }
Property Value
Type | Description |
---|---|
Boolean | Whether the touch is the first TODO |
Remarks
This flag will be set internally by Touchscreen. Generally, it is not necessary to set this bit manually when feeding data to Touchscreens.
isTap
Declaration
public bool isTap { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
phase
Get or set the phase of the touch.
Declaration
public TouchPhase phase { get; set; }
Property Value
Type | Description |
---|---|
TouchPhase | Phase of the touch. |
See Also
Methods
ToString()
Return a string representation of the state useful for debugging.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String | A string representation of the touch state. |