Struct TouchscreenState | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct TouchscreenState

    Default state layout for touch devices.

    Namespace: UnityEngine.InputSystem.LowLevel
    Syntax
    public struct TouchscreenState : IInputStateTypeInfo
    Remarks

    Combines multiple pointers each corresponding to a single contact.

    All touches combine to quite a bit of state; ideally send delta events that update only specific fingers.

    This is NOT used by native. Instead, the native runtime always sends individual touches (TouchState) and leaves state management for a touchscreen as a whole to the managed part of the system.

    Fields

    MaxTouches

    Maximum number of touches that can be tracked at the same time.

    Declaration
    public const int MaxTouches = 10
    Field Value
    Type Description
    System.Int32
    Remarks

    While most touchscreens only support a number of concurrent touches that is significantly lower than this number, having a larger pool of touch states to work with makes it possible to track short-lived touches better.

    primaryTouchData

    Data for the touch that is deemed the "primary" touch at the moment.

    Declaration
    public byte *primaryTouchData
    Field Value
    Type Description
    System.Byte*
    Remarks

    This touch duplicates touch data from whichever touch is deemed the primary touch at the moment. When going from no fingers down to any finger down, the first finger to touch the screen is deemed the "primary touch". It stays the primary touch until released. At that point, if any other finger is still down, the next finger in touchData is

    Having this touch be its own separate state and own separate control allows actions to track the state of the primary touch even if the touch moves from one finger to another in touchData.

    touchData

    Declaration
    public byte *touchData
    Field Value
    Type Description
    System.Byte*

    Properties

    format

    Declaration
    public FourCC format { get; }
    Property Value
    Type Description
    FourCC
    Implements
    IInputStateTypeInfo.format

    kFormat

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

    primaryTouch

    Declaration
    public TouchState*primaryTouch { get; }
    Property Value
    Type Description
    TouchState*

    touches

    Declaration
    public TouchState*touches { get; }
    Property Value
    Type Description
    TouchState*
    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023