Search Unity

[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. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    Adding a collider2d to an UI image doesn't seem to work. The collider doesn't stretch with the canvas anyway. There's something in the button script that blocks the raycast from going further. I can set the button to not be interactable and it works still.
     
    LLZ_T likes this.
  2. bibloc

    bibloc

    Joined:
    Jan 31, 2018
    Posts:
    17
    In your OrbitAndPlaceObjects demo, there is a problem when you place two objects and try to move them when they are aligned.

    It seems that the raycast distance is ignored to determine which object should receive the gesture.
     
  3. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I will look into it bibloc
     
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    Hi, Been using Fingers on Android for a while fine. Just switched my build target to Windows and got the following error:

    > FingersScript.cs(1020,49): error CS0117: 'GestureRecognizer' does not contain a definition for 'MainThreadCallback'

    Checking, I found it's usually in GestureRecognizer around line 1542 however it's protected by:

    #if !PCL && !HAS_TASKS

    I've worked around for now by adding the same condition to the FingersScript code that uses it. That seems to work for now but I've not investigated whether there might be negative consequences.

    Thanks.

    p.s. I'm 1 version out of date in case that matters.
     
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Are you targeting uwp?
     
  6. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    655
    nope, PC standalone
     
  7. Totoro83y

    Totoro83y

    Joined:
    Sep 21, 2013
    Posts:
    21
    Hi, I'm using Fingers gladly since months (but just for specific tasks), but now I have a strange situation, probably because I miss something.

    My setup is somewhat complex. I have two different cameras, one for just screen space canvases, and one for everything else, managed by cinemachine (the ui camera is parented to this one).
    The non-ui camera has a physics raycaster, and I have a script to rotate and zoom the camera (with cinemachine) that uses fingers gestures pan and scale. I have some gameobjects that react to unity events with the physics raycaster (and I don't think that this is important, but these objects are instantiated at runtime in scene, they are not there from the start).
    I have a FingersScript in scene with "Add Auto Required Components" unflagged.

    All works exactly as I want, except that Fingers doesn't recognize that I'm interacting with the physics raycaster (but recognizes the canvases), and both the gestures are executed (I mean the one managed by Fingers and the one managed directly by unity).
    What am I missing?
     
    Last edited: Feb 18, 2020
  8. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    That is a tricky one, maybe post a video of the problem so I can understand better?
     
  9. Totoro83y

    Totoro83y

    Joined:
    Sep 21, 2013
    Posts:
    21
    I'm not in a hurry anymore because for some limitations in the UI events I have to rewrite the input of the objects in scene with Fingers, but just to understand better how it should be working, I made a video for you.

    As you can see if I enable CameraInput (that uses Fingers) I can move the camera. If I disable it I can normally drag my ball around. But if I enable CameraInput and try to drag the ball I drag both the camera and the ball.
    Probably I miss something in the setup of Fingers, I never tried to interact with an object with a physics raycaster and use Fingers at the sime time untill now, so I suppose it is a really simple setup I missed, but I don't know which one.
     
  10. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I would use one pan gesture for both camera movement / rotation and object dragging. You can do a raycast on the gesture when it begins. If the raycast hits an object you care to drag, start dragging the object. If not, start manipulating the camera. When the pan gesture ends, reset the state. Let me know if it makes sense.
     
  11. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Hey @jjxtra , I'm having issues with gestures propagating up the raycast hit list ignoring the "raycast target" checkbox completely. I have a UI with a bunch of stacked windows. A tap is being recognized not only by the topmost object I'm actually tapping on, but as well by all tap gesture recognizers down the raycast path. Adding intermediate sprites with raycast on doesn't help. Looks like something is broken, I would expect the propagation stop both in case of successful gesture recognition as well as just hitting a UI object with raycast target on.
     
  12. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Are you using a single gesture recognized?
     
  13. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Yep, no other gestures or any other pointer events handlers. Just a bunch of stacked UI Images with FingersTapGesture.
     
  14. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    If you are doing a raycast then only take the top object and ignore the rest.
     
  15. WildMaN

    WildMaN

    Joined:
    Jan 24, 2013
    Posts:
    128
    Sample project attached, w/o the plugin code

    Screenshot_4.jpg

    tap outside any squares doesn't produce any response - check
    tap on exclusively red/blue area registers a tap gesture on corresponding square - check
    tap on red area also covered by white square, which is raycast target enabled, still registers a tap - FAIL, should not register anything since white square is blocking and not having any gesture recognizer attached
    tap on area covered both by red and blue produces both red and blue responses in reversed order - first red then blue - FAIL, should register only blue
     

    Attached Files:

  16. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Does the white square have a collider on it?
     
  17. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    Hey, I'm using the FingersPanARComponentScript. I see a bug that pops up once in a while where I can't select another gameobject. It won't leave the previous selection. This bug seems to turn up on double or triple quick taps for deleting gameobjects or 3 finger touch. The 3 finger touch consistently turning up this bug.

    I thought it might be this script below, where I commented out the line but The bug pops up again but less frequently but triple tap won't work.

    In another script, I do test a simple Input.GetTouch(0).phase on one gameobject. I hope that doesn't interfere with Fingers somehow.

    Code (CSharp):
    1.         private Transform SelectCurrentTarget(float x, float y)
    2.         {
    3.             if (EventSystem.current == null)
    4.             {
    5.                 Debug.LogError(GetType().Name + " requires an EventSystem in the scene");
    6.                 return null;
    7.             }
    8.             else if (currentTarget != null)
    9.             {
    10.                //return currentTarget;
    11.                //*******************   bug of sticking to one target???
    12.             }
    13.  
    14.             PointerEventData data = new PointerEventData(EventSystem.current);
    15.             data.position = new Vector2(x, y);
    16.             raycastResults.Clear();
    17.             EventSystem.current.RaycastAll(data, raycastResults);
    18.  
    19.             foreach (RaycastResult result in raycastResults)
    20.             {
    21.          
    22.                 foreach (Transform t in Targets)
    23.                 {
    24.                     if (result.gameObject.transform == t)
    25.                     {
    26.                         return (currentTarget = t);
    27.                     }
    28.                 }
    29.             }
    30.             return null;
    31.         }

    I also added a custom fingers function.
    Code (CSharp):
    1.  
    2.             PanUpGesture = new PanGestureRecognizer();
    3.             PanUpGesture.MaximumNumberOfTouchesToTrack = 2;
    4.             PanUpGesture.MinimumNumberOfTouchesToTrack = 2;
    5.             PanUpGesture.StateUpdated += PanUpGestureStateUpdated;
    6.             PanUpGesture.AllowSimultaneousExecution(ScaleGesture);
    7.             PanUpGesture.AllowSimultaneousExecution(RotateGesture);
    8.             FingersScript.Instance.AddGesture(PanUpGesture);
    9.  
    10.  
    11.   private void PanUpGestureStateUpdated(GestureRecognizer gesture)
    12.         {
    13.             if (currentTarget == null && gesture.State == GestureRecognizerState.Began)
    14.             {
    15.                 SelectCurrentTarget(gesture.FocusX, gesture.FocusY);
    16.                 PushGesture(gesture);
    17.                 //Debug.Log("Pan up: " + gesture);
    18.             }
    19.             else if (currentTarget != null && gesture.State == GestureRecognizerState.Executing && orbitTarget == null)
    20.             {
    21.               //move obj up!!!!!
    22.                 Vector3 up = Camera.transform.up;
    23.                 up.x = 0.0f;
    24.                 up.z = 0.0f;
    25.                 up = up.normalized;
    26.              
    27.                 currentTarget.Translate(up * gesture.DeltaY * Time.deltaTime * SpeedUp, Space.World);
    28.                 //Debug.Log("Pan up: " + currentTarget+":"+ forward); // forward is 0,0,0
    29.             }
    30.             else if (gesture.State == GestureRecognizerState.Ended)
    31.             {
    32.                 PopGesture(gesture);
    33.             }
    34.         }
    35.  
     
    Last edited: Mar 22, 2020
  18. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I'll have a look and get back...
     
  19. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Does changing this method help?

    Code (CSharp):
    1.  
    2. private void PushGesture(GestureRecognizer gesture)
    3. {
    4.     if (!gestures.Contains(gesture))
    5.     {
    6.         gestures.Add(gesture);
    7.     }
    8. }
    9.  
     
  20. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    Still a problem.
    I think I found the bug. Anytime there is a long press on an object (without moving), the bug shows up.
    There is a longpress function. I'll mess with it for now.

    Code (CSharp):
    1.  private void LongPressGestureStateUpdated(GestureRecognizer gesture)
    2.         {
    3.             if (gesture.State == GestureRecognizerState.Began)
    4.             {
    5.                 //Debug.Log("Long tap on fingers pan ar component script began");
    6.                 //get called all the time when pressing button
    7.                 SelectCurrentTarget(gesture.FocusX, gesture.FocusY);
    8.                 PushGesture(gesture);
    9.                 if (LongPressGestureBegan != null)
    10.                 {
    11.                     LongPressGestureBegan.Invoke(this);
    12.                 }
    13.                 gesture.Reset();
    14.             }
    15.             else if (gesture.State == GestureRecognizerState.Ended)
    16.             {
    17.                 PopGesture(gesture);
    18.             }
    19.         }

    *****************update

    Yup, this is the problem. I commented out the add event and registry of this function, the bug is gone.
     
    Last edited: Mar 23, 2020
  21. umiringo73

    umiringo73

    Joined:
    Apr 18, 2017
    Posts:
    13
    Hi, I used your great asset to create my game.
    But recently, I got a issue about admob native advanced.
    When I create a native ads in my game, while I enable fingers, the clicking of ads will be disabled.
    I want to know if anyone has used this asset and admob native ads together?
    Thank you
     
  22. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Fingers shouldn't effect Unity admob module. How does admob register clicks? Does removing fingers gestures from your game fix it?
     
  23. magarcan

    magarcan

    Joined:
    Sep 25, 2012
    Posts:
    34
    Just playing with DemoSceneImageRecognition.

    I have noticed that a lot of time passes from the moment the gesture is recognized until the lines are cleared and you can draw again.

    Can you adjust it, or is it the time it takes the script to run?
     
  24. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Something is ignoring gestures for about a second, it's not an issue with computing the shape. I will send an update of same version, try downloading it again in about an hour.
     
  25. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Ok I sent a new update that fixes the issue. Download it in about 10 minutes. Let me know how it goes!
     
  26. drjamiearron

    drjamiearron

    Joined:
    Jun 8, 2012
    Posts:
    134
    Hi there, is it possible to capture a "double/multi swipe" gesture? For example, let's say you are playing a game in portrait mode, and using both thumbs on either side of the screen the player swipes both thumbs upwards - can your plugin detect this?
     
  27. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    You can set min and max touches required to two on the swipe gesture. Or if you want to allow 1 OR 2 fingers, set min touches required to 1 and max to 2. Then in the callback you can examine the current tracked touches property to see if it's one or two and do different logic.
     
  28. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    Hi,I have a question about long press gesture. I want to record up to 2 long press touches simultaneously but I struggle to find the right way.
    I've tried to set MaximumNumberOfTouchesToTrack = 2, but when I release one of my two long touches, the gesture goes in ended state, and the touches count drop to 0 (instead of 1). If I release the other touch the gesture execute another ended state. Nothing in between. I think it's just a bug.

    In particular, what I want to achieve is moving a character by long pressing on the right or left screen. The problem is that the user can accidentally put the other finger on before releasing the first one. So I need to track both touches and keep executing the last one active.

    Any suggestion?

    PS: sorry for my bad english, and thanks for very well designed plugin :)
     
  29. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Seems like two long press gestures should work. Set them to execute simultaneously with each other.
     
  30. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    I tried many combinations. Two different long press gestures allowed to execute simultaneously, with 2 touches tracked, with 1 touches tracked, one gesture allowed to execute simultaneosly with itself. Nothing works properly. I have only long press gestures implemented in code, no taps or other gestures.
     
  31. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    You could make two panels, one on each side of the screen in the area where the long press is allowed to start. Then assign the panel game object as the platform specific view property for each long press gesture. Then make sure the min and max touches for each long press are 1, and that they are NOT set to execute simultaneously with each other.
     
  32. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    Oh man, i found out the bug, it was pretty subtle. upload_2020-5-10_20-48-20.png
    upload_2020-5-10_20-48-31.png

    I manually set it to false and now everything works fine.

    Edit: to be clear, the doc states that the property is set to false by default, but for long press gesture at least is set to true, I didn't check other gestures.
     
  33. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I would suggest changing that to true outside the gesture, that way if you update the asset your changes don't get blown away. It is a public property so should be easy to change in your own script.
     
  34. Kidara

    Kidara

    Joined:
    Jul 6, 2017
    Posts:
    16
    It is set to true by you, not by me. This is the bug ahahah. I set it to false outside the constructor, accessing the public property in my code :D
     
  35. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Hmmm. I am guessing there is story there. My commit log shows simply that I migrated from my now deleted bitbucket account over a year ago, so I will resubmit with that line removed and see if people have any issues.
     
    Kidara likes this.
  36. Philkrom

    Philkrom

    Joined:
    Dec 26, 2015
    Posts:
    90
    Hello
    I just bought your asset, you have a lot of demo scenes I tried the DemoSceneFirstPersonController but I am looking for a FPC with a "divided screen" like in this video :

    On the left side, a virtual joystick to move front back right left (with left thumb), and on the right side the rotation, with the right thumb.

    Maybe it has another name in one of your demoscenes ? Or I have to combine 2 scenes ? I didn't try all of them.

    Best regards
    Phil
     
  37. mistergreen2016

    mistergreen2016

    Joined:
    Dec 4, 2016
    Posts:
    226
    You can download unity's crossplatform mobile input asset for free.
     
  38. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    There is a virtual joystick component, and then you can use a pan gesture on the other side, and set them to execute simultaneously with each other.
     
  39. gareth_untether

    gareth_untether

    Joined:
    Jan 5, 2018
    Posts:
    69
    When I stop the editor from playing I receive this error:

    Code (CSharp):
    1. Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?)
    2. The following scene GameObjects were found:
    3. Touch16
    4. Touch9
    5. FingersScriptPrefab(Clone)
    6. TouchesCanvas
    7.  
    8. ... Touch objects continues to Touch30
    9.  
    10.  
    11.  
    Could it be something to do with this in FingersScript?

    Code (CSharp):
    1.         /// <summary>
    2.         /// Check whether Instance is not null without it actually creating a prefab if needed
    3.         /// Call this when removing the gestures in OnDisable to avoid creating a prefab in OnDestroy methods and causing lots of errors
    4.         /// </summary>
    5.         public static bool HasInstance { get { return singleton != null; } }
     
  40. gareth_untether

    gareth_untether

    Joined:
    Jan 5, 2018
    Posts:
    69
    Response from the Jeff @ Ruby:

    The pattern for OnDisable is:
    Code (CSharp):
    1.  
    2.  
    3. void OnDisable ()
    4. {
    5.     if (FingersScript.HasInstance)
    6.     {
    7.         // cleanup gestures
    8.     }
    9. }
    In cleanup gestures add FingersScript.Instance.RemoveGesture(the gesture you added);[/QUOTE]
     
  41. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Hi Jeff

    I have a Tap gesture on a canvas which all works fine.

    However now I have some UI buttons which I would like to block this Tap gesture i.e. so when I click the button it does not register the Tap.

    I have been through all the samples and looked through this forum, scanned the docs, but it is not clear to me how I can setup this simple use-case.

    Please can you advise how I can do this?


    thanks

    Nalin
     
  42. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Buttons should block the gesture by default. Did you set the canvas as the PlatformSpecificView of the tap gesture? If so you will need to remove that as it will allow the tap anywhere on the canvas.
     
  43. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    Buttons should block the gesture by default
    That's what I was hoping, but its not working for me :(

    Below is my TapGesture setup on the Canvas.

    Do I need to do something specific with the Button?

    FingersTapGesture.png
     
  44. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    Hmmm. That looks ok. So your tap gesture is firing when it happens on buttons? Can you send a small repro project to support@digitalruby.com, want to rule out a bug here...
     
  45. puzzlekings

    puzzlekings

    Joined:
    Sep 6, 2012
    Posts:
    404
    So your tap gesture is firing when it happens on buttons?

    Yes, I built a test project which is on its way to you now.

    I tracked down what is causing the problem and it seems that the "Gesture View" being set to something seems to make this happen. If it's null then only the button fires which is correct, otherwise both events fire!

    N
     
  46. DeJMan

    DeJMan

    Joined:
    Nov 26, 2013
    Posts:
    5
    Hi.

    I have 2 orthographic cameras side by side outputting to display 1 and 2 respectively.

    There are sprites scattered across both displays with FingersPanRotateScale components attached to them. However, on a build, the touches are triggered only on the primary display.

    Do you know of a way to fix this?

    Thanks.
     
  47. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    I am not sure if Unity supports touches on multiple monitors. I would reach out to them first.
     
    DeJMan likes this.
  48. LLZ_T

    LLZ_T

    Joined:
    Apr 22, 2020
    Posts:
    8
    Hello,

    In your DemoScene, there is a scroll view with a NoPassThrough button and a bunch of PassThrough buttons. They appear to be identical and yet the NoPassthrough button doesn't change gesture state. I am trying to figure out how you have set them up to block or not block gestures. I also don't see any Gesture scripts in the scene so I'm a little lost as to how they are being differentiated. Any help would be appreciated.

    Thanks.
    Screenshot_1.png
     
  49. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,464
    DemoScript.cs sets it all up. Let me know if you have trouble finding it.
     
  50. LLZ_T

    LLZ_T

    Joined:
    Apr 22, 2020
    Posts:
    8
    I apologize, it was staring me in the face. The CaptureGestureHandler registration with FingerScript looks like it will be just the ticket. Thank you!
     
    jjxtra likes this.