FingerGestures Upgrade Guide (v1.4 to v2.0)


Some major changes introduced in FingerGestures 2.0 have broken backward compatibility with previous versions in some parts of the library. This document details the areas impacted, and how to restore functionality.

Gesture Settings

In previous versions of FingerGestures, the gesture settings (such as drag threshold, long-press duration, required tap count, tap move tolerance…) were globally defined in the FingerGestures instance (MouseGestures or TouchGestures prefabs). This is no longer the case in FingerGestures 2.0: the old code that used to detect the various finger events and gestures has been broken down into various gesture recognizer scripts that are neatly self-contained and much more configurable than before.

On its default settings, FingerGestures 2.0 will automatically create default gesture recognizers for the most common gestures so you do not need to do it yourself. These default objects are instantiated from a list of gesture recognizer prefabs referenced by the FingerGestures.defaultPrefabs list object.  These default gesture prefabs are located in the FingerGestures\Prefabs\Components folder:

Explore the various gesture prefabs in this folder, and modify their settings at your convenience to match your original settings.

Events API Changes

As some of the event names and delegates signatures in the new version have changed:

  • FingerGestures.OnDragBegin was renamed to FingerGestures.OnFingerDragBegin
  • FingerGestures.OnDragMove was renamed to FingerGestures.OnFingerDragMove
  • FingerGestures.OnDragEnd was renamed to FingerGestures.OnFingerDragEnd
  • FingerGestures.OnTap was renamed to FingerGestures.OnFingerTap
  • FingerGestures.OnSwipe was renamed to FingerGestures.OnFingerSwipe
  • FingerGestures.OnLongPress was renamed to FingerGestures.OnFingerLongPress
As a consequence, you might get the following couple of errors after upgrading to the new version:
  • Error CS0123: A method or delegate `XXX’ parameters do not match delegate
  • Error CS0428: Cannot convert method group `XXX’ to non-delegate type `YYY’. Consider using parentheses to invoke the method
If that’s the case, do not panic! We have this under control. Simply perform a “Find and Replace” in the affected source files for the old “FingerGestures.OnXXX” events above and rename them to their new “FingerGestures.OnFingerXXX” version.

Here’s an example:

// FingerGestures v1.4
void OnEnable()
    FingerGestures.OnLongPress += YourEventHandler_OnLongPress;
    FingerGestures.OnTap += YourEventHandler_OnTap;
    FingerGestures.OnSwipe += YourEventHandler_OnSwipe;
    FingerGestures.OnDragBegin += YourEventHandler_OnDragBegin;
    FingerGestures.OnDragMove += YourEventHandler_OnDragMove;
    FingerGestures.OnDragEnd += YourEventHandler_OnDragEnd;

…should be converted to:

// FingerGestures v2.0
void OnEnable()
    FingerGestures.OnFingerLongPress += YourEventHandler_OnLongPress;
    FingerGestures.OnFingerTap += YourEventHandler_OnTap;
    FingerGestures.OnFingerSwipe += YourEventHandler_OnSwipe;
    FingerGestures.OnFingerDragBegin += YourEventHandler_OnDragBegin;
    FingerGestures.OnFingerDragMove += YourEventHandler_OnDragMove;
    FingerGestures.OnFingerDragEnd += YourEventHandler_OnDragEnd;

© 2012 Fatal Frog Software Suffusion theme by Sayontan Sinha