Run an XR application
How to build and run Unity XR projects during development.
Read time 3 minutesLast updated 12 days ago
Running an XR app developed in Unity works the same as running any type of app on a device. In most cases, you can use the Unity Build and Run function to both build and run an app on a connected device.
Build and Run
To build your game or application and run it on a device:
- Connect the target device to your build computer.
- Open the Build Profiles window (menu: File > Build Profiles).
- If necessary, choose the target platform and click Switch platform.
- Choose the connected XR device from the Run device options in the build settings. (Not required on all platforms.)
- Ensure the other build settings are correct for your chosen platform. Refer to Build profiles for more information.
- Click Build And Run.
Refer to Publishing profiles for more information about building Unity projects.
Play mode
On the Windows platform, some XR provider plug-ins support a "hybrid" play mode in which the project runs on a connected XR device when you enter Play mode. The Unity Game view mirrors the headset display. You have the choice of the following options for the Game view:
- Left Eye: shows the left eye only
- Right Eye: shows the right eye only
- Both Eyes: shows both eyes, side by side
- Occlusion mesh: shows the both eyes, side by side, mapped onto a mesh similar to that used by headsets to compensate for lens distortion.
Mock HMD
The Mock HMD package provides a simulated HMD in the Unity Game view in Play mode. The Mock HMD is a provider plug-in that simulates the presence of a head-mounted device. Enable the Mock HMD in the XR Plug-in Management settings section. Input and tracking are not simulated.
Refer to the Mock HMD documentation for more information.
XR Simulation
The AR Foundation package provides an XR Simulation feature that you can use to test AR apps in the Editor. XR Simulation provides pre-built test environments that you can use in Play Mode to simulate how your app would behave in different physical settings. The simulation reports detected planes and other AR features as if you were navigating within a real environment. You can modify the provided environments and create your own.
See XR Simulation for more information.
Additional resources
Most XR devices use one of the existing OS platforms. For additional information about running projects on these platforms, see: