docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Class GestureRecognizer<T>

    The base class for concrete gesture recognizers.

    A gesture recognizer decouples the logic for recognizing a sequence of touches (or other input) and acting on that recognition. When one of these objects recognizes a common gesture or, in some cases, a change in the gesture, it sends an action message to each designated target object.

    Inheritance
    object
    GestureRecognizer<T>
    PinchGestureRecognizer
    Implements
    IGestureRecognizer
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Unity.AppUI.Core
    Assembly: Unity.AppUI.dll
    Syntax
    public abstract class GestureRecognizer<T> : IGestureRecognizer
    Type Parameters
    Name Description
    T

    The type of value the gesture recognizer will output when the gesture is recognized. Very often this value will be of type Vector2 or float.

    Properties

    hasChangedThisFrame

    Whether the gesture recognizer state or outgoing value has changed this frame.

    Declaration
    public bool hasChangedThisFrame { get; protected set; }
    Property Value
    Type Description
    bool

    state

    The current state of the gesture recognizer.

    The possible states a gesture recognizer can be in are represented by the values of type.

    GestureRecognizerState.

    Some of these states aren’t applicable to discrete gestures.

    Declaration
    public GestureRecognizerState state { get; set; }
    Property Value
    Type Description
    GestureRecognizerState

    value

    The current value of type T for the gesture recognizer.

    Concrete implementations of gesture recognizers should set this value when the gesture is recognized. Very often this value will be of type Vector2 or float.

    Declaration
    public T value { get; protected set; }
    Property Value
    Type Description
    T

    Methods

    Recognize(ReadOnlySpan<AppUITouch>)

    Main method to recognize a gesture.

    A concrete implementation of a gesture recognizer should override this method to recognize a gesture. The implementation should also assume that this method will be called every frame.

    Declaration
    public virtual void Recognize(ReadOnlySpan<AppUITouch> appuiTouches)
    Parameters
    Type Name Description
    ReadOnlySpan<AppUITouch> appuiTouches

    The current touch inputs for the current frame.

    Remarks

    Sometimes, touch inputs can be lost from a frame to another (no AppUITouch event with an Ended or Canceled phase will be sent). The concrete implementation must aknowledge this and reset its state accordingly.

    Reset()

    Resets the gesture recognizer to its initial state.

    Declaration
    public virtual void Reset()

    Implements

    IGestureRecognizer
    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)