Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    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
    Generally, no. As the FAQ says you need colliders to capture touch points — http://interactivelab.github.io/TouchScript/#faq.
    But there are ways to do this manually:
    1. You can place invisible objects with collders on them right behind gui elements. These objects will get touch points effectively covering the cube.
    2. Write a custom script inherited from HitTest which checks coordinates in screen space and discards touch points if they are in selected areas where your gui elements are.
     
  2. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,230
    This is a really nice tool - thank you for publishing it on the Asset Store. I'm using this to make an app work with Windows7 / Windows8 touch and Tuio. ATM, I'm not really interested in the gesture recognition because that's something I already have built into and tweaked for this project (that'll come handy in another project, though).

    I have already created a bridge for a tool I have developed for that project, using MetaGesture, which worked pretty nicely (I'll probably publish that tool on the Asset Store later - with the option to use TouchScript with it if one needs it).

    What's missing for me now is support for NGUI. Basically, all I need is NGUI to work with TouchScript the same way it would work with "native touches". In fact, on devices where native touches are supported, I wouldn't even use TouchScript because this already works smoothly. Only on Windows 7 / 8, I'd like TouchScript to feed the touch events into NGUI somehow.

    I noticed that someone (ludicch) seemingly already has an NGUI integration up and running and offered adding this into the project. Any chance we could get this? That would be a huge time saver and avoid that everyone has to duplicate that effort.

    See also the discussion in: https://github.com/InteractiveLab/TouchScript/issues/6
     
  3. misc

    misc

    Joined:
    Jul 11, 2012
    Posts:
    7
    Right Mouse Button Input

    I am working on a multi-platform application and it should work with normal mouse input and optional touch input on Windows/Mac/iOS.
    When I drag with left mousebutton down I want the object to rotate, when I drag with right mousebutton down I want the object to pan.
    The multitouch version works fine: one touch drag to rotate, dual touch drag to pan.

    It seems that right mouse button input is not supported - is there a way to use the standard right mouse button input?
     
  4. 4sth4rtee

    4sth4rtee

    Joined:
    Jul 9, 2013
    Posts:
    1
    Hello and first of all thank you for sharing your work !

    I am using TouchScript for my mobile application and I am encountering issues using FlickGesture, as long as the Gesture is Recognized when the input is released and not while finger is moving. Am I doing something wrong ?
    Another thing, I want to recognize FlickGesture, PressGesture, LongPressGesture and PanGesture on the same GameObject, but I don't want to recognize the PressGesture when I'm dragging the object (and not detecting a simple press when I want a LongPress); is it possible ?
    Thanks again
     
    Last edited: Jul 9, 2013
  5. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
  6. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    MouseInput class converts clicks into touch points.
    There were a couple requests with right click functionality but every time different ones.
    For the engine it's not possible to say that some touches are somehow "different" from the others, so the best way to make right mouse work is to add 2 touch points when right button is pressed instead of one. So you could set up 1 point gesture to rotate and 2 point gesture to rotate.

    Is this what you want?
     
  7. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Right now Flick Gesture indeed is descreet and only fires state change when it's recognized.

    As for the logic you described the best way is to let everything work together but in the script you get all the events to have states based on what events happened and changes states accordingly allowing or ignoring certain events from gestures.
     
  8. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
  9. misc

    misc

    Joined:
    Jul 11, 2012
    Posts:
    7
    It would work fine for me, if right mousebutton input and left mousebutton input were exactly the same.
    I just have the problem, that nothing is happening at all, when I use the right mousebutton.
     
  10. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    But how will you differentiate actions when left button or right button are pressed if they are identical?
     
  11. misc

    misc

    Joined:
    Jul 11, 2012
    Posts:
    7
    I would use for example Input.GetMouseButton(1) for right [FONT=Verdana, Arial]mousebutton.[/FONT]
     
  12. aum

    aum

    Joined:
    Dec 17, 2012
    Posts:
    20
    It's possible a simple example to move rotate and scale a box, with the 3 actions interacting at same time, and at same object.

    Move with 1 finger
    Rotate 2 fingers in rotation movement.
    Scale 2 finger with "expand" movement.

    ???

    I tried but sometimes works, and sometimes fails.
    I put the the behaviours to the Box with Local 0,1,0 in the projection normal in Pan and Rotate.

    Could you help me?
     
  13. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Check out the examples, there's just what you need. Inspect carefully gestures' parameters especially Will Recognize With array.
     
  14. aum

    aum

    Joined:
    Dec 17, 2012
    Posts:
    20
    I'm tried, but when I test in Ipad, sometimes detect rotation, sometimes scale, sometimes nothing...
    I have to add the same object to the array "Will recognize with"? similar to the "Simple Gesture scene"?
     
  15. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    yes, if you got a scale gesture (1), a rotate gesture (2) and a pan gesture (3) you need to add (1) and (2) to (3)'s Will Recognize With array and (1) to (2)'s array.
     
  16. aum

    aum

    Joined:
    Dec 17, 2012
    Posts:
    20
    in just a word!!
    FANTASTIC!!!!

    Thank you very very very much, works fine.

    Could you explain what is the "sense" for do this configuration.? I refer the config for "encue" the gestures in the Arrays of the same gestures...it works, but.. why? I haven't finish to undertand it...

    I'm tested and searched very much but nobody says me the configuration before.. that works incredible fine.

    Thank you another time for this.. I recommend you to put in the scenes demo.
     
  17. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    sorry, could you repeat your question? o_O
    also where would you like demos to be put? They are in Examples folder anyway.
     
  18. aum

    aum

    Joined:
    Dec 17, 2012
    Posts:
    20
    Hi valyard,
    thank you for your time.

    The question is wha'ts the point for put in the Move script, the rotate and the scale scripts in the "Recognize with"..., so... it's because it's only active when you are moving, or because another thing? I don't understand that the point.

    I would understand that I had to put the Move script, the rotate script and the scale script, but why had to put in the REcognize with..?

    Thanks
     
  19. aum

    aum

    Joined:
    Dec 17, 2012
    Posts:
    20
    And another question.. how can I detect double tap in all the fullscreen?

    Thanks
     
  20. Cadmus

    Cadmus

    Joined:
    Aug 2, 2013
    Posts:
    4
    Hey thanks a lot for this plugin. It is really well done!

    Question: I'm trying to modify the source code. When I try to build using my modified version I get an error saying "Extracting referenced dlls failed."

    I imagine it's coming because I'm compiling the dlls with a different version of .net, but I currently don't know enough about MonoDevelop to figure it out.

    Has anyone seen this issue? Is there a good solution?
     
  21. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Sorry, never saw this error.
    I develop on PC and Mac, on PC I use Visual Studio and on Mac I use MonoDevelop. So building process works in MonoDevelop.
    Have you seen the developers' guide on the site? Maybe you haven't included Unity libs.
     
  22. Cadmus

    Cadmus

    Joined:
    Aug 2, 2013
    Posts:
    4
    Thanks, I resolved it by deleting everything in the TouchScript/Plugins folder in my Unity project, recompiling the TouchScript dlls, and then re-importing them.

    I'm not sure exactly what the problem was, but I think it had something to do with the autogenerated TouchScript.sln file in the Plugins folder.

    Anyway, thanks a lot for the library. It's really useful and well done!
     
  23. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Guys!

    If you made a project using TouchScript I would really appreciate if you sent me a link to the project's page, video or screenshots!
     
  24. sleep

    sleep

    Joined:
    Aug 7, 2013
    Posts:
    8
    Hi Valyard, you're lib looks just the trick for a museum intallation project we're about to do. Would love to use it and and contribute. It needs to run on Windows 7 Touch, I'm just wondering if you can clarify what this means from the website:

    http://interactivelab.github.io/TouchScript/#description

    Thanks a lot.
     
  25. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Native windows touch through Win7TouchInput input source doesn't work when you test your app in Unity IDE. It works fine when you build a standalone app. This is due to some limitations we haven't have time to solve yet. Need to hook into Unity internals but we don't have this kind of expertise and not much time to investigate this issue.

    What kind of input and hardware you are going to use?
     
  26. sleep

    sleep

    Joined:
    Aug 7, 2013
    Posts:
    8
    Hey thanks for the info, that makes sense - maybe solving that is something I could look into.

    Still finalising the exact hardware make / model. I'll post as soon as I know, would greatly appreciate any insight you might have into whether it will work as expected. Can you reveal what hardware / input you used in the Vimeo videos at the start of the thread?
     
    Last edited: Aug 22, 2013
  27. Grahammmm

    Grahammmm

    Joined:
    Jun 4, 2013
    Posts:
    7
    Hello again,

    I've been experimenting with adjusting the vanishing point of the main camera using the script found here. When the image shown on the screen is shifted, it seems like the rays being cast to detect touched objects are not being shifted along with it. In order to touch an object, you need to touch where the object would have appeared using a normal projection matrix. Do you have an idea about how i might get this working? Thanks!
     
  28. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hi !
    Great work with TouchScript, it is really handy.
    I've been experiencing a bit with it and I already like.
    I'm now trying to make some basic particle system spawn when fingers press (on touch pressed) and then the spawned particle system should follow the finger until the touchEnd.
    Spawning works and dragging works... but the two aren't.

    I can not figure out how to directly attach a GameObject to the current touch.
    I've created a particleSystem which is spawn where the finger touch (Using on Press), code here :

    https://gist.github.com/gabrielstuff/6347267

    This works fine. The spawned element is draggable using on Pan, on simple tap and Transform2D (inspired from Basic example). But the spawnad object is not attached to the finger. I have to retouch it in order to make it stick to the finger...

    Thanks !
     
  29. gfoxworthy

    gfoxworthy

    Joined:
    Nov 4, 2010
    Posts:
    23
  30. kukamed

    kukamed

    Joined:
    Jan 23, 2013
    Posts:
    13

    Thank you very much for this library. Great work. Loving it. No complains. We are a small team from Brazil developing a digital audio mixer using your lib. On a couple of months we will share the project.
     
  31. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    Got the solution by implementing metaGesture and following the spawnCube example in EverythingCompiled example.

    Thanks
     
  32. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hi,

    I'm trying to implement momentum for rotation, and pan gesture.
    I was wondering what was the best way.

    Adding custom gesture or taking use of pan and rotate and release to add some effect onRelease.

    Any hints would be great.

    Thanks,
     
  33. dyego_s

    dyego_s

    Joined:
    Mar 26, 2013
    Posts:
    24
    HI!

    Has touchscript some mouse over functions?

    thks!
     
  34. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    As touchscript is for touching, what is your plan to do a mouse over ? you mean something to convert mouseover into mouseclick into tap ?
     
  35. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    We mostly use touch frames from PQLabs, the latest ones are decent enough. Also ZaagTouch frames are OK. For the transparent screen we used Displax Touch Foil. For many installations we used our custom made camera based DI soultion, but MultiTaction cells are much better... and much more expensive.
     
  36. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    I know there are issues when camera matrix is changed but it's still on my todo list since I personally don't use such effects.

    All the touch hit testing logic is in https://github.com/InteractiveLab/TouchScript/blob/master/TouchScript/Layers/CameraLayer.cs so you could try figure it out yourself.
     
  37. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    afaik they got their specific SDK, but I think it can be used as a Win7 touch input, though I never tried.
    I would be interested myself to test TouchScript on the latest MS Surface.
     
  38. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    The best way is to have a script which listens to pan gesture events, moves a target (or dispatches move events) and records all the movement in a stack. When gesture is finished the script would calculate how fast it was moving and start moving a target using calculated velocity which should decrease over time simulating friction.
     
  39. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    There is no mouse over functionality because there's no such concept in touch interfaces.
    Also if you touched an object another object can't be automatically notified if a finger was dragged over it.
     
  40. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Sorry guys for all the late replies, I've been at Unite'13 talking about TouchScript q:
     
  41. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    Thanks :) that is what I thought !
     
  42. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    Hi !

    Again ! very nice work on the TouchScript !

    Question : I have several little object that receive tap event. This works great. There transform belong all to a parent object. Let's say big.
    I'd like big to receive pan gesture event in order to rotate him along the pan gesture direction (this works great also.) So I calculate the boundaries of the collider box corresponding to center of gravity of all my little object + the whole size. I add this box collider to my Big object. This also works

    But as soon as my little object are hidden by the bigger collider box, they do not receive the touch events.


    Do you have any proposal for this ?

    Thanks !
     
  43. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, bigger colliders will cover smaller ones.
    But you can use several camera layers. That's what they are for. They got LayerMask property you can set to get hits only from colliders of specific layers.

    Can you try Camera Layers and report if they do the trick?
     
  44. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    I'm trying right now. But I can not find the image you refer to in your tutorial.

    See below :

    $1.png
     
  45. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    It's on a TouchManager instance. Add it somewhere in your scene.
     
  46. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    ok I've found it ! It is on the touchmanager object !
    Also I've added a second camera exactly placed at the same position of the previous one. This one got a layer with the mini cube.
    The other one got all the layer except mini cubes.
    Then in touchmanger I've changed the layer order to first look at minicube.

    This work. Only question I'm wondering... how much camera can one put in a scene ? and what should be the parameters. As for now, I've just duplicate the main Camera and both have Camera Layer Script from TouchScript.
     
  47. gabrielstuff

    gabrielstuff

    Joined:
    Aug 14, 2013
    Posts:
    15
    thanks, the tutos lead me in the wrong direction.
     
  48. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    If I'm not mistaken you can have several Camera Layers on one camera.
    Never used them this way though.
     
  49. oJAHRASTAo

    oJAHRASTAo

    Joined:
    Nov 9, 2012
    Posts:
    2
    Can this framework be used with WebPlayer builds?
     
  50. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Never tried. You should try build examples for webplayer.
     
unityunity