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.
Implements
Inherited Members
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.
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(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(AppUITouch[] appuiTouches)
Parameters
Type | Name | Description |
---|---|---|
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()