Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

TouchScript — multi-touch library for Unity [RELEASED]

Discussion in 'Assets and Asset Store' started by valyard, Mar 6, 2013.

  1. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Please post all your questions on the official board:
    http://touchprefab.com/index.php! Questions posted here probably will not be answered!


    Before posting questions or bug reports please make sure that:
      • Browsed through examples bundled with the library,
    If you think there must definitely be a bug please post it at Github.

    Thank you.


    TouchScript. Multitouch library for Unity.

    TouchScript is much more than a handful of routines to receive touch events from different sources. Inspired by iOS, TouchScript makes handling complex gesture interactions on large touch surfaces much easier. Unity and Flash implementations are developed to work together in Scaleform environment.

    TouchScript is a multitouch framework for Unity. It was developed by Valentin Simonov (me) at Interactive Lab to:
    • Provide a reliable way to code multitouch interfaces on various devices.
    • Unify different input methods.
    • Handle complex interactions between gestures.
    • Take into account differences between a large touch surface and an iPad.

    Official site: http://interactivelab.github.com/TouchScript/
    Github repository: https://github.com/InteractiveLab/TouchScript

    Features

    • Easy and intuitive API.
    • Works on PC (Windows 7 and Windows 8), Mac, iOS, Android and Windows RT.
    • Doesn't require Unity Pro.
    • Supported input sources: TUIO, mouse, mobile (iOS, Android, WinRT) and native Windows touch.
    • Groups touch points into clusters on big touch surfaces.
    • Manages simultaneous gesture recognition within scene hierarchy (inspired by iOS).
    • Comes with many commonly used gestures. Easy to write custom ones.
    • Easy to test multitouch gestures without actual multitouch device using built-in second touch simulator (activated with Alt+click), TUIOPad on iOs or TUIODroid on Android.
    • It's free and open-source. Licensed under MIT license.
    • And more...
    All our (Interactive Lab) multitouch projects were done using TouchScript. You have probably seen these ones from Unity videos site or at Unite'12 keynote.


     
    Last edited: Sep 12, 2014
    Kellyrayj and rakkarage like this.
  2. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    WOW FREE?! AND OPEN SOURCE?!! INCREDIBLE !!!!
    Looks like Input.Touches/Easy Touch/FingerGesture just got some serious competition!
    Thanks so much for sharing!
     
  3. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    They are oriented on mobile devices, TouchScript was made for large touch surfaces.
    It's not optimized (yet) for iOS and Android. I hope someone will get to it eventually since the infrastructure is ready.
     
  4. kenshin

    kenshin

    Joined:
    Apr 21, 2010
    Posts:
    940
    Thanks, this is a great idea!

    I am pretty sure that unity3d community will do a good job with oyur project! :)
     
  5. elias_t

    elias_t

    Joined:
    Sep 17, 2010
    Posts:
    1,367
    Thanks a lot for this!
     
  6. elbows

    elbows

    Joined:
    Nov 28, 2009
    Posts:
    2,502
    I can confirm that as with the earlier version, the Windows 7 touch works with Windows 8 too :)

    (I tested with an Acer T232HL windows 8 multitouch monitor)
     
  7. ryangreen8

    ryangreen8

    Joined:
    Jan 26, 2012
    Posts:
    12
    Hey Guys,

    I'm having a tough time finding documentation or examples on how to use multiple gestures together in Unity

    I'd like to use the PanGesture to allow camera rotation. I accomplish this by placing a plane as a child of the camera and tracking finger movement by attaching a PanGesture to the plane. However, any TapGestures placed on elements in the scene are blocked by the plane in front of the camera. How would you recommend approaching this with your library?

    Thanks!
    Ryan
     
  8. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    One way would be to use FullscreenBackgroundTarget which does just what you said. Attach it to your camera.
    I don't remember when I used it the last time but it should work. The difference between FullscreenBackgroundTarget and your approach is that FullscreenBackgroundTarget places a BoxCollider at the far clipping plane of a camera. So if an object is further away you can't see it anyway.
     
  9. MadBrew

    MadBrew

    Joined:
    Mar 21, 2013
    Posts:
    2
    I'm having some issues getting this to work with Windows 8 and using a Dell S2340T multitouch monitor. The monitor appears to support native Windows Touch (Windows recognizes pinch zoom, I can see up to 10 blobs on the screen, etc. etc.), but when I build and run the project, it only captures a single point. Is there something I'm missing from the examples?
     
  10. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Do you use Win7TouchInput and not MouseInput?
     
  11. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Ouch! TouchScrip requires Unity Pro. Why in the world would a ouch input framework require System.Net.Sockets ?

    I get the following warning when I try to build the Everything Combined Example project.

    Error building Player: SystemException: System.Net.Sockets are supported only on Unity iOS Pro. Referenced from assembly 'OSCsharp'.
     
  12. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Main touch input in multitouch world is still TUIO which is a network protocol.
    That's why it needs System.Net.Sockets.

    You can fork the repository and remove TUIOInput and all references to TUIO from the project.
     
  13. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Seems like that would adversely affect it.
     
  14. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, but the main reason it to be opensource is that I got time only for functionality I need and bug fixes.
    If you need some additional functionality you can always implement it yourself.
     
  15. TokyoDan

    TokyoDan

    Joined:
    Jun 16, 2012
    Posts:
    1,080
    Yeah. I can see that and it is good for others with more time than both of us. The reason for me to consider such a tool is precisely because I don't have the time or don't want the bother of implementing it myself. But it does look like a very good tool.
     
  16. MadBrew

    MadBrew

    Joined:
    Mar 21, 2013
    Posts:
    2
    I cannot believe I missed that! Thank so much, works like a charm!
     
  17. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    So far this framework is proving to be great! Question - is it possible to use this framework to rotate an object with a single touch? We'd like to rotate a 3D object around it's center point on a single touch - ideally it would be coupled with the built-in Scale gesture (which works great as-is).
     
  18. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Sure, you'll need to write a custom gesture, add it and Scale Gesture to your object and add one of them to WIll Recognize With array of the other one.
    You can check out how Pan Gesture is made and use it to make a custom gesture which uses cluster's center not to move ano object but to rotate based on distance traveled or angle between camera normal and ray from cluster's center.
     
  19. UnityCoder

    UnityCoder

    Joined:
    Dec 8, 2011
    Posts:
    534
    I tested it on windows 7 with multitouch monitor, but only one touch working. No response of multitouch. Can you tell me what i am doing wrong here?
     
  20. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Are you using MouseInput or Win7TouchInput?
     
  21. UnityCoder

    UnityCoder

    Joined:
    Dec 8, 2011
    Posts:
    534
    How can i identify which input is currently set and if its MouseInput then how to change with Win7TouchInput?
     
  22. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Check TouchScript object in scene.
    If you don't have one it is automatically created when you press play. And if you don't have any inputs a MouseInput is created.
    Add Win7TouchInput manually.
     
  23. UnityCoder

    UnityCoder

    Joined:
    Dec 8, 2011
    Posts:
    534
    Ok... i found it. Add Win7TouchInput manually and after building a .exe its work fine for me, but whenver i closed my .exe its giving a crash report.

    One more thing multitouch drag and drop is possible with your script?

    I also built for android and tested on Google Nexus but nothing happen, so any suggestion for android build?
     
    Last edited: Apr 16, 2013
  24. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    Thanks for the help - we wrote a script using MetaGesture, and it is working great in the editor using TUIOpad as well as TUIODroid. However, when build and test on an iPad, the script is not working, but our Scale and Rotate gestures work fine. We have a Mobile input script attached to our Touch Manager gameObject.

    Perhaps something is setup wrong on our end? Hopefully MetaGesture works on iPad!
     
  25. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    There was indeed a problem with metagesture I fixed in develop branch a while ago. But I haven't merged it into master branch yet.
    Get the working DLL from github: https://github.com/InteractiveLab/TouchScript/tree/develop
    I plan to review what should be merged in master soon.
     
  26. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    That fixed it! Thanks a lot for the quick response! :D
     
  27. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, there's a bug with Win7TouchInput that it crashes on exit.
    For Android you should use MobileInput.
     
  28. fgarmo

    fgarmo

    Joined:
    Apr 22, 2013
    Posts:
    9
    First, thank you for your work and for share it for free, it's a great framework. Well, I have a question. I'm testing pan gesture and I do a drag and drop movement with an sphere game object. I need to add some colliders like a capsule collider to this sphere to detect some collisions on any particular areas of this sphere with other game objects, so I add these capsule colliders as children of my sphere.

    The question is I want to drag and drop my sphere only touching the sphere collider not touching the rest of capsule colliders (they are sphere's children), I mean only I want to drag and drop my sphere when I touch over her. Is there any to apply pan gesture only to the parent and not to children? I have attached pan gesture script to sphere only, but it seems like pan gesture was applied to the children too for this behavior.
     
  29. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, child colliders will trigger parent gestures too. This was the main idea q:
    But if you don't want that you can go to github and check out Hit Test example. There are cubes with different methods of ignoring touches. I think this is what you want.
     
  30. fgarmo

    fgarmo

    Joined:
    Apr 22, 2013
    Posts:
    9
    Thanks again. Is it possible to manage two or more different gestures in the same gameobject without conflict? In this case how? I am having troubles implementing scale and pan gestures in a sphere. I added the two gestures: pan gesture and scale gesture and then created two scripts to manage them separately, even I check the active touches number in each other to assert for example 1 touch in pan and 2 in scale gesture. However, there is a conflict with these because once scale or drag when should not do.
     
  31. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    This is easy. Just add one of them to another one's "willRecognizeWith" array in properties.
    This way they will work together.
     
  32. fgarmo

    fgarmo

    Joined:
    Apr 22, 2013
    Posts:
    9
    Thank you! it's working fine for me :) It's a great framework, thanks for share it for free again :)
     
  33. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Add a review in Asset Store if you like it q:
     
  34. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Just got version 2.0 in Asset Store and github.
    Please update.
     
  35. fgarmo

    fgarmo

    Joined:
    Apr 22, 2013
    Posts:
    9
    Is it possible to manage gestures on gui textures objects? If do, why?
     
  36. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    No it's not possible. Gestures work only on objects with colliders.
     
  37. ThreeDeeZ

    ThreeDeeZ

    Joined:
    Jun 22, 2012
    Posts:
    4
    I am trying to create my own gesture, but for some reason it does not seem to be getting the events for touchesBegan etc.

    New class that extends Gesture.
    Add the following lines to the class:

    Code (csharp):
    1.     protected override void touchesBegan(IList<TouchPoint> touches)
    2.     {
    3.         Debug.Log(this.name + touches.Count);
    4.     }
    When my new gesture is applied to an object in the scene (with a collider) I never see my debug messages or get any other output from it to trigger. If I apply one of the built in gestures (TapGesture) the events are processed as expected.

    Is extending with my own gestures not possible without rebuilding the entire TouchScript library, or am I missing some basic C# thing here...?
     
  38. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Should work as simple as PressGesture. Do you have an appropriate InputSource? And do you see touch points with touch debugger?
     
  39. ThreeDeeZ

    ThreeDeeZ

    Joined:
    Jun 22, 2012
    Posts:
    4
    I found the issue: I had a few other gestures attached and I thought I had disabled them all, but I still had one active. It was capturing the touchpoints and not sharing. Once I disabled the other gesture mine started working, and then I realized that mine was not set to 'will recognize with' the other gesture(s).

    TLDR: Operator error, check to see if you have "willRecognizeWith" enabled for 2+ gestures on the same game object.
     
  40. Grimjack2600

    Grimjack2600

    Joined:
    May 7, 2013
    Posts:
    13
    Hi, Thanks for creating TouchScript. I'm wondering if there are any utilities built in which allow for sending TUIO events out of Unity. I'd like to use a Unity driven application to send TUIO events to a listener elsewhere. Are these functions implemented in Touchscript?

    (digging and poking, this functionality appears to be present. what are the chances of sussing and example usage out of someone?)

    Resolved: Ended up writing a full port of TUIO/OSC based on reactivision C# port. Solved the whole mess that way.
     
    Last edited: May 16, 2013
  41. Fellow

    Fellow

    Joined:
    Apr 26, 2013
    Posts:
    4
    Hi everyone

    First, thanks for the lib, it's a great thing for touch devices.

    My goal is to achieve a camera that is moved using the touch input. So basically, ScaleGesture to zoom, Pan to move and Rotate ... to rotate ;)
    I used the FullSCreenBackgroundTarget to put the collider on the far plane of the camera to get the input, used the CameraLayer to sort the input on the objects on my scene from the input to control the camera. So far so good.

    But when I try to rotate or move, I have some weird data. The LocalDeltaRotation from RotateGesture is either 90 or -90. And the Pan is not even triggering.
    So I tried to use my own background plane and position it myself. When it is not well aligned with the camera, everything works like a charm. And as soon as it is aligned right on the far plane, same errors.

    The only solution I can see, is to put a plane big enough to cover the whole level. Not really efficient.

    Any thoughts anyone ?
    Thanks
     
  42. Grimjack2600

    Grimjack2600

    Joined:
    May 7, 2013
    Posts:
    13
    Fellow.

    Thoughts:
    I think what you're looking for is found in the newer Meta Gesture type. Alternately you can attach a background touch object (from the touchscript components) to the camera. Then you have a target/backdrop for the touch event to register against.
     
  43. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    24
    Quick question regarding ScaleGesture - is it possible to apply limits that prevent scaling up or down beyond specific values? For instance, if I had an object with a ScaleGesture attached to it that is scale 1, is there a way to prevent it from scaling smaller than 0.8, and larger than 1.5 ?

    Right now, I'm using the Update loop to check it's scale and brute force it into an acceptable range, but I'm getting some "jittery" results as it hits the threshold. It would be nice if there was an official solution that felt a little smoother.
     
    Last edited: May 9, 2013
  44. Fellow

    Fellow

    Joined:
    Apr 26, 2013
    Posts:
    4
    Grimjack : I did attach an background touch object to the camera, that is what I got my input from, but the data is not good.

    gfoxworthy : just write your own gesture from the ScaleGesture code and add this at the end.

    LocalDeltaScale = Mathf.Min(maxScale, Mathf.Max(minScale, LocalDeltaScale));
     
  45. Imawizrd

    Imawizrd

    Joined:
    Jan 19, 2013
    Posts:
    20
    Hey guys,

    I'm searching for a solution using touch controls with Windows 8. (I can't change OS unfortunately).
    I don't have the computer at the moment so I am unable to test TouchScript.

    Does TouchScript work with Windows 8?

    Thanks
     
  46. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    This shouldn't be happening.
    Do you have rotation in camera space set up for RotateGesture?
     
  47. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    LocalDeltaScale is a DELTA from previous frame to this frame. Limiting it has no sense.
    What you need to do is limit final scale in a script where you get events from ScaleGesture. If you use Transformer2d you'll have to write your own implementation and add needed constraints yourself.
     
  48. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    People reported that it does.
    I unfortunately don't have windows 8 and can not test it.
     
  49. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    BTW, uploaded to Asset Store version 2.0.1 which doesn't crash on exit when you use Win7TouchInput.
     
  50. dyego_s

    dyego_s

    Joined:
    Mar 26, 2013
    Posts:
    24
    Hello guys.

    I'm using the flick gesture and I what I want to know is: Can I get if is flicking to left or right?

    thanks!