This Unity project demonstrates how to capture a user's voice and egocentric camera image on Galaxy XR devices, send both inputs to the OpenAI API, and stream back textual responses. It is built on top of the Unity Mixed Reality Template (Unity 6000.2.10f1) configured for OpenXR and Android XR (experimental).
- Captures microphone input on Galaxy XR, forwards it to the OpenAI Responses API, and returns text output.
- Sends the current egocentric camera frame alongside the voice transcript to enrich the OpenAI query context.
- Provides optional visual debugging by rendering the passthrough capture onto a raw image via the
StreamPassthroughprefab.
- Unity Editor: 6000.2.10f1 (Mixed Reality Template)
- XR configuration: OpenXR + Android XR (experimental)
- Tested device: Galaxy XR (developer mode enabled)
com.google.xr.extensions1.2.0com.openai.unity8.8.7com.unity.xr.interaction.toolkit3.2.1 including all samplescom.unity.xr.hands1.7.0 including all samplescom.unity.xr.arfoundation6.2.0
The sample uses the OpenAI Unity SDK (com.openai.unity) to submit multimodal requests that combine:
- Voice recordings captured via Unity's microphone APIs.
- JPEG-encoded passthrough frames pulled from the Galaxy XR camera pipeline.
The OpenAI Responses API handles both inputs, returning text that the app displays in-world. Replace the placeholder API key in the Unity project settings with your OpenAI key before building.
For detailed package setup, follow the official documentation:
- Create an
OpenAIConfigurationScriptableObject via Assets > Create > OpenAI > Configuration, as described in the package documentation above. - Store the asset inside
Assets/Resourcesso it can be auto-loaded when the app starts. - Populate the asset with your API credentials (API key, org, and project IDs as needed).
- Assign this asset to the
configurationfield on theOpenAIQueryVisioncomponent in your scene inspector. - Alternatively, you can point the client to a
.openaiconfig file if you prefer not to embed credentials in the project.
- The passthrough feed is obtained through a Java plugin located at
Plugins/Android/src/com/galaxyXR/passthrough. - Keep the plugin in this folder structure; if you relocate it, update all C# calls that reference the Java package path.
- The plugin exposes camera frames to Unity, where they are converted into textures and attached to OpenAI requests or visualized in the scene.
- Follow the configuration steps in the Android XR guide: https://developer.android.com/develop/xr/unity.
- Enable developer mode on the Galaxy XR headset.
- In
AndroidManifest.xml, grant camera access:<uses-permission android:name="android.permission.CAMERA" /> <uses-feature android:name="android.hardware.camera2.any" android:required="false" />
- Import the required Unity packages listed above via the Package Manager.
- Configure OpenXR for Android XR (experimental) in Project Settings > XR Plug-in Management.
- Create and assign the
OpenAIConfigurationasset (see above) so that theOpenAIQueryVisioncomponent has valid OpenAI credentials before running the scene.
To preview the passthrough capture in a scene, add the DrawPassThroughOnQuad prefab. It maps the latest camera texture onto a quad so you can verify the image feed while testing.
- Use
adb logcatto monitor plugin output and OpenAI request status when debugging device builds.