Skip to main content
Version: 0.23.2

Unity Setup Guide

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

Prerequisites

VERSION

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.

Download the Developer Package

Download the developer package from the Snapdragon Spaces Developer Portal.

Import the Package

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

tip

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 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
danger

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.

FeatureAR Foundation/Spaces ManagerXR Subsystem
Base RuntimeAR Session
AR Pose Driver
XRSessionSubsystem
-
Camera Frame AccessAR Camera ManagerXRCameraSubsystem
Hand TrackingSpaces Hand Tracking ManagerSpaces.XRHandTrackingSubsystem
Hit Testing (Experimental)AR Raycast ManagerXRRaycastSubsystem
Image TrackingAR Tracked Image ManagerXRImageTrackingSubsystem
Plane DetectionAR Plane ManagerXRPlaneSubsystem
Spatial AnchorsAR Anchor ManagerXRAnchorSubsystem
Spatial Meshing (Experimental)AR Mesh ManagerXRMeshSubsystem
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
IMPORTANT

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