Touch Screen User Interface (TUIO)

From ETC Public Wiki
Jump to: navigation, search

For touch screen interfaces in Unity, we use the uniTuio framework. uniTuio is an easy to use framework for Unity to handle touch screen input and simply apply it to a scene.


Getting started

  1. Download uniTuio. To do this, you first need to go to http://xtuio.com/ and register an account. Following this, uniTuio can be downloaded at: http://xtuio.com/index.php/projectsmain/utuiomain/item/xtuiocategory/new-unituio-ce-copy. uniTuio is a client for Tuio messages - but you also need a server
  2. Download Touch2Tuio server to convert Windows touchscreen messages. This can be found at http://dm.tzi.de/en/touch2tuio/
  3. Run the client exe in Command Line (cmd) specifiying unity as the process to connect to. After you start Unity (but before you hit play) in order to get access to touch-gestures. More information about using this command line is available at http://dm.tzi.de/en/touch2tuio/

Integration with Unity

  1. First you must create a gameObject dedicated to being a handler for information. On this handler, add a BBTouch Manager Starter script and a BBCrosshair Controller script (see Figure 1). File:TouchManager.png
  2. The BBTouch Manager starter must take in a prefab of a touchHandler object. uniTuio currently simulates the touch controls by mimicking iphone touch events, so it has to have a BBIphoneTouch script attached (see Figure 2). File:IphoneManager.png
  3. The BBCrosshair Controller script must have attatched to it the object you want to be your touch object representation. If this is an invisible object that is fine, but an object is needed. This script will automatically take your designated object and position it in the location of the touch within your scene. With these object in place, the touch interface has numerous controllers to automatically effect objects within your scene.

TUIO Glossary

Object Manipulation

  • BB3D Crosshair Controller - Generates a 3D cursor out of a designated prefab at the designated location of your touch.
  • BBBasic Touch Manipulation - BBBasic Touch Manipulation handles all basic touch events for your scene. If an object with this script attatch is touched you can have it dragged, scaled, and rotated by designating the actions with the check boxes on the script.
  • BBSimple Touchable Object - Allows for simple touches such as single, double, multi, or no touch actions to register to objects.
  • BBTouchable Button - Allows for button touches to be registered while throwing designated events to handle button presses.


Actions

  • BBChange Color Action - The color action toggles between multiple colors based off of touches. You designate 3 colors that will change with On, Off, and State change. State change is activated if the State checkbox is set and the toggling between On, Off, and state occurs when Press to Toggle is checked.
  • BBDestroy Object Action - The destroy object action destroys the destroys the designated object upon touch.
  • BBLoad Prefab Action - The load prefab action loads the designated prefab upon touch.
  • BBLoad Scene Action - The load scene action loads the designated scene upon touch.
  • BBTest Button label Action - The Test Button Label action generates designated text in the scene to output the state of a button for testing purposes.
  • BBTurn Off Texture Action - The turn off texture action turns off gui textures upon touch.


GUI Stuff

  • BBCrosshair Controller - Generates a gui crosshair representation of touch objects.
  • BBPress GUI Texture Action - Generates designated texture within GUI upon touch.
  • BBTouchable GUI Object - Allows for an object to be touched within GUI.

Coming Soon

  • Automation of calls to server (within Unity)
  • Project example using Touch2Tuio server
  • Example scene using touchscreen gestures

Sample Code

Below is a sample project using UniTUIO.
TUIO Tutorial Demo