Unity XR

Cross-Plaform Example

June 19, 2019

 

Unity has some nice code for handling cross-platform XR development, but there aren't a lot of examples for how to handle several different devices and write code that is independent from the current platform.

This example demonstrates a method for utilizing Unity's XR API to handle device connections and controller input. Includes a Player class with controllers that are loosely coupled and mostly abstracted from the XR device currently connected, allowing for easier cross platform development.

 

Supports the following devices:

  • Oculus Quest (the default configuration for the project)

  • Oculus Rift

  • HTC Vive

  • Magic Leap

This first version was created with Unity 2019.1.0f2.

Features

XRDevicesService.cs

  • Monitor devices that are connected or disconnected.

  • Classifies devices as HMDs, or Controllers, and tracks the type of device.