# Unity Setup Guide

This guide will explain in detail how to get started with the Snapdragon Spaces SDK in Unity.

# Prerequisites


Please note that the recommended Unity Editor version to work with Snapdragon Spaces is 2021.3 LTS (starting with 2021.3.16f1). Later versions of the Unity Editor have not been extensively tested and may not work as effectively.

Android Build Support must be added when installing the Unity Editor to be able to export .apk files. The module can also be added afterwards through the Unity Hub.

# Import the package

The Snapdragon Spaces SDK comes as a package in form of a tarball file. Please follow the Unity instructions (opens new window) to import the package into the project using the tgz file located in the Unity Package folder.


To have the package listed with a relative path (better for version control) instead of an absolute path, copy the tgz file into your project's Packages directory and then add it from there.

# XR Interaction Toolkit import

The Snapdragon Spaces Unity package has a dependency to the XR Interaction Toolkit package. During the import of the Snapdragon Spaces package, two prompts may pop up while importing XR Interaction Toolkit:

  • Enable the new input system: It is recommended to include the new Input System package by clicking Yes to ensure full functionality with the OpenXR and XR Interaction Toolkit packages. If the legacy input system is needed in addition, the Active Input Handling value under Player > Other Settings > Configuration can be set to both.
  • Interaction Layer Mask Update: The Interaction Layer Mask Updater (opens new window) might show a prompt to upgrade the interaction layer masks. No Thanks can be selected if XR Interaction Toolkit wasn't added to the project before. If an XR Interaction Toolkit package with a version prior to 2.0.0 was already imported, it is recommended to upgrade the interaction layer masks by clicking I Made A Backup, Go Ahead!.
Unity XRIT import prompts


Updating to the new input system will restart the Unity Editor, which is normal. This might cause confusion or leave the impression of a crash, however this is not the case. If you are concerned about your project, save or make a backup as recommended before updating.

# Change the project settings

To enable the Snapdragon Spaces OpenXR Plug-in, navigate to the project settings under Edit > Project Settings > XR Plug-in Management and open the Android tab. Check the OpenXR plug-in as well as the Snapdragon Spaces feature group. Initially, there will be some project settings that have to be updated/fixed. To do so, click on the red exclamation mark next to OpenXR to step into the OpenXR Project Validation window. Click on the fix buttons next to the entries to apply the needed project settings. Apply the setting to enable both Input Systems last, as this may require a restart of the Editor.

OpenXR Project Validation

# Enable Spaces features

Enable the features in the OpenXR settings that should be active during runtime. The current supported features and the respective AR Foundation manager or XR subsystem that can be used with it, is listed in the table below.

Feature AR Foundation/Spaces Manager XR Subsystem
Base Runtime AR Session (opens new window)
AR Pose Driver (opens new window)
XRSessionSubsystem (opens new window)
Camera Frame Access AR Camera Manager (opens new window) XRCameraSubsystem (opens new window)
Hand Tracking Spaces Hand Tracking Manager Spaces.XRHandTrackingSubsystem
Hit Testing (Experimental) AR Raycast Manager (opens new window) XRRaycastSubsystem (opens new window)
Image Tracking AR Tracked Image Manager (opens new window) XRImageTrackingSubsystem (opens new window)
Plane Detection AR Plane Manager (opens new window) XRPlaneSubsystem (opens new window)
Spatial Anchors AR Anchor Manager (opens new window) XRAnchorSubsystem (opens new window)
Spatial Meshing (Experimental) AR Mesh Manager (opens new window) XRMeshSubsystem (opens new window)
OpenXR Project Features

# Import the samples

The Snapdragon Spaces SDK package comes with sample assets to showcase how to use the perception features included in the package. To import them, simply pick the package in the package manager (located in the menu bar under Window > Package Manager) and click import on the Core Samples.

Import Core Samples


The Camera Frame Access sample's implementation requires unsafe code to be enabled under Player Settings (> Android Tab) > Other Settings group > Script Compilation > Allow 'unsafe' Code. If you do not wish to allow unsafe code, do not need the Camera Frame Access sample, and want to get rid of the error in the OpenXR Project Validation, you may delete the Camera Frame Access Sample folder from Samples > Snapdragon Spaces > {SDK Version} > Core Samples > Scenes.

After the samples have been imported, there is a helper tool to add the sample scenes to the build settings by clicking Window > Snapdragon Spaces > Add Scenes to Build Settings in the menu bar.

Add scenes to the Editor build settings