Implement a provider
To implement a provider for the subsystem in this package (for example, say you are a hardware manufacturer for a new XR device), Unity recommends that your implementation inherit from XRHand
Subsystem implementations should be independent from each other. For example, your implementation of the XRHand
Register a subsystem descriptor
Each subsystem type has a corresponding subsystem descriptor type. Your provider should create and register a subsystem descriptor instance with Unity's SubsystemManager to enable runtime discovery and activation of subsystems. To register your subsystem descriptor, include a static void method with the [RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
attribute as shown in the example below, and in it call XRHandSubsystemDescriptor.Register
with subsystem descriptor information you are registering.
// This class defines a hand subsystem provider
class MyHandProvider : XRHandSubsystemProvider
{
// ...
}
// This class defines a hand subsystem
class MyHandSubsystem : XRHandSubsystem
{
public int myPlatformSpecificData => provider.RetrievePlatformSpecificData();
// This method registers the subsystem descriptor with the SubsystemManager
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
static void RegisterDescriptor()
{
var handsSubsystemCinfo = new XRHandSubsystemDescriptor.Cinfo
{
id = "My-Hands",
providerType = typeof(MyHandProvider),
subsystemTypeOverride = typeof(MyHandSubsystem)
};
XRHandSubsystemDescriptor.Register(handsSubsystemCinfo);
}
}
Implement an XR Loader
An XRLoader
is responsible for creating and destroying subsystem instances based on the settings found in Project Settings > XR Plug-in Management. All provider plug-ins must implement an XRLoader
. For more information on authoring an XRLoader
, see the XR Plug-in Management provider documentation.