In the previous article, we introduced How to use TouchDesigner’s OSC Out CHOP to send values to Unity. In this article, we will use OSC In CHOP to let TouchDesigner receive values from Unity.
We will use Unity’s Slider UI as an interactive interface, output a range of 0~1 values, and let TouchDesigner receive it via OSC.
The specific steps are as follows:
- Create a Slider UI in Unity.
- Connect the Slider UI to the Property Sender of OSC Jack.
- Create an OSC In CHOP in TouchDesigner.
- Start Unity and TouchDesigner.
- Slide the Slider UI in Unity, and TouchDesigner will receive the value and display it on the interface.
1. Install the OSC Jack package
First, open a Unity project (2021.3 or later). Click Edit and open Project Settings.
Switch to the Package Manager tab and register a package source in the Scoped Registries. Click Save to save the changes and close the Project Settings window.
The properties are as follows:
Click Window and open the Package Manager.
Switch the package source to My Registries and then find OSC Jack and click Install to install the package.
In the Assets folder of the Project, right-click > Create > ScriptableObjects > OSC Jack > Connection to create an OscConnection profile.
Click on OscConnection and change the Port to 10000, the default port for TouchDesigner.
2. Create UI
In the scene, create a Slider UI and adjust it to a suitable size. The default setting of the Slider object has a range of floating-point numbers 0~1, and no settings need to be modified.
3. Configure OSC
In the scene, create an empty object GameManager, first add the Property Sender script of OSC Jack, then drag the previously created OscConnection setting file to the Connection field, and finally drag the Slider UI we added to the Data Source field, and set Component to Slider and Property to value, please refer to the figure below for the settings.
4. Create OSC In CHOP in TouchDesigner
Open a new TouchDesigner project, delete all the default OP, add an OSC In and keep the default settings unchanged, and you can execute the test.
Run the Unity project, use the mouse to drag the Slider in the screen, and the corresponding value will be directly reflected in TouchDesigner.