Introducing “Input.Touches”, a low cost, easy to use helper library for Unity3 touch (and mouse) input.
Input.Touches uses event system to signal various input event. Letting you focus on dealing with your actual code instead of juggling with various input.
Supported input event:
single finger: short tap, long tap, multi-tap, charge(timed-pressed), drag, swipe
multi-finger: short tap, long tap, multi-tap, charge(timed-pressed), drag.
special gesture: pinch, rotate
Support concurrent input (2 or more input type at the same time) for most events. The exception are multi-finger drag, pinch and rotate.
Uses event system, keep things simple.
Support both JS and C#.
Tested and works on PC and iOS device.
Various example scene with documented code in both JS and C#.
So, is this a code-once solution? I’m looking for something easy to use, that doesn’t require me to re-write or juggle input schemes between platforms (PC/Mac vs. iOS). It also has to support JS and be well-documented (as you’ve already stated, just calling it out).
This should work just fine switching from PC to Mac to device. I myself does that quite often and I understand it’s quite a pain trying to maintain input code for build across all platforms.
I dont have an extensive example of js but I do include a simple demonstration of how to use the event system using js. I think I have a rather comprehensive documentation and example code. But I’m happy to take any feedback and make the necessary amendment. You can be sure that customer satisfaction is my first concern.
@milkhall, This framework uses only unity default touch input functionality. As far as I know it does not support multi-touch on window7. So the answer is no.
@Shawn, The framework is very much device and system dependant. If the input device is supported by unity, then yes. Pardon me but I’m not sure what device and system you are refering to. My understand is flash player are not available on iOS device, which this framework is developed and tested on. I imagine it should work just fine on an android device. However if you other desktop based touch input device, then unfortunately the answer is no.
Hi. The RTS camera demo in your package does not work as well as the web demo. When I move camera with right mouse button, the camera only moves slightly, while on the web demo it works perfectly. I tried to increase panSpeedModifier to 1000, still no luck.
@abbc, I dont seem to have that problem, both on my window pc and mac. Can you please let me know platform are you running on? It would help tremendously if you could just sent me your package so I can take a closer look.
I’ve just bought this, tried on Windows and Android. Curently, there is no problem for me. The RTSdemo just worked out of the box. The only problem with the RTSdemo is that the camera does not rotate around the “target” object, instead it rotates around its parent. Therefore the “target” slot is a bit confusing, since it’s not used at all.
Anyway, thanks for this simple and effective tool… very well worth the price.
None of the complicated taps seem to be working. I’m using the latest version of unity. I open your tap demo scene, and the only one in there that seems to work is the drag one. Is there anything else I need to do to get them to work?
EDIT:
I just realized that SwipeDetector.cs has the same issue. Just change line 132 the same way.
EDIT 2:
Changing SwipeDetector.cs the way I described f*cks up the SwipeDetector-Demo completely. It says it always detects a swipe as soon as you click somewhere in the editor. The sphere moves erratically when moving the mouse while fire1 is held down.
EDIT 3:
Added " (!UNITY_EDITOR)" in line 46 in TapDetector.cs and line 75 in SwipeDetector.cs and now it’s working fine.
@delstrega, Thanks alot for the elaborate modification. I really appreaciate it. The issue where some of the input are not working are cuased by the target platform selection. The mouse Input wouldnt work properly when the target platform is set to iOS or Andriod.
I’m quite aware of this. The lines of code such as
are there to prevent mouse and touch input to be detected simultaneously. The reason is unity would detech mouse input as a finger touch and vive versa. However the detection of touch input as mouse would only applied if the target platform is set to iOS. Without this platform depandant compilation, the mouse input detection would mess up the touch input when running on device.
By default, those purposefully coded restriction prevent mouse input to work when the platform is set to mobile. The reason I made it so is that I would expect developer to be more keen on testing their mobile build via touch using device or Unity Remote. delstrega’s is a vaible solution which would enable mouse input to work when the platform is set to iOS or android, however in doing so the touch input can only tested when running on a device, which of course prevent the usage of unity remote.
TLDR: The default code will only allow touch input but not mouse input in mobile platform. Hope this clear up the issue.
I see now, so that’s why you did it this way. Since I don’t use Unity Remote that much, I hadn’t actually noticed that it wouldn’t work correctly the way I “fixed” the scripts. But to be honest, it was kinda odd seeing the provided examples not working in the editor using mouse input.
Thanks for the clarification!
EDIT: I thought the dragging in TapDemo was kinda strange too (in Editor) so I played around with the code some more. Here’s the fix for that:
General.cs line 17: add " (!UNITY_EDITOR)" and the dragging works fine.