docs.unity.cn
    Show / Hide Table of Contents

    Class TouchControl

    A control representing a touch contact.

    Inheritance
    Object
    InputControl
    InputControl<TouchState>
    TouchControl
    Inherited Members
    InputControl<TouchState>.valueType
    InputControl<TouchState>.valueSizeInBytes
    InputControl<TouchState>.ReadValue()
    InputControl<TouchState>.ReadValueFromPreviousFrame()
    InputControl<TouchState>.ReadDefaultValue()
    InputControl<TouchState>.ReadValueFromState(Void*)
    InputControl<TouchState>.ReadUnprocessedValue()
    InputControl<TouchState>.ReadValueFromStateAsObject(Void*)
    InputControl<TouchState>.ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
    InputControl<TouchState>.WriteValueFromBufferIntoState(Void*, Int32, Void*)
    InputControl<TouchState>.WriteValueFromObjectIntoState(Object, Void*)
    InputControl<TouchState>.ReadValueFromBufferAsObject(Void*, Int32)
    InputControl<TouchState>.CompareValue(Void*, Void*)
    InputControl<TouchState>.ProcessValue(TouchState)
    InputControl.name
    InputControl.displayName
    InputControl.shortDisplayName
    InputControl.path
    InputControl.layout
    InputControl.variants
    InputControl.device
    InputControl.parent
    InputControl.children
    InputControl.usages
    InputControl.aliases
    InputControl.stateBlock
    InputControl.noisy
    InputControl.synthetic
    InputControl.Item[String]
    InputControl.ToString()
    InputControl.EvaluateMagnitude()
    InputControl.EvaluateMagnitude(Void*)
    InputControl.TryGetChildControl(String)
    InputControl.TryGetChildControl<TControl>(String)
    InputControl.GetChildControl(String)
    InputControl.GetChildControl<TControl>(String)
    InputControl.RefreshConfigurationIfNeeded()
    InputControl.RefreshConfiguration()
    InputControl.m_StateBlock
    InputControl.currentStatePtr
    InputControl.previousFrameStatePtr
    InputControl.defaultStatePtr
    InputControl.noiseMaskPtr
    InputControl.stateOffsetRelativeToDeviceRoot
    Namespace: UnityEngine.InputSystem.Controls
    Syntax
    public class TouchControl : InputControl<TouchState>
    Remarks

    Note that unlike most other control types, TouchControls do not have a flexible memory layout. They are hardwired to TouchState and will not work correctly with a different memory layouts. Additional fields may be appended to the struct but what's there in the struct has to be located at exactly those memory addresses.

    Constructors

    TouchControl()

    Default-initialize the touch control.

    Declaration
    public TouchControl()
    Remarks

    Sets the format to "TOUC".

    Properties

    delta

    Screen-space motion delta of the touch.

    Declaration
    public Vector2Control delta { get; set; }
    Property Value
    Type Description
    Vector2Control

    Control representing the screen-space motion delta of the touch.

    Remarks

    This is either supplied directly by the underlying platform or computed on the fly by Touchscreen from the last known position of the touch.

    Note that deltas have behaviors attached to them different from most other controls. See delta for details.

    See Also
    delta

    indirectTouch

    Whether the touch comes from a source other than direct contact with the touch surface.

    Declaration
    public ButtonControl indirectTouch { get; set; }
    Property Value
    Type Description
    ButtonControl

    Control indicating whether the touch was generated indirectly.

    Remarks

    Indirect touches can be generated with a stylus, for example.

    isInProgress

    Whether a touch on the control is currently is progress.

    Declaration
    public bool isInProgress { get; }
    Property Value
    Type Description
    Boolean

    If true, a touch is in progress, i.e. has a phase of Began, Moved, or Canceled.

    phase

    Current phase of the touch.

    Declaration
    public TouchPhaseControl phase { get; set; }
    Property Value
    Type Description
    TouchPhaseControl

    Control representing the current phase of the touch.

    Remarks

    This will be None if no touch has been registered on the control yet or if the control has been reset to its default state.

    See Also
    isInProgress

    position

    Absolute screen-space position on the touch surface.

    Declaration
    public Vector2Control position { get; set; }
    Property Value
    Type Description
    Vector2Control

    Control representing the screen-space of the touch.

    See Also
    position

    press

    Button that indicates whether there is currently an ongoing touch contact on the control. When touch is ongoing, button will be 1, otherwise button will be 0.

    Declaration
    public TouchPressControl press { get; set; }
    Property Value
    Type Description
    TouchPressControl

    Control representing an ongoing touch contact.

    Remarks

    This control simply monitors phase and will read as 1 whenever the phase is Began, Moved, or Stationary.

    See Also
    phase

    pressure

    Normalized pressure of the touch against the touch surface.

    Declaration
    public AxisControl pressure { get; set; }
    Property Value
    Type Description
    AxisControl

    Control representing the pressure level of the touch.

    Remarks

    Not all touchscreens are pressure-sensitive. If unsupported, this control will remain at default value.

    In general, touch pressure is supported on mobile platforms only.

    Note that it is possible for the value to go above 1 even though it is considered normalized. The reason is that calibration on the system can put the maximum pressure point below the physically supported maximum value.

    See Also
    pressure
    pressure

    radius

    Screen-space radius of the touch.

    Declaration
    public Vector2Control radius { get; set; }
    Property Value
    Type Description
    Vector2Control

    Control representing the horizontal and vertical extents of the touch contact.

    Remarks

    If supported by the device, this reports the size of the touch contact based on its position center point. If not supported, this will be default(Vector2).

    See Also
    radius

    startPosition

    Screen-space position where the touch started.

    Declaration
    public Vector2Control startPosition { get; set; }
    Property Value
    Type Description
    Vector2Control

    Control representing the start position of the touch.

    See Also
    position

    startTime

    Time in seconds on the same timeline as Time.realTimeSinceStartup when the touch began.

    Declaration
    public DoubleControl startTime { get; set; }
    Property Value
    Type Description
    DoubleControl

    Control representing the start time of the touch.

    Remarks

    This is the value of time when the touch starts with phase Began.

    See Also
    time

    tap

    Whether the touch has performed a tap.

    Declaration
    public ButtonControl tap { get; set; }
    Property Value
    Type Description
    ButtonControl

    Control that indicates whether the touch has tapped the screen.

    Remarks

    A tap is defined as a touch that begins and ends within defaultTapTime and stays within tapRadius of its startPosition. If this is the case for a touch, this button is set to 1 at the time the touch goes to phase Ended.

    The button resets to 0 only when another touch is started on the control or when the control is reset.

    See Also
    tapCount
    defaultTapTime

    tapCount

    Number of times that the touch has been tapped in succession.

    Declaration
    public IntegerControl tapCount { get; set; }
    Property Value
    Type Description
    IntegerControl

    Control that indicates how many taps have been performed one after the other.

    Remarks

    Successive taps have to come within multiTapDelayTime for them to increase the tap count. I.e. if a new tap finishes within that time after startTime of the previous touch, the tap count is increased by one. If more than multiTapDelayTime passes after a tap with no successive tap, the tap count is reset to zero.

    touchId

    The ID of the touch contact as reported by the underlying system.

    Declaration
    public IntegerControl touchId { get; set; }
    Property Value
    Type Description
    IntegerControl

    Control reading out the ID of the touch.

    Remarks

    Each touch contact that is made with the screen receives its own unique ID which is normally assigned by the underlying platform.

    Note a platform may reuse touch IDs after their respective touches have finished. This means that the guarantee of uniqueness is only made with respect to currently ongoing touches.

    See Also
    touchId

    Methods

    FinishSetup()

    Perform final initialization tasks after the control hierarchy has been put into place.

    Declaration
    protected override void FinishSetup()
    Overrides
    InputControl.FinishSetup()
    Remarks

    This method can be overridden to perform control- or device-specific setup work. The most common use case is for looking up child controls and storing them in local getters.

    public class MyDevice : InputDevice
    {
        public ButtonControl button { get; private set; }
        public AxisControl axis { get; private set; }
    
        protected override void OnFinishSetup()
        {
            // Cache controls in getters.
            button = GetChildControl("button");
            axis = GetChildControl("axis");
        }
    }

    ReadUnprocessedValueFromState(Void*)

    Declaration
    public override TouchState ReadUnprocessedValueFromState(void *statePtr)
    Parameters
    Type Name Description
    Void* statePtr
    Returns
    Type Description
    TouchState
    Overrides
    UnityEngine.InputSystem.InputControl<UnityEngine.InputSystem.LowLevel.TouchState>.ReadUnprocessedValueFromState(System.Void*)

    WriteValueIntoState(TouchState, Void*)

    Declaration
    public override void WriteValueIntoState(TouchState value, void *statePtr)
    Parameters
    Type Name Description
    TouchState value
    Void* statePtr
    Overrides
    UnityEngine.InputSystem.InputControl<UnityEngine.InputSystem.LowLevel.TouchState>.WriteValueIntoState(UnityEngine.InputSystem.LowLevel.TouchState, System.Void*)

    Extension Methods

    InputControlExtensions.FindInParentChain<TControl>(InputControl)
    InputControlExtensions.IsPressed(InputControl, Single)
    InputControlExtensions.IsActuated(InputControl, Single)
    InputControlExtensions.ReadValueAsObject(InputControl)
    InputControlExtensions.ReadValueIntoBuffer(InputControl, Void*, Int32)
    InputControlExtensions.ReadDefaultValueAsObject(InputControl)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.ReadValueFromEventAsObject(InputControl, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr)
    InputControlExtensions.ReadUnprocessedValueFromEvent<TValue>(InputControl<TValue>, InputEventPtr, out TValue)
    InputControlExtensions.WriteValueFromObjectIntoEvent(InputControl, InputEventPtr, Object)
    InputControlExtensions.WriteValueIntoState(InputControl, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, TValue, Void*)
    InputControlExtensions.WriteValueIntoState<TValue>(InputControl<TValue>, Void*)
    InputControlExtensions.WriteValueIntoState<TValue, TState>(InputControl<TValue>, TValue, ref TState)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl, TValue, InputEventPtr)
    InputControlExtensions.WriteValueIntoEvent<TValue>(InputControl<TValue>, TValue, InputEventPtr)
    InputControlExtensions.CheckStateIsAtDefault(InputControl)
    InputControlExtensions.CheckStateIsAtDefault(InputControl, Void*, Void*)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl)
    InputControlExtensions.CheckStateIsAtDefaultIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareStateIgnoringNoise(InputControl, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*, Void*)
    InputControlExtensions.CompareState(InputControl, Void*, Void*)
    InputControlExtensions.HasValueChangeInState(InputControl, Void*)
    InputControlExtensions.HasValueChangeInEvent(InputControl, InputEventPtr)
    InputControlExtensions.GetStatePtrFromStateEvent(InputControl, InputEventPtr)
    InputControlExtensions.ResetToDefaultStateInEvent(InputControl, InputEventPtr)
    InputControlExtensions.QueueValueChange<TValue>(InputControl<TValue>, TValue, Double)
    InputControlExtensions.FindControlsRecursive<TControl>(InputControl, IList<TControl>, Func<TControl, Boolean>)
    Back to top Copyright © 2022 Unity Technologies
    Generated by DocFX
    on Wednesday, January 5, 2022
    Terms of use