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
    hm... a couple days ago working on a new version of TouchScript I split ScaleformLayer from ScaleformCamera.
    I guess it will be hard for you to upgrade to develop branch since it differs A LOT.
    But you can try to modify the source from https://github.com/InteractiveLab/T...caleform/Assets/TouchScript/Scripts/Scaleform.
    Since it's pretty short.
     
  2. czuczr

    czuczr

    Joined:
    Jan 23, 2014
    Posts:
    7
    ThankU Valyard! I just imported from the branch the new ScaleformLayer.cs and ScaleformMovie.cs to the project, added SFCamera and ScaleformLayer to an empty game object and duplicated it four times and works perfectly! :) I will post you if have some performance test.
     
  3. Dunkelheit

    Dunkelheit

    Joined:
    Sep 3, 2013
    Posts:
    81
    I'll take a look on it soon. Thanks!
     
  4. Credencys_parth

    Credencys_parth

    Joined:
    Oct 3, 2013
    Posts:
    1
    Hello everyone,

    I am new to programming and Unity3D. I am right now trying to use TouchScript for multitouch purpose in my Unity3D game. I need to create a custom gesture to implement Fruit Ninja type slicing effect. I want to know how to get the current touch positions of all the touches. Can anyone help me to make this gesture?

    Thanks in advance.
     
  5. PixelFrog

    PixelFrog

    Joined:
    Dec 2, 2012
    Posts:
    8
    Hi,
    I'm try use touchscript with unity 3.5.7. After import newest package 4.1 i've got compile error:
    nhandled Exception: System.TypeLoadException: Could not load type 'TouchScript.Hit.TouchHit' from assembly 'TouchScript, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
    All package was imported to Touchscript catalog, next package full was imported. If any one had this issue please share your solution :)

    Best,
    PixelFrog :)
     
  6. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Starting from 4.0 TouchScript doesn't support Unity 3.5.
    But you can try to build this version: https://github.com/InteractiveLab/TouchScript/tree/4.0.unity42
    It doesn't contain new 4.3 2d physics.
     
  7. StarHunter32

    StarHunter32

    Joined:
    Feb 10, 2013
    Posts:
    99
    Hello Valyard, is the prefab Touch Debugger same as Debug Camera from the tutorial.
    In the prefabs folder there's only Touch Debugger prefab. Thank you for the amazing plugin!
     
  8. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes. Also I'm updating tutorials.
     
  9. StarHunter32

    StarHunter32

    Joined:
    Feb 10, 2013
    Posts:
    99
    Great!
    I'm sorry for the lame question, but how to make a cube (or many cubes) draggable across the screen on let's say x and z axis with mouse/touch input? I guess I should attach Press Gesture on the cube itself, but then what? I keep trying, but can't find what to attach on where.Thank you.
     
    Last edited: Mar 25, 2014
  10. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    PanGesture and Transformer2d on one object with a collider would work.
     
  11. StarHunter32

    StarHunter32

    Joined:
    Feb 10, 2013
    Posts:
    99
    It works, except the cubes does not seem to respect the constrains in the rigid body parameters (even if I restrain rotation or postion they still rotate and move freely) and also when they collide with other object they react in a very slow motion manner and are no longer controllable.
     
  12. ToasterOfDeath

    ToasterOfDeath

    Joined:
    Feb 10, 2014
    Posts:
    5
    Hello

    First of, thanks for the touch library. I tried a few different lib and touchscript seemed to be really efficient.
    However I have a couple of question. Maybe something a didn't quite understand:

    I registered my object to three events: PressGesture.StateChanged, PanGesture.StateChanged and ReleaseGesture.StateChanged , in order to make it draggable. When using a mouse, everything works fine. But when using touch, the Press event is not detected until another event occurs: when a press my finger, nothing happens. Then if I release, I detect both press and release events at the same time. Same if a press and pan, the press event isn't fired until I move my finger. Is it the intended behaviour? How can I detect the press event right away even if my finger doesn't move?

    The second problem happens after a while playing with my draggable objects, suddently, for some objects, the Pan gesture never fires the StateChanged event. So if I push on my object and Pan, I only recieve press, and then release when I put the finger up. Not PanGesture.StateChanged is fired when I Pan between the Press and Release. I had the feeling that it only happens when using multitouch, but it's hard to find a way to reproduce other than panning on objects until it happens. Do you know how to fix this?

    I hope you can help me.

    Once again, thank for the work,
    Cheers
     
  13. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    The cube won't respect the constraints since it's moved by "manually" setting transform.position not by physics.
    If you want to use physics you will need to implement this functionality yourself.

    No, this behavior is wrong. What touch device are you using? Some touch display work like you described.

    You mean that no panning actually occurs? Is the position you are trying to move your object far from the start position? Because pan gesture has a movement threshold and starts after some movement is applied.
     
  14. ToasterOfDeath

    ToasterOfDeath

    Joined:
    Feb 10, 2014
    Posts:
    5
    Hi

    Thanks for the quick answer.

    Regarding the press event only fired when a second event occurs: The target hardware is an Open Frame LCD Monitor OF4204D FHD (42'' touch screen) working on windows 7. I get the same issue when simulating touch event on my windows 7 computer (I simulate touch events using the InputSimulator tool provided with the windows surface SDK).

    Regarding the no panning error: yes, no panning occur. I am able to drag my objects on the screen. They follow my finger without any problem (exept the first press event comes late, as mentionned above). I update the position of the object to the position of my finger projected in a 3D plane. I can see the objects dragged correctly, even several at a time with multi touch. But at some point, one or more objects stop to move. I can still see that the initial press event is fired but the object doesn't follow my finger. I write the events recieved in a log file. I can observe that at startup, the object recieved all Pan events (and thus moved along with my finger). Then at some point, the object doesn't recieve anymore Pan event and thus stops moving with my finger. Note that :
    - If I start dragging and get a Pan event, everything works until I release. The Pan events never stop once dragging.
    - It always works at startup
    - At some point, I press an object to start dragging, but when moving my finger, only the press event is launched and then nothing more
    - From this point, I never got the object moving again until a restart the program

    Do you have an idea of what could cause this?

    More Info:
    I have several objects that create a new PressGesture, PanGesture and ReleaseGesture in their start method, and register to them, so I have several (around 10) gameobjects, and each one of them has a Press, Pan and ReleaseGesture. Am I using touchscript right?
     
  15. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yes, it's better though to have a preconfigured prefab.

    Not sure what happens in the first issue described. Do other apps work fine?

    As for your second issue, it seems to be a case of this bug: https://github.com/InteractiveLab/TouchScript/issues/64
     
  16. ToasterOfDeath

    ToasterOfDeath

    Joined:
    Feb 10, 2014
    Posts:
    5
    Hi

    Regarding the first issue (Press not fired right away), I have constated the same behaviour when running your cube demo, so if this is not intended by you, I would guess it comes from the hardware.

    Regarding the second issue, it's more blocking for the project I'm on. I don't remember if I had both MouseInput and Win7Input enabled when testing on the target hardware (as mentionned in the bug you linked me to). Unfortunately, I won't have access to the target hardware before Monday, so I won't be able to test it again before next week. I'll come back to you in case it doesn't work better then.

    Thanks for your help and nice lib
     
  17. ToasterOfDeath

    ToasterOfDeath

    Joined:
    Feb 10, 2014
    Posts:
    5
    Hi

    EDIT: I completely edit my post because I actually found the answer to the question:


    Regarding the press event that isn't fired immediately when the finger doesn't move: I think it is specific to windows touches.

    Apparently, windows reserves the long press to simulate a mouse right click. So the press event isn't fired since windows waits for a long press.

    In this forum, someone proposes a solution to disable it: http://social.msdn.microsoft.com/Forums/en-US/1862ce62-455d-4566-a721-acb05716ce1b/disable-windows-7-touch-animation-in-wpf?forum=whatforum/

    The code is made for WPF app though, but adapting it to fit in the Win7TouchInput file, it works perfectly. the press events are now correctly detected on windows.

    Are you interested in me sending you the file so you can have a look and choose if you want to integrate it in a futur release of Touchscript?

    Once again thanks for your help!
     
    Last edited: Mar 31, 2014
  18. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Interesting.
    Sure, you can post it at gist.github.com for example. Or attach it here.
     
  19. ToasterOfDeath

    ToasterOfDeath

    Joined:
    Feb 10, 2014
    Posts:
    5
    Here is the link to gist:

    https://gist.github.com/bperrenoud/9909987

    I hope it wil be useful. If you have a win7 touch screen, you can try this code in your samples (like the input sample which drops white balls on press). In the current version, nothing happens if you touch but don't move. The ball only appear when releasing. With this update, the ball drops on press even in this case
     
  20. Mikeysee

    Mikeysee

    Joined:
    Oct 14, 2013
    Posts:
    155
    Hi Valyard,

    I love your library, great work mate.

    Im just having issues with panning the camera in 2D. I have uploaded a very simple project to show what I mean here: https://www.dropbox.com/s/nrb9nz8ovp2ufwo/TouchScriptTest.zip

    I am trying to make the princess touchable and have the background pannable but for whatever reason it doesn't work. If I remove the CameraLayer2D then I am able to pan but not able to click the Princess.

    Any idea?

    Mike
     
  21. PentagramPro

    PentagramPro

    Joined:
    Apr 5, 2014
    Posts:
    23
    Hello!
    I`m developing an open source strategy and I`m using TouchScript to scroll map with PanGesture and to control units with TapGesture.
    I`ve come to a problem that all touches go through GUI. When user clicks on a button, GameObject under it receives notification as if it were taped directly. How can I solve this problem?

    Game itself
     
  22. vickygroups

    vickygroups

    Joined:
    Apr 2, 2014
    Posts:
    16
    I'm getting this error after installing TouchScript into my game:

    No camera layers. Adding one for the main camera.
    UnityEngine.Debug:Log(Object)
    TouchScript.TouchManager:createCameraLayer()
    TouchScript.<lateAwake>c__Iterator1:MoveNext()
     
  23. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    At the moment TouchScript only works with somehting which has a collider.
    GUI elements don't have colliders. For now you can add empty objects right under GUI controls to catch events.
    I'm not sure what to do about this.
     
  24. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    This is not an error.
    It just creates a layer on the main camera because there has to be at least one in the scene.
     
  25. Otomii Lu

    Otomii Lu

    Joined:
    Apr 17, 2014
    Posts:
    20
    Hi ,

    Sorry for the noob question.

    I have an object behind a wall. They have their own LayerMask and collision.

    How can I Hit or use Gesture on the object with LayerMask in TouchScript?

    Thx a lot.
     
    Last edited: Apr 17, 2014
  26. dmutt

    dmutt

    Joined:
    Jun 3, 2013
    Posts:
    17
    What does this error warning mean?........................................your examples do it too. Is it because I am not on a "touch" device?

    No camera layers. Adding one for the main camera.
    UnityEngine.Debug:Log(Object)
    TouchScript.TouchManager:createCameraLayer()
    TouchScript.<lateAwake>c__Iterator1:MoveNext()
     
  27. dmutt

    dmutt

    Joined:
    Jun 3, 2013
    Posts:
    17
    Nevermind.........just saw the post 2 above. LOL
     
  28. EBPlayin

    EBPlayin

    Joined:
    Apr 17, 2014
    Posts:
    2
    I'm hoping you or someone else who has worked with Touchscript can point me in the right direction.

    I am looking to use the simple pan gesture to pull back then release as if from a slingshot. I have the pan working but I'm not sure how/where I can best capture the changes in position that occur while the pan is processed.

    Using Simple Pan Recognizer and Transformer 2D at the moment.
     
    Last edited: Apr 25, 2014
  29. mplaczek

    mplaczek

    Joined:
    Feb 13, 2012
    Posts:
    19
    Quick question. I was wondering how I would go about refreshing the Layers in the Touch Manager via code at runtime.

    Thanks! :)
     
  30. mplaczek

    mplaczek

    Joined:
    Feb 13, 2012
    Posts:
    19
    The application I'm currently building needs to run on a Samsung 1920x1080 46" touchscreen (SMED46CTS-6). However, the screen is currently being repaired and is installed physically a couple hours drive away making it impossible for me to test on currently (and pretty difficult any other time...)
    I was hoping those with a little more experience with TouchScript could help recommend a good set of values to plug in to get the best chance of robust gesture recognition from the start.

    I've calculated the dpi to be 47.89 on this screen so 'Live Dpi' is easy.
    However, what about 'Scaling Threshold' and 'Min Points Distance'? I understand the tooltip for each... but I'm wondering if the values I should initially test at should to be adjusted for the size and pixel density of the screen I'm using.

    Any thoughts or suggestions would be greatly appreciated. :)
     
  31. Pharaoh

    Pharaoh

    Joined:
    Jan 8, 2014
    Posts:
    28
    Hi valyard. I want to thank you for sharing TouchScript. It's a great library!
    I have downloaded TouchScript today and was checking out all possibilities.
    I was wondering what is the easiest way to implement something like standard "draw pattern to unlock screen".

    $android-security-unlock.jpg

    So basically my scene in Unity is the same like picture I have added.
    There are 9 GameObject which are positioned in the scene and I want to start from any of those GameObject and to "draw pattern".
    Gesture has to be started by initial press on touch screen, all objects which are touched have to be detected (so that I can change their color or something similar) and finally gesture is completed by releasing a touch from screen. As I said same as any other basic "draw pattern to unlock screen" application.

    Any help would be appreciated. Tnx
     
  32. valyard

    valyard

    Unity Technologies

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

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    You can add/remove/change index, this is what you should use.

    No, these values are in cm.
     
  34. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    You can make a new gesture which starts when you press one of these objects and with every movement of the touch it checks which object is closer to this touch. When this target object changes it writes its name to a list. If when the touch lifted off this list contains desired pattern this gesture recognizes. If not, it fails.

    The first thing which came in mind.
     
  35. Pharaoh

    Pharaoh

    Joined:
    Jan 8, 2014
    Posts:
    28
    Your idea is exactly what I had in mind. Only thing which I have trouble with is how to detect those sequential objects when the touch is moving. And how to distingvish those with some other game object which shouldn't be selected in the scene. Should I use raycasting? Is any available gestures nearly similar so I could see source code for ideas.
     
  36. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    You just add these 9 objects to a container and put your gesture on it.
    So you will have to check only these objects. Also you can use TouchManager.Instance.GetHitTarget() to check what object your touch point is currently hitting. This method uses raycast.
     
  37. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Hi,

    In my app, I move the 3D objects, when user moves two fingers without changing the gap in between the fingers.
    I have tested this with having Windows 7 touch input and it works fine. Now my client needs the mouse input also to work in other functionalities. So I added mouse input too. Now that moving functionality doesn't work any more. I have done it using the SimplePanGesture.
    Is there a way to identify whether the input is a mouse input or a touch input. May be this will help to solve my problem.


    Thanks
     
  38. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Are you using the latest 5.0 version?
    Mouse and Win7 inputs won't work together. Especially in old builds.
    Because windows dispatches first touch as mouse. So you will have double touch points.
    Somewhere in 5.0 the bug with touch points in the same position was fixed.
    Also Win7Input has a checkbox which disables MouseInput for this specific reason. Try to disable it.

    But, bad news is that right now you can't tell if a touch came from one input or another )8
     
  39. madhur

    madhur

    Joined:
    May 16, 2012
    Posts:
    86
    Thanks for the reply.
    I'm using 4.1. I'll try the latest version and see.
    Thanks
     
  40. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    I know this isn't documented in the release notes but has TouchScript now integrated NGUI or not? :)
    If not, how hard is it to implement?
     
  41. rrl

    rrl

    Joined:
    Aug 17, 2012
    Posts:
    1
    First off, thank you for creating TouchScript. It is very helpful.

    Unfortunately, I am having a problem with it since I updated to the latest version. With the old version, our game wouldn't compile for Windows Phone. I believe we were previously using 3.1 or something around there. Basically, we used the Tap Gesture for a lot of GUI elements in our game, and in the version we were using, we could have code run during the Began state, which we did. Here's a brief example of a simple button:

    Code (csharp):
    1. void Tap(object sender, GestureStateChangeEventArgs e)
    2. {
    3.     TapGesture target = sender as TapGesture;
    4.  
    5.     if (e.State == Gesture.GestureState.Began)
    6.     {
    7.         // button image scale tweens to smaller size
    8.     }
    9.        
    10.     if (e.State == Gesture.GestureState.Failed || e.State == Gesture.GestureState.Ended)
    11.     {
    12.         // button image scale tweens back to normal
    13.     }
    14.        
    15.     if (e.State == Gesture.GestureState.Recognized)
    16.     {
    17.         SendMessage("ButtonClick");
    18.     }
    19. }
    Going over the documentation, I get the feeling this was never how the Tap Gesture was supposed to be used. It seems this functionality was removed in the newer versions, since no code in the Began state runs. I feel like a possible solution would be to try and get everything to work with Press and Release Gestures, but... we have a large number of unique GUI elements that used the Tap Gesture in this fashion and I was wondering if there was a simpler fix. Ideally, some way to enable the Began state again for Tap Gestures would be great. Or maybe a custom gesture? I've never written one and the tutorial on the TouchScript site is incomplete.

    Any help you could offer would be greatly appreciated!
     
  42. czuczr

    czuczr

    Joined:
    Jan 23, 2014
    Posts:
    7
    Hi Valyard!

    We have a working setup with running 4instances from the same scaleform swf in one application. Using TUIO on windows 7.
    Instances can be restarted by user at any time or when user is finished.
    Now we have an issue, sometimes PQLABS Multitouch Helper is freezing and a windows pop's up showing that helper has stopped working.
    What do you think, can it be releated somehow to Touchscript?

    Thankx!
    czuczr
     
  43. Kscorrales

    Kscorrales

    Joined:
    May 12, 2014
    Posts:
    13
    Is there any tutorial to learn how to use it unityscript / javascript? Apart of page
     
  44. devandart

    devandart

    Joined:
    Jun 7, 2013
    Posts:
    144
    At first, your Library is SO NICE! Thank you for this.

    I'm building a Windows Multitouch game and created a "Hold to reload level" Button.
    My problem is now when I say
    Code (csharp):
    1. Application.LoadLevel(Application.loadedLevelName);
    the Scene reloads but my Touchscript doesn't work anymore!?

    Is there a Singleton that could have problems with this?
     
  45. DavideA

    DavideA

    Joined:
    Oct 14, 2013
    Posts:
    2
    Hi Valyard,
    I'm having a strange problem, perhaps you could tell me where I should look at.
    I have 2 cameras with a CameraLayer2D attached to each one. One camera is the main one that shows the game, the other, GUICamera, it is used to show a particular gui that it is showed only in some circumstances, and there are some buttons in this gui. In the editor, everything works fine, when the GUI is displayed touching the buttons their action is played. Now, I build the APK, but on the android phone the gui doesn't respond, but after building the APK also in the editor there is the same problem, before it was working, after the build it doesn't work anymore. If from the GUICamera I remove the CameraLayer2D component, and then I add it again, it starts working again.
    What do you think?
    I'm using version 5.0
    Thank you
    Davide
     
  46. valyard

    valyard

    Unity Technologies

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

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Shouldn't be hard. In fact someone already did this some time ago. It's buried somewhere in github issues.
    Though I think that NGUI API has changed since then.

    I have it in plans but not sure when I'll be able to do it.
     
  48. valyard

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Yeah, I'm doing the same thing with a combination of Press and Release gestures.
    You can find such buttons in the examples.
     
  49. valyard

    valyard

    Unity Technologies

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

    valyard

    Unity Technologies

    Joined:
    Jun 4, 2010
    Posts:
    291
    Sorry I don't really get your setup and what can go wrong o_O