docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GestureRecognizer<T>

    A Gesture Recognizer processes touch input to determine if a gesture should start and fires an event when the gesture is started.

    Inheritance
    object
    GestureRecognizer<T>
    DragGestureRecognizer
    PinchGestureRecognizer
    TapGestureRecognizer
    TwistGestureRecognizer
    TwoFingerDragGestureRecognizer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: UnityEngine.XR.Interaction.Toolkit.AR
    Assembly: Unity.XR.Interaction.Toolkit.dll
    Syntax
    public abstract class GestureRecognizer<T> where T : Gesture<T>
    Type Parameters
    Name Description
    T

    The actual gesture.

    Remarks

    To determine when a gesture is finished/updated, listen to events on the Gesture<T> object.

    Properties

    gestures

    List of current active gestures.

    Declaration
    protected List<T> gestures { get; }
    Property Value
    Type Description
    List<T>
    Remarks

    Gestures must be added or removed using AddGesture(T) and RemoveGesture(T) rather than by directly modifying this list. This list should be treated as read-only.

    See Also
    AddGesture(T)
    RemoveGesture(T)

    raycastMask

    Gets or sets layer mask used for limiting ray cast targets.

    Declaration
    public LayerMask raycastMask { get; set; }
    Property Value
    Type Description
    LayerMask

    raycastTriggerInteraction

    Gets or sets type of interaction with trigger colliders via ray cast.

    Declaration
    public QueryTriggerInteraction raycastTriggerInteraction { get; set; }
    Property Value
    Type Description
    QueryTriggerInteraction
    Remarks

    When set to UseGlobal, the value of Queries Hit Triggers (queriesHitTriggers) in Edit > Project Settings > Physics will be used.

    xrOrigin

    The Unity.XR.CoreUtils.XROrigin that will be used by gestures (such as to get the Camera or to transform from Session space).

    Declaration
    public XROrigin xrOrigin { get; set; }
    Property Value
    Type Description
    XROrigin

    Methods

    AddGesture(T)

    Add the given gesture to be managed so that it can be updated during Update().

    Declaration
    protected void AddGesture(T gesture)
    Parameters
    Type Name Description
    T gesture

    The gesture to add.

    See Also
    RemoveGesture(T)

    RemoveGesture(T)

    Remove the given gesture from being managed. After being removed, it will no longer be updated during Update().

    Declaration
    protected void RemoveGesture(T gesture)
    Parameters
    Type Name Description
    T gesture

    The gesture to remove.

    See Also
    AddGesture(T)

    TryCreateGestures()

    Try to recognize and create gestures.

    Declaration
    protected abstract void TryCreateGestures()

    TryCreateOneFingerGestureOnTouchBegan(Func<Touch, T>, Action<T, Touch>)

    Helper function for creating or reinitializing one-finger gestures when a touch begins.

    Declaration
    protected void TryCreateOneFingerGestureOnTouchBegan(Func<Touch, T> createGestureFunction, Action<T, Touch> reinitializeGestureFunction)
    Parameters
    Type Name Description
    Func<Touch, T> createGestureFunction

    Function to be executed to create the gesture if no dead gesture was available to re-initialize.

    Action<T, Touch> reinitializeGestureFunction

    Function to be executed to re-initialize the gesture if a dead gesture was available to re-initialize.

    TryCreateOneFingerGestureOnTouchBegan(Func<Touch, T>, Action<T, Touch>)

    Helper function for creating or re-initializing one-finger gestures when a touch begins.

    Declaration
    protected void TryCreateOneFingerGestureOnTouchBegan(Func<Touch, T> createGestureFunction, Action<T, Touch> reinitializeGestureFunction)
    Parameters
    Type Name Description
    Func<Touch, T> createGestureFunction

    Function to be executed to create the gesture if no dead gesture was available to re-initialize.

    Action<T, Touch> reinitializeGestureFunction

    Function to be executed to re-initialize the gesture if a dead gesture was available to re-initialize.

    TryCreateTwoFingerGestureOnTouchBegan(Func<Touch, Touch, T>, Action<T, Touch, Touch>)

    Helper function for creating two-finger gestures when a touch begins.

    Declaration
    protected void TryCreateTwoFingerGestureOnTouchBegan(Func<Touch, Touch, T> createGestureFunction, Action<T, Touch, Touch> reinitializeGestureFunction)
    Parameters
    Type Name Description
    Func<Touch, Touch, T> createGestureFunction

    Function to be executed to create the gesture if no dead gesture was available to re-initialize.

    Action<T, Touch, Touch> reinitializeGestureFunction

    Function to be executed to re-initialize the gesture if a dead gesture was available to re-initialize.

    TryCreateTwoFingerGestureOnTouchBegan(Func<Touch, Touch, T>, Action<T, Touch, Touch>)

    Helper function for creating or re-initializing two-finger gestures when a touch begins.

    Declaration
    protected void TryCreateTwoFingerGestureOnTouchBegan(Func<Touch, Touch, T> createGestureFunction, Action<T, Touch, Touch> reinitializeGestureFunction)
    Parameters
    Type Name Description
    Func<Touch, Touch, T> createGestureFunction

    Function to be executed to create the gesture if no dead gesture was available to re-initialize.

    Action<T, Touch, Touch> reinitializeGestureFunction

    Function to be executed to re-initialize the gesture if a dead gesture was available to re-initialize.

    Update()

    Instantiate and update all gestures.

    Declaration
    public void Update()

    Events

    onGestureStarted

    Calls the methods in its invocation list when a gesture is started. To receive an event when the gesture is finished/updated, listen to events on the Gesture<T> object.

    Declaration
    public event Action<T> onGestureStarted
    Event Type
    Type Description
    Action<T>
    In This Article
    Back to top
    Copyright © 2025 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)