docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct TouchState

    State layout for a single touch.

    Implements
    IInputStateTypeInfo
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    Namespace: UnityEngine.InputSystem.LowLevel
    Assembly: Unity.InputSystem.dll
    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
    delta

    displayIndex

    The index of the display that was touched.

    Declaration
    public byte displayIndex
    Field Value
    Type Description
    byte
    See Also
    TouchControl
    Touchscreen

    flags

    Declaration
    public byte flags
    Field Value
    Type Description
    byte
    See Also
    TouchControl
    Touchscreen

    phaseId

    TouchPhase value of the touch.

    Declaration
    public byte phaseId
    Field Value
    Type Description
    byte

    Current TouchPhase.

    See Also
    phase

    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
    position

    pressure

    Pressure-level of the touch against the touchscreen.

    Declaration
    public float pressure
    Field Value
    Type Description
    float

    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
    pressure

    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
    radius

    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
    startPosition

    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
    time
    startTime

    tapCount

    Declaration
    public byte tapCount
    Field Value
    Type Description
    byte
    See Also
    TouchControl
    Touchscreen

    touchId

    Numeric ID of the touch.

    Declaration
    public int touchId
    Field Value
    Type Description
    int

    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
    touchId

    Properties

    Format

    Memory format tag for TouchState.

    Declaration
    public static FourCC Format { get; }
    Property Value
    Type Description
    FourCC

    Returns "TOUC".

    See Also
    format

    format

    Declaration
    public FourCC format { get; }
    Property Value
    Type Description
    FourCC
    See Also
    TouchControl
    Touchscreen

    isInProgress

    Declaration
    public bool isInProgress { get; }
    Property Value
    Type Description
    bool
    See Also
    TouchControl
    Touchscreen

    isIndirectTouch

    Declaration
    public bool isIndirectTouch { get; set; }
    Property Value
    Type Description
    bool
    See Also
    TouchControl
    Touchscreen

    isNoneEndedOrCanceled

    Declaration
    public bool isNoneEndedOrCanceled { get; }
    Property Value
    Type Description
    bool
    See Also
    TouchControl
    Touchscreen

    isPrimaryTouch

    Whether, after not having any touch contacts, this is part of the first touch contact that started.

    Declaration
    public bool isPrimaryTouch { get; set; }
    Property Value
    Type Description
    bool
    Remarks

    This flag will be set internally by Touchscreen. Generally, it is not necessary to set this bit manually when feeding data to Touchscreens.

    See Also
    TouchControl
    Touchscreen

    isTap

    Declaration
    public bool isTap { get; set; }
    Property Value
    Type Description
    bool
    See Also
    TouchControl
    Touchscreen

    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
    phase

    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.

    Overrides
    ValueType.ToString()
    See Also
    TouchControl
    Touchscreen

    Implements

    IInputStateTypeInfo

    See Also

    TouchControl
    Touchscreen
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)