Version: 2019.4
VR frame timing
Creating an XR provider

Unity XR SDK

The Unity XRAn umbrella term encompassing Virtual Reality (VR), Augmented Reality (AR) and Mixed Reality (MR) applications. Devices supporting these forms of interactive applications can be referred to as XR devices. More info
See in Glossary
SDK is aimed at specialist users who want to develop their own XR providers that work with Unity. To download XR SDK, you must sign up for access on this page.

The XR SDK package allows multiple backends (called “providers”) to implement a single engine feature (called a “subsystem”) in Unity. User applications can select and activate providers at runtime.

Subsystems

A single subsystem consists of:

  • A developer-facing C# interface
  • A native interface that multiple backends (Providers) implement via dynamic libraries
  • Common engine code which handles communicating with the C# interface, the native interface, and the rest of the engine

Subsystem diagram

Subsystem descriptor

A subsystem descriptor is metadata about a subsystem which can be inspected before loading or initializing a subsystem. This comes from a manifest file and is accessed via a C# interface. A Create method activates the subsystem and provides an instance of it to the user’s scriptsA piece of code that allows you to create your own Components, trigger game events, modify Component properties over time and respond to user input in any way you like. More info
See in Glossary
.

For more information, see the Runtime discovery and activation of subsystems page.

Subsystem instance

When Create is called on a subsystem descriptor, this creates a subsystem instance. Scripting code interacts with these instances in order to communicate with the subsystem. The subsystem itself has its own lifecycle: it can be started, stopped, and shut down.

Provider

A provider is the native implementation of a subsystem. One subsystem can have multiple providers. Some subsystems can allow multiple providers to be active at a time, but others might be mutually exclusive.

Provider diagram
Provider diagram

Providers conform to the Unity native plug-in interface, with some additional lifecycle support built on top. The entry point is the UnityPluginLoad method. From there, the provider must register with all subsystems it intends to implement.

extern "C" void UNITY_INTERFACE_EXPORT UNITY_INTERFACE_API
UnityPluginLoad(IUnityInterfaces* unityInterfaces)
{
    s_XrDisplay = unityInterfaces->Get<IUnityXRDisplayInterface>();
    UnityLifecycleProvider displayLifecycleHandler =
    {
        NULL, // This can be any object you want to be passed as userData to the following functions
        &Lifecycle_Initialize,
        &Lifecycle_Start,
        &Lifecycle_Stop,
        &Lifecycle_Shutdown
    };
    s_XrDisplay->RegisterLifecycleProvider("Provider Plugin Name", "Display0", &displayLifecycleHandler);

    // Register with other subsystems...
}
VR frame timing
Creating an XR provider