Search Unity

[RELEASED] Easy Touch

Discussion in 'Assets and Asset Store' started by Hedgehog-Team, May 8, 2012.

  1. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    Yes my Ipad2 is on IOS7
     
  2. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    Titlis
    I don't understand why you manage a fake fingerIndex ?
     
  3. scrlklk

    scrlklk

    Joined:
    Dec 23, 2013
    Posts:
    8
    Hi, Hedgehog Team

    Cause i have a to send a bool at touchstart to tell the raycast script which controll the gun to start, i use the fake fingerindex to record which fingerindex is touch on freezone or joystick at the beginning, then at the on_touchup i check gesture.fingerindex == which finger, if its the finger controll the joystick then nothing happen, else if its the fingerindex which touch on freezone at touchstart, then return the bool to tell the script to stop controll the gun. Otherwise, if i dont do these stupid step, it sent the bool on any finger touchup. I know these is stupid,any suggestion pleasse

    Ps. I cant use isHoverReservedArea on drag, if the drag leave the joystick area it will recognize as freezone. So i saved which fingerindex controll what things at start.
     
    Last edited: Jan 21, 2014
  4. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi

    Titlis
    Is your joystick is dynamic?
     
  5. scrlklk

    scrlklk

    Joined:
    Dec 23, 2013
    Posts:
    8
    No, i haven't change any setting from default.

    I think the reason cant use isHoverReservedArea on drag, is On_drag keep updating the gesture.isHoverReservedArea, so when i leave the joystick area, it detected as a freezone.
     
    Last edited: Jan 22, 2014
  6. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Titlis,

    Ok, and I see that you use Drag event, not swipe event, it's mean that you have a big collider front of camera ?
     
  7. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi again,

    Titlis
    Can you try this one, I 'm using EasyJoystick event rather than EasyTouch event :

    Code (csharp):
    1.     private bool enableMoveGun = true;
    2.  
    3.     void OnEnable(){
    4.         EasyTouch.On_Swipe += On_Swipe;
    5.         EasyJoystick.On_JoystickTouchStart += On_JoystickTouchStart;
    6.         EasyJoystick.On_JoystickTouchUp += On_JoystickTouchUp;
    7.     }
    8.  
    9.     void OnDisable(){
    10.         UnsubscribeEvent();
    11.     }
    12.  
    13.     void OnDestroy(){
    14.         UnsubscribeEvent();
    15.     }
    16.  
    17.     void UnsubscribeEvent(){
    18.         EasyTouch.On_Swipe -= On_Swipe;
    19.         EasyJoystick.On_JoystickTouchStart -= On_JoystickTouchStart;
    20.         EasyJoystick.On_JoystickTouchUp -= On_JoystickTouchUp;
    21.     }    
    22.  
    23.  
    24.     void On_Swipe(Gesture gesture){
    25.        
    26.         if ((gesture.touchCount == 1  enableMoveGun) || (gesture.touchCount>1  !gesture.isHoverReservedArea)){
    27.             Debug.Log( "move gun");
    28.         }
    29.     }
    30.  
    31.  
    32.     void On_JoystickTouchStart(MovingJoystick move){
    33.         enableMoveGun = false;
    34.     }
    35.    
    36.     void On_JoystickTouchUp(MovingJoystick move){
    37.         enableMoveGun = true;
    38.     }
     
  8. VladNeykov

    VladNeykov

    Joined:
    Nov 12, 2013
    Posts:
    3
    Hi Hedgehog Team,

    Just purchased the Easy Touch package last night and my code is already looking cleaner; great job on the asset!

    I searched though the forum, but couldn't find a solution for multiple drag events. I have a few objects with a modified drag script which need to be able to receive their On_Drag/On_DragStart/On_DragEnd events independently. It looks like each of them remembers it's fingerIndex, the touch count does reflect that the previous finger is still pressed, however once a new object receives a drag event the old one freezes and no longer updates it's location.

    Short of reverting to adding in Update Input.touches[fingerIndex].phase == TouchPhase.Moved - do something (my original workaround), is there a way to use Easy Touch with multiple drag events?

    Thank you in advance!
    Vlad
     
  9. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    VladNeykov
    Can you try "MultipleFingers" example, there is multi drag event (off course you try it, on a real device). I'm thinking there is that you want
     
  10. VladNeykov

    VladNeykov

    Joined:
    Nov 12, 2013
    Posts:
    3
    Hi,
    Thank you for your prompt response; I did try it, even made a build on my iPad for it, and it exhibits a similar behaviour. You cannot be dragging one circle and then click to drag a second one without stopping the drag on the first one. In very very well-timed situations (if I manage to touch down at the exact same time on both circles) do I get a chance to drag them at the same time.

    Any further help would be most appreciated!

    Thanks,
    'V
     
  11. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi VladNeyKov,

    Your casea only happened when you have only two fingers, because there is security for two finger gesture that not allow to have tow different picked game object when you want to manage a twist or pinch.

    So just disable 2 Fingers Gesture in the inspector.
     
  12. VladNeykov

    VladNeykov

    Joined:
    Nov 12, 2013
    Posts:
    3
    You, sir, are a gentleman and a scholar!
    That did the trick; thanks much :)
     
  13. scrlklk

    scrlklk

    Joined:
    Dec 23, 2013
    Posts:
    8
    Yes,i have a plane collider attach on camera.

    i tested the script, it works as same as using on_drag:sad: Things are perfect when the first touch is on joystick. However, If i touch on a free zone first, then touch on the joystick and drag it outside of the area, it affect the touch position. i think it is also due to the isHoverreservedArea is on a update Events.
     
  14. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Titlis,

    Ok I see. I'm going to look at that ...
     
  15. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Titlis,

    Pending the update on the store, here are the changes for what you want to do :

    1- On MovingJoystick classe add this member : public int fingerIndex;

    2- On EsayJoystick classe add this line at line 1088 (CreateEvent method)
    move.fingerIndex= joystickIndex;

    The new script
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class test : MonoBehaviour {
    5.    
    6.  
    7.     private int joyIndex=-1;
    8.    
    9.     void OnEnable(){
    10.         EasyTouch.On_Swipe += On_Swipe;
    11.         EasyJoystick.On_JoystickTouchStart += On_JoystickTouchStart;
    12.         EasyJoystick.On_JoystickTouchUp += On_JoystickTouchUp;
    13.     }
    14.  
    15.     void OnDisable(){
    16.         UnsubscribeEvent();
    17.     }
    18.  
    19.     void OnDestroy(){
    20.         UnsubscribeEvent();
    21.     }
    22.  
    23.     void UnsubscribeEvent(){
    24.         EasyTouch.On_Swipe -= On_Swipe;
    25.         EasyJoystick.On_JoystickTouchStart -= On_JoystickTouchStart;
    26.         EasyJoystick.On_JoystickTouchUp -= On_JoystickTouchUp;
    27.     }    
    28.  
    29.  
    30.     void On_Swipe(Gesture gesture){
    31.        
    32.         if (gesture.fingerIndex != joyIndex){
    33.             Debug.Log( "move gun" + gesture.position);
    34.         }
    35.     }
    36.  
    37.  
    38.     void On_JoystickTouchStart(MovingJoystick move){
    39.         joyIndex = move.fingerIndex;
    40.     }
    41.    
    42.     void On_JoystickTouchUp(MovingJoystick move){
    43.         joyIndex = -1;
    44.     }
    45. }
    Tell me if it's good for you
     
  16. Mikie

    Mikie

    Joined:
    Dec 27, 2011
    Posts:
    367
    Hi Nicolas,

    Nice Skyping with you the other day. I finally have quit on 4.3.3 and put 4.2.2 back on. It works great with easytouch and my Droid 2.
     
  17. scrlklk

    scrlklk

    Joined:
    Dec 23, 2013
    Posts:
    8
    Wow, Thank you so much!! it works amazing.:D
     
  18. Jonathan Genesis

    Jonathan Genesis

    Joined:
    Apr 10, 2013
    Posts:
    2
    Hey I'm trying to get the joystick to work with javascript and i don't know how to it says nothing about that in the documentation here is my script

    Code (csharp):
    1. var MoveAxis : Vector2;
    2.  
    3. function On_JoystickMove(move: MovingJoystick){
    4.     if (move.joystickName == "LeftJoystick"){
    5.         MoveAxis = Vector2(move.joystickAxis.x,move.joystickAxis.y);
    6.     }
    7. }
     
  19. PixelEnvision

    PixelEnvision

    Joined:
    Feb 7, 2012
    Posts:
    513
    Hi,

    I've just installed today for the first time, as soon as the package is imported I'm receiving following error (twice) on the console. Any idea what that might be?

    "Mismatched serialization in the builtin class 'Mesh'. (Read 560 bytes but expected 561 bytes)"

    That's on latest unity...

    Edit: I forgot to mention...

    Asset store product page shows v3.1.6 but when imported plugin shows v.3.1.5. Asset store problem?
     
    Last edited: Jan 26, 2014
  20. username_

    username_

    Joined:
    Sep 27, 2013
    Posts:
    9
    Hello

    Did anybody manage to get Easy Touch to work with EZ GUI? I see that there is an NGUI compatbility support, but that did not help with EZ GUI.

    If I include an EZ GUI button in my scene, and also Easy Touch, the app crashes after a few seconds on android.
    It does not crash in the editor.
     
  21. Ertai7

    Ertai7

    Joined:
    Nov 30, 2013
    Posts:
    11
    Hi

    I don't know if anyone already mentioned it, but there seems to be a misspelling in the function name GetTouchToWordlPoint.
    It's more of a nuisance than a real problem - still would be nice to get fixed.
     
  22. vinchenc0o

    vinchenc0o

    Joined:
    Dec 11, 2013
    Posts:
    4
    Hi Team,

    Sorry if this was already asked but how can I use different animations for moving forward and moving backwards? I am using the third person example.
     
  23. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Great plugin, much better than FingerGestures, but I'm having an odd NGUI related issue. I have the latest version of the EasyTouch and have NGUI support enabled with the ngui layers added. I add the NGUI camera in code because the UI (and ngui camera) is loaded during loading each mission scene of the game. I use:

    uiCamera = UICamera.FindCameraForLayer(Globals.layerUI);
    EasyTouch.instance.nGUICameras.Add(uiCamera.camera);

    This seems to work perfectly in the editor as the UI touches and easy touch work together. Once I load the game onto an iPad everything works fine the first mission scene that I load (the EasyTouch gameobject is already in each mission scene), then if go back to the main menu and try another mission the NGUI support no longer works as touches go right through the ngui UI and register on both the 3D objects and NGUI. This only happens on a device, not in the editor.

    I put in a debug after my add camera line:
    Debug.Log(EasyTouch.instance.nGUICameras[0].name);

    and got a null reference error on device (not in the editor) when the 2nd mission scene was loaded. So then I added this line:
    EasyTouch.instance.nGUICameras = new List<Camera>();

    before I add the camera and then the debug worked reading back the ngui camera name, but that didn't fix the issue as touches on the UI hit both the UI and the 3D objects underneath.
     
  24. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi CapitalJmedia,

    Do you use one EasyTouch for all scenes or only one easytouch for each scene (don't destroy on load) ?
     
  25. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    I use a separate EasyTouch in every scene (except main menu). So every scene has it's own EasyTouch gameobject.
     
  26. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    Ok I suppose you added these line on start method. I don't know why, but in some case Unity doesn't execute scripts in the same order as in editor. To prevent thaat I added a new event "On_EasyTouchIsReady".

    Subscribe to it, and you must make initialization line in the event


    Nicolas
     
  27. henriquefaria

    henriquefaria

    Joined:
    Sep 17, 2013
    Posts:
    31
    Does it fully support Daikon Forge UI?
     
  28. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Not yet, but a simple change can do it
     
  29. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Yes, I has my code in the Start function. I added your event and it seems to have worked. Thanks for the help!
     
  30. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    You're welcome
     
  31. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Hi, I am trying to disable the 2nd finger simulation from standalone builds. Shouldn't the simulation of the 2nd finger only occur in the editor? Otherwise in standalone windows/mac builds the orange circle shows up if the 2nd finger button is pressed. I suggest disabling that by default for standalone builds.

    I tried:
    EasyTouch.instance.showSecondFinger = false;

    but that doesn't work, and changing the keys for the 2nd finger simulation doesn't seem to do anything either as the same keys keep being used.

    To disable this I had to change line 49 of EasyTouchInput.cs (add platform dependent code):

    #if UNITY_EDITOR
    if (Input.GetKey(KeyCode.LeftAlt) || Input.GetKey(EasyTouch.instance.twistKey)|| Input.GetKey(KeyCode.LeftControl) ||Input.GetKey(EasyTouch.instance.swipeKey ))
    count=2;
    if (Input.GetKeyUp(KeyCode.LeftAlt)|| Input.GetKeyUp(EasyTouch.instance.twistKey)|| Input.GetKeyUp(KeyCode.LeftControl)|| Input.GetKeyUp(EasyTouch.instance.swipeKey))
    count=2;
    #endif

    and line 552 of EasyTouch.cs (added Unity_standalone to platform dependent code):

    #if ((!UNITY_ANDROID !UNITY_IPHONE !UNITY_WINRT !UNITY_BLACKBERRY !UNITY_STANDALONE) || UNITY_EDITOR)
    void OnGUI(){
    Vector2 finger = input.GetSecondFingerPosition();
    if (finger!=new Vector2(-1,-1)){
    GUI.DrawTexture( new Rect(finger.x-16,Screen.height-finger.y-16,32,32),secondFingerTexture);
    }
    }
    #endif
     
  32. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi

    I going to look that I can do for the next release.
     
  33. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Hi again, I'm having an issue with getting a regular tap to be recognized on a standalone windows build (on a touchscreen device running win8.1 but a regular windows build, not a windows 8 build). It only gets recognized if I hold down for about a second instead of a quick tap (like it does on mobile platforms). Using:

    EasyTouch.On_SimpleTap += OnTap;

    private void OnTap( Gesture gesture )
    {
    Debug.Log("tap");
    }

    It registers mouse clicks just fine (which call the OnTap method from EasyTouch), and works perfectly on iOS/Android, but on a standalone windows build it is different. I've used other gesture recognizers on standalone windows builds and tap gestures always worked fine on touchscreen win devices.
     
  34. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Hello

    I have a game which controls the character by touching screen. I tried putting a button on screen but character moves when I touch button.

    How do I ignore touch for moving character but get touch for button?

    Thanks!
     
  35. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    You must test if the member isHoverReservedArea of Gesture class is equal to false when your receive an event from easytouch.

    When his member is equal to true, it's mean that you touch a button or a joystick.

    Nicolas
     
  36. TimB

    TimB

    Joined:
    Jan 19, 2011
    Posts:
    65
    Can I get the change needed to support Daikon Forge?

    Thanks
     
  37. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi,

    This is the code made by Udorn, to support DFGUI. You have to replace IsTouchHoverNGui method by this one in EasyTouch.cd script

    Code (csharp):
    1. private bool IsTouchHoverNGui(int touchIndex){
    2.  
    3.  
    4.         bool returnValue = false;
    5.  
    6.         if (enabledNGuiMode){
    7.             LayerMask mask= nGUILayers;
    8.             RaycastHit hit;      
    9.             int i=0;
    10.  
    11.             while (!returnValue  i<nGUICameras.Count){
    12.  
    13.                 Ray ray = nGUICameras[i].ScreenPointToRay( fingers[touchIndex].position );
    14.                 returnValue =  Physics.Raycast( ray, out hit,float.MaxValue,mask );
    15.                 returnValue = returnValue  hit.transform.parent != null;
    16.  
    17.                 i++;
    18.  
    19.             }
    20.         }
    21.         return returnValue;
    22.  
    23.     }
     
  38. TimB

    TimB

    Joined:
    Jan 19, 2011
    Posts:
    65
    Awesome, I'll give it a shot, Thanks!
     
  39. jococo

    jococo

    Joined:
    Dec 15, 2012
    Posts:
    232
    Cool thank Nicolas that worked.

    Can I use Easytouch to detect when I touch a gameobject?

    I have a raycast system working but it seems ugly.
     
  40. mimminito

    mimminito

    Joined:
    Feb 10, 2010
    Posts:
    780
    Hi,

    Is there a way to always detect the object that is under the swipe? I have used the static EasyTouch.GetCurrentPickedObject method along with the OnSwipe callback, but it seems to stop after a bit of swiping around. Am I missing something here?

    If the user is swiping the screen, non stop, I would like to be able to get the object that is always under the finger. How would I go about doing this?

    Adam
     
  41. ritual

    ritual

    Joined:
    Sep 26, 2013
    Posts:
    5
    Hi,

    how would you setup a script to move the camera up, down, left, right.?
    I'm making a top down 2d game. I want to be able to move the camera as i swipe my finger in any direction.
    I tried using drag, but that's not working for me.. would you use swipe or drag..?
     
  42. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Hi Nicolas, did you see my question about the simpletap not working on windows? I also PMed you about it a few days ago.
     
  43. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    I've been trying to solve this for a few weeks now, and haven't heard back to my PMs or on this forum about this issue. I guess it's time to try out another gesture plugin. :(
     
  44. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Hi capital

    Sorry, to not have responded rather (I'm very busy at the moment).Can you give me again your problem.

    Nicolas
     
    Last edited: Mar 10, 2014
  45. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    The simple tap doesn't work on window ?

    Does one finger example work for you ?

    Nicolas
     
  46. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    I'm having an issue with getting a regular tap to be recognized on a standalone windows build (on a touchscreen device running win8.1 but a regular windows build, not a windows 8 build). It only gets recognized if I hold down for about a second instead of a quick tap (like it does on mobile platforms). Using:

    EasyTouch.On_SimpleTap += OnTap;

    private void OnTap( Gesture gesture )
    {
    Debug.Log("tap");
    }

    It registers mouse clicks just fine (which call the OnTap method from EasyTouch), and works perfectly on iOS/Android, but on a standalone windows build it is different. I've used other gesture recognizers on standalone windows builds and tap gestures always worked fine on touchscreen win devices.
     
  47. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Ah ok, you want to use EasyTouch on Win8 or 7 Touch screen , that is correct ?
     
  48. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Yes, on a regular Standalone windows build (not a win8 store build). Currently the Drag, Swipe and Pinch gestures work with EasyTouch on standalone windows build, but tap only works if i hold down for about 1 second (as if it is receiving a long tap instead of simple tap).
     
  49. Hedgehog-Team

    Hedgehog-Team

    Joined:
    Feb 27, 2011
    Posts:
    1,155
    Can you increase the stationay tolerance in the inspector, and make a try

    Nicolas
     
  50. MythicalCity

    MythicalCity

    Joined:
    Feb 10, 2011
    Posts:
    420
    Tried it, all it did was make the dragging less responsive but a tap was still not recognized unless I held for 1+ seconds. I set the stationary tolerance to 100.

    That also brings up another issue, whenever I make changes to the EasyTouch object in the inspector, like the above stationary tolerance setting, it doesn't save. It reverts back to the default setting as soon as I hit play in the editor. But I did manage to get it to stay by changing it in code using EasyTouch.On_EasyTouchIsReady += StartEasyTouch.