Exercise - Load and render a model with Unity
In this exercise, you load a Unity sample project that includes a built-in 3D model of the truck engine. You configure the Unity scene, then enter your Azure Remote Rendering credentials in the RemoteRendering
game object. You then use Remote Rendering to remotely render the truck engine
Clone and open the sample project
At a Windows command prompt, run the following commands to clone the GitHub sample repository and set up the necessary subdirectories and packages for the Unity project.
mkdir ARR cd ARR git clone https://github.com/Azure/azure-remote-rendering powershell -ExecutionPolicy RemoteSigned -File azure-remote-rendering\Scripts\DownloadUnityPackages.ps1
Open Unity Hub and add the sample project, which is the ARR/azure-remote-rendering/Unity/Quickstart folder. Allow Unity to upgrade the project to your installed version if necessary.
Once added, open the project in Unity.
Note
For an overview of the process of configuring a Unity project for Windows Mixed Reality development, see the Set up a Mixed Reality project in Unity with the Mixed Reality Toolkit training module.
Configure the Unity settings
Go to File > Build Settings and switch Build Platform to Universal Windows Platform.
Select Player Settings at the bottom of the Build Settings window, which opens the Project Settings window.
In the Project Settings window, select OpenXR under XR Plug-in Management in the left navigation.
On the OpenXR screen, select Single Pass Instanced for Render Mode and Depth 16 Bit for Depth Submission Mode.
Close the Settings windows.
Configure the RemoteRendering game object
In the Project pane, select the Scenes folder under Assets in the left navigation, and then select the Quickstart scene.
In the Hierarchy pane at upper left, select the RemoteRendering game object.
In the Inspector pane on the right, enter the following information under Remote Rendering (Script):
- Remote Rendering Domain: Enter an Azure location near you in the format <region>.mixedreality.azure.com. The rendering domain can be, but doesn't have to be, the same as the Account Domain.
- Account Domain: Your Remote Rendering Account Domain that you copied from the Azure portal.
- Account Id: Your Remote Rendering Account ID that you copied from the Azure portal.
- Account Key: Your Remote Rendering Primary key that you copied from the Azure portal.
- Max Lease Time: The maximum duration of the remote rendering session. Set to 0 hours and 10 minutes.
Important
Be sure not to expose the saved credentials by checking the project into a repository.
Start a session and render the model in play mode
In the Unity top toolbar, select the Play icon to enter play mode and start the session. An overlay with status text displays at the bottom of the Game window, and the session goes through a series of state transitions.
In the Starting state, the server spins up, which takes several minutes. Upon success, the session transitions to the Ready state. Next, the session enters the Connecting state to reach the rendering runtime on the server.
When connected, the session transitions to the Connected state and downloads the model for rendering. The download can take a few minutes. When the download is complete, the remotely rendered model appears.