This is an example project demonstrating bi-directional communication between a Unity application to a iOS application (built with openFrameworks) using the OSC (Open Sound Control) network protocol.
The project enables the user to manipulate the position of two game objects (Sphere in Unity (green), Circle in openFrameworks (red)). The updated position of the game object in Unity is sent via OSC to the iOS openFrameworks application and vice versa.
ofxOsc was used to send and receive OSC messages in openFrameworks. UnityOSC by Jorge Garcia was used in Unity to send OSC messages, while VVVUnityOSC by frankiezafe was used to specifically receive OSC messages, which originated from an openFrameworks client (feat. bundle management), in Unity.
This example has been built using the following specifications:
- OS X 10.11.4
- Xcode 7.3
- openFrameworks 0.9.3 (iOS release)
- ofxOsc
- Unity 5.3.1f1 Personal
- UnityOSC v.1.2 by Jorge Garcia
- VVVUnityOSC by frankiezafe
- OSC (Open Sound Control)
Note: Generally, the openFrameworks and Unity source code should work also within their Windows counterparts. Please check out the above stated dependencies for troubleshooting.
- Place the contents of the
ios_of
folder into yourof_v0.9.3_ios_release/apps/myApps/
folder, or alternatively link the openFrameworks library accordingly within the iOS project settings. (Xcode only) - Check the Bundle Identifier and Team properties in the iOS project settings. (Xcode only)
- In
src/ofApp.h
, change theOSC_OUT_HOST
IP address to be the IP address of the machine you run the Unity application on. - In the
src/ofApp.h
, change theOSC_OUT_PORT
andOSC_INC_PORT
in case you want to use different ports. (optional)
- Load the Default.unity scene located in the
Assets/_Scenes
folder. - In
Assets/ThirdParty/OSC/OSCHandler.cs
, change theCLIENT_IP_ADDRESS
IP address to be the IP address of the device you run the openFrameworks application on. - In
Assets/ThirdParty/OSC/OSCHandler.cs
, change theCLIENT_PORT
in case you want to use a different port for outgoing OSC messages. (optional) - In
Assets/_Scripts/OSCConnector.cs
, change theOSC_PORT
in case you want to use a different port for incoming OSC messages. (optional)
- Start the openFrameworks application.
- Once 1. is running, start the Unity application.
- Touch input on iOS moves the red circle/sphere. Selecting the
Unity-Player-Controller
in the Unity editor's SceneView and manipulating its position will move and update the green sphere/circle.
MIT License, see LICENSE.md