Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

[NEW UPDATE!] Fingers - Touch Gestures - #1 in Quality, Support and Features : Dozens of Gestures✓

Discussion in 'Assets and Asset Store' started by jjxtra, Apr 25, 2016.

  1. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Greetings! This thread is for the asset "Fingers - Touch Gestures for Unity".

    --> Download Fingers From the Unity Asset Store <--

    Fingers is your one stop choice for all gesture handling in Unity (and other C# platforms as Fingers has no Unity specific code). Fingers has been tested and runs great on MAC, Windows, iOS and Android. Full C# source code and shader code is provided!

    With Fingers, you get all the common touch gestures you are used to built in. This includes: tap, double tap, long tap, pan, rotate, scale and swipe gestures. In addition, creating your own custom gestures is simple and easy.

    I've recently began adding on-screen controls. Right now a joystick and dpad are included with more controls planned for the future.

    Adding gestures in the inspector has never been easier. Simply add from the component menu and configure your gesture. Set the callback to your script and you are done!

    Pan/rotate/scale and drag and drop is simple. Built in scripts for these scenarios, with demo scenes are provided.

    I've also added image recognition gestures. With a few minutes of tweaking, you can recognize shapes like circles, lightning bolts, check marks and the letter X.

    Previewing gestures in the player is easy, even without a touch screen. Just use the shift and control key plus mouse wheel to simulate pinch and rotate gestures, along with each button to simulate a different finger.

    Fingers has a similar architecture to UIGestureRecognizer from iOS, but is built using all C# code and will easily run on any platform that has a mouse or touch screen.

    Gestures are restricted to most UI elements by default, but this is easily configured if you want the gestures to pass through additional UI elements. This asset works great with the default Unity UI and Event System.

    Gestures can be executed simultaneously or exclusively (the default). In addition, gestures can require other gestures to fail (such as a tap requiring a double tap to fail).

    Fingers requires knowledge of C# and Unity scripting to integrate, but the number of lines of code to get up and running should be minimal. A demo scene and script is provided to show you how the gestures work.

    Fingers uses inches by default to measure distances for certain thresholds, but this can be changed via properties on the gestures.

    When using Fingers with Unity Remote, you may want to temporarily disable mouse handling via script property.

    Please see the included Readme.txt file and demo script for a more in-depth guide.

    This code works great even outside of Unity. For example, I am using this code for a Xamarin Android drawing app (You Doodle) instead of the native Android gestures! Fingers gestures framework does not contain any Unity specific code so the framework will run great anywhere C# is supported. If you want this in Xamarin, you just have to write the adapter to send touch events.

    I've included my Xamarin Android touch adapter code in the Readme.txt file at the bottom.

    --> Download Fingers From the Unity Asset Store <--
     
    Last edited: Nov 27, 2017
  2. theANMATOR2b

    theANMATOR2b

    Joined:
    Jul 12, 2014
    Posts:
    7,781
    seems the link isn't correct jjxtra
     
  3. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Looks like a special character got in there when I copied and pasted the URL. Thanks for the heads up.
     
    theANMATOR2b likes this.
  4. the-major-tom

    the-major-tom

    Joined:
    Sep 26, 2014
    Posts:
    1
    Hi, I have some questions about Fingers: I need use two fingers to move an object on Y axis (to simulate up and down movement) and one finger to move on X and Z axis, is that possible?
     
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Should be. You could use a pan gesture for this with maximum allowed touches of 2. Can these two gestures execute simultaneously?
     
  6. mihaicatalind

    mihaicatalind

    Joined:
    Jan 12, 2015
    Posts:
    10
    Hi! I have an issue with this pack.. I put a custom gesture on the scene.. a "D" letter. After that I put in the script: if "D" is recognized to jump to another scene..if I write a "D" on the screen is working.. the scene change to what I want to. after that when I come back to the D recognizing scene, the script isn't work anymore. Nothing happening when I write a gesture, not even tty again ... Any ideea how to fix this ? Thanks
     
  7. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    When you change scenes, gestures are cleared. I think there is a bool property you can set on the FingersScript to keep the gestures even when changing scenes.
     
  8. mihaicatalind

    mihaicatalind

    Joined:
    Jan 12, 2015
    Posts:
    10
    Hi jjxtra, I solved the problem by adding the reset code before the command:

    Image.texture = t;
    lastImage = imageGesture.Image.Clone();

    if (imageGesture.MatchedGestureImage == null)
    {
    MatchLabel.text = "PLEASE TRY AGAIN";
    }
    else
    {
    //MatchLabel.text = "GOOD, YOU DREW : " + recognizableImages[imageGesture.MatchedGestureImage] ;
    imageGesture.Reset();
    ResetLines();
    UpdateImage();

    Application.LoadLevel("Pachet_gri_content");

    }

    Thank you. Now it works awesome!
     
  9. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Glad it's working! Send a link to your game when it's ready to test!
     
  10. Arctous

    Arctous

    Joined:
    Aug 25, 2014
    Posts:
    14
    In your demo you had UI elements labeled "Touches Pass Through..." and "I Eat Touches". What determines the passthrough and the consumption of the touches? How does it react when you have one finger on and one finger off of the "I Eat Touches"? Thanks!
     
  11. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    The I eat touches button will not allow the touch to pass through to gestures. So that finger would have to release and start somewhere else to be part of a gesture. The script has several ways to determine which Ui elements block touches and which allow them to be part of gestures. All of this is demonstrated in a demo scene.
     
  12. Arctous

    Arctous

    Joined:
    Aug 25, 2014
    Posts:
    14
    Great! Thanks for the reply. I was concerned that you were relying on the default behavior of Unity touches (which is a bit questionable).
     
  13. blacksun666

    blacksun666

    Joined:
    Dec 17, 2015
    Posts:
    135
    just wondering what sort of latency you are seeing with your library? Mainly interested in tap, long tap and double tap. I understand it would depend on phone model and OS but do you have any figures?
     
  14. Samuel-Karlos

    Samuel-Karlos

    Joined:
    Sep 26, 2015
    Posts:
    3
    I want to report a bug in the DemoScene: when i rotate the object using two fingers it works as expected, but when i remove just one finger and put it again, i expect detect that i could resize the objet again, but it doesnt work.
    Here is a video, showing the bug.
     

    Attached Files:

  15. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Latency for tap and double tap is configurable. You specify the amount of time that must pass before the double tap fails.
     
  16. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    This is currently by design. The gesture ends when you release the one finger. In order to start again, it needs two new fingers.
     
  17. Samuel-Karlos

    Samuel-Karlos

    Joined:
    Sep 26, 2015
    Posts:
    3
    I updated the project and with that I was able to solve the problem, besides I put it in Start:

    void Start()
    {
    TreatMousePointerAsFinger=false;
    SimulateMouseWithTouches=true;
    }

    With that the problem has been solved, more thanks!
     
    jjxtra likes this.
  18. tomraegan

    tomraegan

    Joined:
    Mar 28, 2016
    Posts:
    95
    Hi Jeff.

    I noticed in your youtube clip you successfully drawn an X. I was wondering how you achieved it. When I release (in the demo scene) after drawing the first line, the image is a recognised before I can complete add the second stroke.

    Thanks kindly.
     
  19. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    You can use DemoSceneImage or raise MaximumPathCount to 2 on the image gesture.
     
  20. tomraegan

    tomraegan

    Joined:
    Mar 28, 2016
    Posts:
    95
    Wow. Fast response. Much obliged.
     
    jjxtra likes this.
  21. nicky-hochmuth

    nicky-hochmuth

    Joined:
    Jun 23, 2016
    Posts:
    3
    Hi Jeff

    thx for the good plugin.
    I wounder if there is a setting or way how to disable the modifier key CTRL for the default zooming behavior. I would like to trigger the scaling without CTRL only by mouse wheel in addition to the touch pinching.

    Thanks
    Nicky
     
  22. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    In the demo, you can modify the script and remove the Ctrl check. Let me know if you have trouble finding it.
     
  23. nicky-hochmuth

    nicky-hochmuth

    Joined:
    Jun 23, 2016
    Posts:
    3
    Hi Jeff
    you mean i should edit the ProcessMouseWheel method in FingerScrips.cs?
    Or did i miss a obvious flag somewhere?
    Nicky
     
  24. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    In FingersScript in the ProcessMouseWheel method there are Input.GetKey... calls. You would just take these out. If you do this, you will need to remove the code that does rotation when the mouse wheel plus shift is pressed.
     
  25. nicky-hochmuth

    nicky-hochmuth

    Joined:
    Jun 23, 2016
    Posts:
    3
    Hi Jeff
    without the key down and up it is hard to determine when to start and stop an zoom action. If i do not stop it correct it will block other recognizers. Any advises would be very welcome.

    Nicky
     
  26. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    You would have to check if the previous mouse wheel is 0 and then start scale and then if the previous is not zero and current is not zero it is scaling and then if the previous is not 0 and current is 0 then it stops scaling.
     
  27. Tropobor

    Tropobor

    Joined:
    Mar 24, 2014
    Posts:
    42
    With the latest release: 1.5.1. It seems to miss some elements in DemoScenePan so that it is understandable. Thanks!
     
  28. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Can you elaborate? If you think there's a bug I'd like to fix it so please provide as many details as possible.
     
  29. Tropobor

    Tropobor

    Joined:
    Mar 24, 2014
    Posts:
    42
    In a fresh project, if I open DemoScenePan scene and hit play there is just nothing to see or interact with in game view.
     
  30. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Correct. That one just logs debug messages.
     
    Tropobor likes this.
  31. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    Hi Jeff,

    I'm enjoying your Fingers library. It was working before, but now it is not. I think I've decoupled something and after a few hours debugging I've not figured out what it is.

    I have an object that calls FingersScript.CreateSingletonFromPrefabIfNeeded and then sets up some gestures. That seems to work fine.

    Also the Debug.Log statements from Fingers show that the mouse scroll wheel is indeed being detected.

    The problem is that my callbacks are never called. For example you see in ScaleGestureCallback that I'm logging every time it is called, but it never gets called.

    Any ideas what I broke? :)

    Here is the pertinent code, which is mostly copied from your demo scene.

    Code (CSharp):
    1.  
    2. using DigitalRubyShared;
    3. using System.Collections.Generic;
    4. using UnityEngine;
    5.  
    6. public class TouchController : MonoBehaviour {
    7.  
    8.     /// <summary>
    9.     /// The camera to control, if different from Camera.main
    10.     /// </summary>
    11.     public Camera Cam;
    12.  
    13.     public GameObject FingersScriptPrefab;
    14.  
    15.     public float PinchSensitivity = 2f;
    16.  
    17.     private PlayerController _playerController = null;
    18.  
    19.     private TapGestureRecognizer tapGesture;
    20.     private PanGestureRecognizer panGesture;
    21.     private ScaleGestureRecognizer scaleGesture;
    22.  
    23.     private void DebugText(string text, params object[] format)
    24.     {
    25.         //bottomLabel.text = string.Format(text, format);
    26.         Debug.Log(string.Format(text, format));
    27.     }
    28.  
    29.     private GestureTouch FirstTouch(ICollection<GestureTouch> touches)
    30.     {
    31.         foreach (GestureTouch t in touches)
    32.         {
    33.             return t;
    34.         }
    35.         return new GestureTouch();
    36.     }
    37.  
    38.     private void TapGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
    39.     {
    40.         if (gesture.State == GestureRecognizerState.Ended)
    41.         {
    42.             GestureTouch t = FirstTouch(touches);
    43.             DebugText("Tapped at {0}, {1}", t.X, t.Y);
    44.         }
    45.     }
    46.  
    47.     private void CreateTapGesture()
    48.     {
    49.         tapGesture = new TapGestureRecognizer();
    50.         tapGesture.Updated += TapGestureCallback;
    51.         FingersScript.Instance.AddGesture(tapGesture);
    52.     }
    53.  
    54.     private void PanGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
    55.     {
    56.         if (gesture.State == GestureRecognizerState.Executing)
    57.         {
    58.             GestureTouch t = FirstTouch(touches);
    59.             DebugText("Panned, {0}, {1}, {2}, {3}, {4}, {5}", t.X, t.Y, t.DeltaX, t.DeltaY, panGesture.DeltaX, panGesture.DeltaY);
    60.  
    61.             float deltaX = panGesture.DeltaX / 25.0f;
    62.             float deltaY = panGesture.DeltaY / 25.0f;
    63.  
    64.             if (!_playerController) {
    65.                 var player = GameObject.FindGameObjectWithTag ("Player");
    66.                 if (player)
    67.                     _playerController = player.GetComponent<PlayerController> ();
    68.             }
    69.  
    70.             if (_playerController)
    71.                 _playerController.Turn (deltaX, deltaY);
    72.         }
    73.     }
    74.  
    75.     private void CreatePanGesture()
    76.     {
    77.         panGesture = new PanGestureRecognizer();
    78.         panGesture.Updated += PanGestureCallback;
    79.         FingersScript.Instance.AddGesture(panGesture);
    80.     }
    81.  
    82.     private void ScaleGestureCallback(GestureRecognizer gesture, ICollection<GestureTouch> touches)
    83.     {
    84.         DebugText("Scale " + gesture.State +": {0}, Focus: {1}, {2}", scaleGesture.ScaleMultiplier, scaleGesture.FocusX, scaleGesture.FocusY);
    85.  
    86.         if (gesture.State == GestureRecognizerState.Executing)
    87.         {
    88.             // On my Razer mouse:
    89.             //
    90.             // scaleGesture.ScaleMultiplier = 0.92 == scroll forward
    91.             // scaleGesture.ScaleMultiplier = 1.08 == scroll backward
    92.  
    93.             var cam = Cam ? Cam : Camera.main;
    94.             var cc = cam ? cam.GetComponent<ICameraController> () : null;
    95.             if (cc != null)
    96.                 cc.Zoom ((1f - scaleGesture.ScaleMultiplier) * PinchSensitivity);
    97.         }
    98.     }
    99.  
    100.     private void CreateScaleGesture()
    101.     {
    102.         scaleGesture = new ScaleGestureRecognizer();
    103.         scaleGesture.Updated += ScaleGestureCallback;
    104.         scaleGesture.RequireGestureRecognizerToFail = panGesture;  // don't pan while scaling
    105.         FingersScript.Instance.AddGesture(scaleGesture);
    106.     }
    107.  
    108.     void Start ()
    109.     {
    110.         // we have set a prefab instance on this script - if we don't have a singleton of FingersScript yet,
    111.         // create an instance of the prefab and set it as the singleton. This allows the fingers script
    112.         // to live forever and eliminates the need to add the fingers script to every scene in your game.
    113.         // you should only have this logic in the first scene of your game, and it must be in the Start method.
    114.  
    115.         FingersScript.CreateSingletonFromPrefabIfNeeded(FingersScriptPrefab);
    116.  
    117.         CreateTapGesture();
    118.         CreatePanGesture();
    119.         CreateScaleGesture();
    120.  
    121.         Debug.Log ("Initialized TouchController");
    122.     }
    123. }
    124.  
    And here is what the log looks like: (The assertion errors are from UMA, unrelated to this)

     
  32. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    This all looks fine. Any chance you can send your project to support@digitalruby.com?
     
  33. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    Done, thanks Jeff.
     
  34. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Awesome, thanks. Will touch base tomorrow.
     
  35. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Most people are using this for 2D which is why this didn't come up. I've added code to ignore objects in the 3D scene, that way the gestures can pass through. This behavior can be overriden still, but seems like a pretty sensible default behavior. I'll get an update sent to Unity ASAP and a patch file sent to you.
     
    rossdp likes this.
  36. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    FYI If anyone else is dealing with Unity 5.6 bugs and wants the fix before version 1.5.2 of this asset hits the asset store, send me an email with your order id and I'll get you a patch.
     
  37. rossdp

    rossdp

    Joined:
    Apr 28, 2017
    Posts:
    19
    Thanks Jeff! :)

    EDIT: Installed the patch you sent, and it works! Thanks again! :)
     
    Last edited: May 11, 2017
  38. chichom27

    chichom27

    Joined:
    Jun 18, 2013
    Posts:
    3
    Hi! How can I cancel FingerDragDrop as soon as a second touch on screen is recorded?
     
  39. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Call "Reset" on any gesture to cancel it.
     
  40. Rodolinc

    Rodolinc

    Joined:
    Sep 23, 2013
    Posts:
    59
    Hi! is it possible to get information on what the tap gesture hit?
    thanks!
     
  41. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Of course, just do EventSystem.Current.RaycastAll and pass in the gesture FocusX and FocusY. Make sure you have setup the appropriate ray casters to your camera.
     
  42. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Just FYI I am submitting a patch to fix a silly null reference exception I introduced in the last update. Sorry about that...
     
  43. thargy

    thargy

    Joined:
    Jun 24, 2012
    Posts:
    6
    Is there a temporary workaround as my project is now broken.
     
  44. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    For anyone that wants a fix before Unity approves the next version, change the compile error line to:

    if ((platformSpecificView == null && EventSystem.current == null) ||
    (platformSpecificView != null && platformSpecificView.GetComponent<Canvas>() != null))
     
  45. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    The fix is live, thanks for your patience everyone!
     
  46. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Update the asset again to fix.
     
  47. davelance

    davelance

    Joined:
    Apr 28, 2017
    Posts:
    1
    Is Fingers tied to a particular camera in any way? It seems to stop hitting my callbacks when I switch to camera 2, but hits again when switching back to camera 1.
     
  48. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Probably. I haven't done much multi-camera testing. Is your project small enough that you could email it to me? Ideally the gestures would work pretty much out of the box with multiple cameras, at least for canvas or screen space elements anyway. Email me offline at support@digitalruby.com and I will try to help.
     
  49. Solid_Metal

    Solid_Metal

    Joined:
    Mar 25, 2015
    Posts:
    45
    good evening

    just got this plugin from unity store bundle, it works amazing, but i do have something to ask

    i want to change/implement the joystick to move to user's finger location, and instantly react/interact with it, while to move the button to user finger location is easy enough, but i until now can't make it to instantly interact with the joystick, need to tap it again to use it

    can you help with this?

    thank you in advance
     
  50. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    724
    Are you using the joystick from the asset or your own or another? Can you provide a little more detail?