Skip to main content
Version: 1.0

Play In Editor Setup Guide

This guide will explain in detail how to configure project settings and the scene to allow for play in editor to work effectively. These settings help speed up development time by reducing the need to deploy to a device to check smaller incremental changes.

Prerequisites

Follow the steps outlined in the Unity Setup Guide to configure the project to use Snapdragon Spaces.

OpenXR Project Settings

Navigate to Edit > Project Settings > XR Plug-in Management. The Unity Setup Guide contains the information needed to correctly configure the project to use Snapdragon Spaces on device, but for playing in the editor some additional steps are required.

OpenXR Project Settings

Initialize XR On Startup

On the Windows, Mac, Linux settings tab in the list of Plug-in Providers enable OpenXR. The Initialize XR On Startup setting should match the value from the Android settings tab. Configuring this setting to match the value from the Android settings tab ensures that when testing applications the behaviour is as close as possible to that seen on the device.

That is:

  • If not using the Dual Render Fusion feature make sure that Initialize XR On Startup is enabled. If this setting is disabled, the following warnings should be logged when pressing Play in the editor:
     No active UnityEngine.XR.ARSubsystems.XRSessionSubsystem is available. This feature is either not supported on the current platform, or you may need to enable a provider in Project Settings > XR Plug-in Management.
    No active UnityEngine.XR.XRInputSubsystem is available. Please ensure that a valid loader configuration exists in the XR project settings.
    • Use of a Spaces XR Simulator component in the scene may suppress these warnings, but it is still important that the settings for the editor match those of the final product to ensure testing the correct behaviour.
  • If using the Dual Render Fusion feature, make sure that Initialize XR On Startup is disabled. If this setting is enabled, the following warning should be logged when pressing Play in the editor:
    XR Management has already initialized an active loader in this scene. Please make sure to stop all subsystems and deinitialize the active loader before initializing a new one.

XR Simulation

Optionally, on the Windows, Mac, Linux settings tab in the list of Plug-in Providers enable XR Simulation. This enables the use of the XR Simulation and XR Simulation Environments provided by AR Foundation. Check the Unity documentation for information the use of XR Simulation.

If the XR Simulation provider is not enabled, the following warnings should be logged when pressing Play in the editor:

No active UnityEngine.XR.ARSubsystems.XRSessionSubsystem is available. This feature is either not supported on the current platform, or you may need to enable a provider in Project Settings > XR Plug-in Management.
No active UnityEngine.XR.XRInputSubsystem is available. Please ensure that a valid loader configuration exists in the XR project settings.
Simulation Subsystems

XR Simulation makes use of specialized, editor-only subsystems.

tip

These subsystems are useful to quickly get an idea of the behaviour or appearance of an application without requiring it to be built and deployed to the device each time an incremental change is made.

danger

These subsystems are provided by AR Foundation and may not provide the complete functionality of all Snapdragon Spaces features.

danger

The QR Code Tracking feature does not have an equivalent editor-only subsystem. See Known Issues for more detail.

Enable Base Runtime Feature for Windows, Mac, Linux

OpenXR Features

Navigate to Edit > Project Settings > XR Plug-in Management > OpenXR.

On the Windows, Mac, Linux settings tab, enable the Base Runtime feature.

Scene Configuration

Snapdragon Spaces provides an additional component which can be added to the scene to make development easier. The Spaces XR Simulator component is most useful when developing applications using the Dual Render Fusion feature. Even when not using the Dual Render Fusion feature, it helps to manage the lifecycle of certain XR systems in the editor, and reduces the number of warnings and errors seen here

Spaces XR Simulator component

The Spaces XR Simulator component is designed to persist between scene changes and should be added to a root game object in the scene hierarchy. This game object will be marked as Don't Destroy On Load. Only one Spaces XR Simulator component can exist and if a second would be instantiated it is destroyed instead.

Editor-Only Behaviour

Some XR systems don't respond well to scene changes in the editor, and can produce warnings or errors which only appear when pressing Play in the editor, and not when run on a device. The Spaces XR Simulator component shuts down many of these systems during editor scene changes, and then reinitializes them.

danger

The behaviour seen in the editor is not 100% identical to that seen on device, but is a useful approximation.

The Spaces Lifecycle Events component for Dual render Fusion may fire more events in the editor than would be seen on the device (shutting down and re-starting OpenXR between scene changes).

tip

All behaviour should, ultimately, be verified on the device and not in the editor.

Component Properties

Spaces XR Simulator component properties
  • Start Connected: when using the Dual Render Fusion feature, if this is enabled the simulation behaves as if glasses are active and connected to the device.
    • When not using the Dual Render Fusion feature, this setting has no effect.
  • Invert Sim Camera Display: when using the Dual Render Fusion feature, if this is enabled the phone display and the glasses display (Display 1 and 2 by default) will be switched.
    • This can be toggled at runtime through the shortcut Alt-Shift-X or through the menu item Window > XR > Snapdragon Spaces > Dual Render Fusion > Simulation > Invert Simulation Displays.
    • This setting is a workaround for a Known Issue where the Dual Render Fusion second display is not interactable in the editor.
    • When not using the Dual Render Fusion feature, this setting has no effect.XR Displays - Default

Dual Render Fusion Utility Methods

The Spaces XR Simulator component defines some utility methods which can be triggered at runtime to simulate events concerning the state of the device. The developer can then respond to the events fired by the Spaces Lifecycle Events component as desired.

Simulation EventKeyboard ShortcutEditor Menu ButtonDescription
Connect GlassesAlt-Shift-CWindow > XR > Snapdragon Spaces > Dual Render Fusion > Simulation > Connect GlassesSimulates glasses being connected to the phone, and enables the glasses display in the editor.
Disconnect GlassesAlt-Shift-DWindow > XR > Snapdragon Spaces > Dual Render Fusion > Simulation > Disconnect GlassesSimulates glasses being disconnected from the phone, and disables the glasses display in the editor
Glasses ActiveAlt-Shift-GWindow > XR > Snapdragon Spaces > Dual Render Fusion > Simulation > Glasses ActiveSimulates glasses becoming actively worn.
Glasses IdleAlt-Shift-HWindow > XR > Snapdragon Spaces > Dual Render Fusion > Simulation > Glasses IdleSimulates glasses not being actively worn.