Create enhanced 3D visuals with Holographic Remoting in UWP
Standalone Universal Windows Platform Holographic Emulation is the next step in holographic emulation, extending its functionality outside of the Unity Editor. Developers can now create UWP applications running on their Windows PC and connect to HoloLens at any point, providing a way to visualize 3D content in mixed reality.
Standalone UWP Holographic Emulation requires Unity 2018.2 beta and Windows 10 Anniversary Update or later.
To enable remoting in the UWP build, open the Build Settings window and select Enable XR Remoting.
This changes the startup process of the app by enabling holographic remoting and setting it to run in Remote to Device mode internally.
Next step is to write some code, allowing us to connect to a remote HoloLens device. Sample code is available as a part of the documentation here.
The new HolographicRemoting API allows us to connect, disconnect, or check the connection status. Once the connection succeeds, code loading Windows Mixed Reality device has to be executed to start the initialization process.
IEnumerator LoadDevice(string newDevice)
yield return null;
XRSettings.enabled = true;
For a call to XRSettings.enabled to succeed, we have to wait for load device by name to complete. To make sure we do so, we yield return null.
Similar to Holographic Remoting functionality available in the Editor, you need to install and run the Remoting Player available from the Windows Store. Start the application on the device, and the IP Address you should use when using Holographic Remoting API to connect will show up on the screen.
More information about the Remoting Player is available at Microsoft Windows Dev Center.
Once the app is running on a device, launch the standalone Unity app with remoting functionality enabled. Once HolographicRemoting.Connect() is called, you should see the content of your UWP app displayed in mixed reality on HoloLens.
This is a great way to extend your UWP application by adding Mixed Reality content to it or use users desktop to render complex models and see them in XR.
Testing Your Standalone Holographic Remoting App in Editor
The Standalone Holographic Remoting API can run while in Play mode inside Editor. To enable this option, go to Holographic Emulation window and make sure that the Emulation Mode is set to Remote to Device and that the Remoting Player is running on the HoloLens.
There is no need to provide any other information in that window. Now, start the App in Play Mode in Editor, and execute the logic leading to the HolographicRemoting.Connect() call.
Speech (PhraseRecognizer) isn’t currently supported via Holographic Remoting and instead intercepts speech from the Editor-hosted machine.
PhotoCapture can be performed during Holographic Simulation, but since the capture works via a local camera (such as a webcam), you won’t be able to retrieve a matrix with TryGetProjectionMatrix or TryGetCameraToWorldMatrix.
During Remoting, all audio on the hosted PC (not just that from the app) will redirect to the device.