Version: 2021.1
VR frame timing
Creating an XR provider

Unity XR SDK

The Unity XR 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 scripts.

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
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961