Using Touch Code in Different Platforms

From ETC Public Wiki
Jump to: navigation, search


Content on the bridge can be created using a wide variety of platforms. Platforms refers to the program that the content was created in, ie Flash, Panda, Unity, GameMaker, etc.

We are working to make the touch capabilities on the lower screens of each station as simple as possible for all of these different platforms. Below you will find instructions on how to do just that.

Touch Content using Panda

Add here

Touch Content using Flash

Add here

Touch Content using Unity

These steps are not in a particular order.


• Obtain a copy of the TUIO_Example folder from \\randon\etc\projects\internal\spacebridge\ExampleBridgeContent. This is a sample project that has all the needed materials for creating a piece of bridge touch content. This is a good place to start so rename the folder to a fitting name.

• Obtain an OSC port#.

Title Screen

• The content must have a title / loading screen. Open up the project in unity and look at the setup scene.

• In the Project plane, open the Images folder and find the title asset. This texture is currently loaded in the diffuse channel of the material on the Title object in the scene. Load the image into Photoshop and change the title screen to match the piece of content. Re-save over the original file in the Assets\Images folder. This will update the texture in unity.

• The title screen is a Plane Mesh object and should be positioned close to the camera. A GUI texture could be used as well.

• The title screen is meant to give the user feedback that something happened when they pressed a button on the bridge to signal the desire to load a piece of content. It takes time to load the content, find the window handle, and position the window properly and during this time the window may not be positioned in such a way that one would be able to interact with the piece of content.

• The title screen should wait about 10 seconds before being destroyed and allowing the game to officially start. A script named TitleScript.js has been added to the Title game object to take care of this in a very simple way. This simple script does not prevent any other game elements from running any of their own code during this time so if this is desired then additional functionality will need to be added here.


• The GameController object is an empty node meant to hold the main game scripts.

• Currently it has a MainGame.js script that is pretty empty and waiting your game logic.

• It also has the KillGame.js script that closes the application. The script is very basic at the moment but if any actions must be taken at close for the purpose of cleanup then those actions could be added to this script.

• Other game objects look for the GameController object by name when it is time to quit the game. If you change the name of the object that contains the KillGame script then you must change the name in the Find commands used in other scripts like the IdleTimer script.


• The tuioStarter object must be in the scene, by that name, for it handles the TUIO touches.

• If for some reason the tuioStarter object is not in the scene, there is a prefab in the Prefabs folder.


• The BBTouchManagerStarter script has been added to the object. Make sure that the iPhoneEventManager prefab, from the Prefabs folder, has been assigned to the EventManagerPrefab variable in the Inspector. This script handles all the setup needed.

• The BBCrosshairController script has been added to the object. At start, the blursor prefab, from the Prefabs folder, should be assigned to the CrosshairPrefab variable. This script places an orange dot on the screen where the user has touched. If a different cursor is desired then replace this prefab variable. However, a cursor of some sort should be used to give the user feedback that they have touched the surface.

• The IdleTimer script has been added to the object. All bridge content should have a timer so that if someone walks away from the content then it will automatically shut down after a time. By default the IdleMinutes variable is set to 1 so that the content will close after 1 minute. The IdleLabel game object variable, by default, is set to the game object IdleStatus in the scene. This is a small GUIText object in the lower corner of the screen that updates as the idle timer ticks away. Every time the user touches the screen the BBCrosshairController calls the IdleTimer’s StopIdleTimer function to reset the timer. While it is not completely necessary to have some visible representation of the timer on the screen it does help the debug process.

Exit button

• Add

• First touchable thing

• GUI button

• Plugins folder

Draggable button

• Add

Touchable button

• Add

• Object Manipulation\BBTouchableButton

• ButtonTouchedScript

• Get TouchDown and TouchUp events

Touchable object

• Add

• Object Manipulation\BBTouchableObject

• ObjectTouchedScript

• Get TouchSingle, TouchDouble, and TouchMany events

Setting up the OSC port

• Update the OSC port number that was obtained so that the content can get the proper TUIO messages sent to it. Open the BBInputController script found in the Plugins\uniTUIOCE\iPhoneInput fakery folder. Find the line of code “client = new TuioClient(15308); “ and change the number if needed.

Exporting the project

• Create a project name for this piece of content and verify that it is unique.

• Create a new folder, somewhere, that is named the project name – case is important.

• Change the Player Settings so that the Default Screen Width = 1920 and the Default Screen Height = 1080. Check Run in Background. Disable the Display Resolution Dialog. Change the Product Name to your project name – case is important. This will change the name of the window.

• Create an executable and name it the project name – case is important.

• Place the executable and its Data folder into your project folder.


Getting the internal game content to line up with the frames:

• Getting the content to fit the window on the bridge station must also be tackled. This can be the first step or the last step.

• It is a suggestion to have all framing pieces children to an empty game object that can then be positioned and scaled. If GUI objects are used then you may need one node to control the 3D objects in the scene and another node to control all the 2D GUI since they use a different coord. system.

• Background template images can be used to get a base starting point for where to place your objects in the scene. This, however, may not be 100% accurate since templates have to be remade after a projector has received maintenance. Setup keyboard commands to move the empty game object and print out it's current position. Then load an executable onto the bridge and using the bridge laptop move the game object until the game content fits in the window. This is a try and tweak process that continues until it is right.

Getting the window to open up on the correct screen - TV or Projection

The simplest solution is to allow the bridge menu to position the screen for you but there are times when you want Unity to do it.

Networked content has a few more steps but for single window content follow these steps.

• If your Assets folder does not already have a Plugins folder make one.

• Acquire a copy of WindowHandler.cs and place it in the Plugins folder

• Acquire a copy of PositionScreen.js and place it in your Scripts folder

• Attach the PositionScreen script to a game object in the scene. Set the desired screen size and position. Also make sure to set the window name to your content name. This will override your player settings and remember that the bridge menu is expecting a specific window name.

• Create an executable and test it out.