- Home /
Getting started with UniTUIO
I'm developing a game for Windows Surface and I'm trying to integrate multitouch inputs. I know that Unity doesn't support native multitouch inputs (right now), so I thought to use UniTUIO. But there's next to no tutorial on how to use it out there. Has someone experience with UniTUIO and could show me the ropes?
In addition to that, I'm using MultiTouchVista to simulate a multitouch enviroment(using 2 mices) for development purposes(as I can't develop on the Surface). So I want to know if those to things can go hand in hand.
Answer by Luci85 · Jun 12, 2012 at 01:22 PM
So after some researching, testing and putting together I got it to work.
1. get Touch2TUIO ( http://dm.tzi.de/touch2tuio )
2. If you don't have a multitouch display, but still want to develop multitouch applications, get MultiTouchVista ( http://multitouchvista.codeplex.com )
3. get the uniTUIO demo scene ( http://xtuio.com )
4. Now take the iPhoneEventManager from the demo and integrate it into your scene (deactivate the ConvertTouchToMouse Option). Don't forget to grab all other scripts from the scene.
5a. As I developed in UnityScript I had to use some tricks to get the touch position data. I used the BBCrosshairController prefab as a starting point. Then I added a Touchconversion script onto the prefab, which translated the touch into my UnityScript world. (basic touch informations like the phase and the position)
5b. If you use C# as scripting language you can just use the iPhoneInput class, which now has the fake touchs inside.
6. To test your application, (start MultiTouchVista for multimouse to multitouch emulation, then) start your application, then (very important) start Touch2TUIO in a command window with you application name as argument. And now you should have a working multitouch solution.
Some hints:
-unitTUIO isn't build for multi camera games (aka splitscreen), but if you change
BBInputDelegate updateEvent()
anEvent.screenPosition = new Vector3(cursor.getX() * Camera.main.pixelWidth,(1.0f - cursor.getY()) * Camera.main.pixelHeight,0.3f);
into
anEvent.screenPosition = new Vector3(cursor.getX() * Screen.width,(1.0f - cursor.getY()) * Screen.height,0.3f);
and the same for cursorDown(), you will get touches above all cameras.
-if you are like me and developing in UnityScript, give the blursor prefab a new layer, faketouch for example, then you can just use
fakeTouches = GameObject.FindGameObjectsWithTag("FakeTouch");
for(fakeTouch in fakeTouches)
to get all active touches (check the enabled state or delete the blursors inside BBCrosshairControll if there is no touch). Remember the blursor is in viewport coordinates so you have to translate it into the screenposition.
-TUIO applications are always in fullscreen
-if you compile your application remember the settings (32 or 64 bit) and use the appropiate Touch2TUIO exe
Your answer
Follow this Question
Related Questions
Attaching Scripts to GUI Components 1 Answer
Move 2 objects at the same time 0 Answers
uniTUIO touch delay 0 Answers
How to have multi-touch with Canvas buttons 0 Answers
I try to Create a DLL for get WM_TOUCH windows message! 1 Answer