Adapters
namespace AR51.Unity.SDK;
The adapter layer is how the SDK reads tracked hands, VR controllers, and the play-area boundary without binding to any one device. Each capability is a small interface (IHandsAdapter, IControllerAdapter, IBoundaryAdapter) that a platform/device integration implements, plus a static factory that resolves and caches the active implementation per platform. Consumers never new an adapter — they call the matching factory's GetAdapter(). A platform integration calls Register<T>(platform) once at startup.
All positions, lengths, and matrices on this page are in Unity meters.
The platform fallback adapters returned when nothing is registered — EmptyHandsAdapter, EmptyControllerAdapter, DefaultBoundaryAdapter — are internal plumbing and not part of the public surface.
IHandsAdapter
interfacepublic interface IHandsAdapter
Interface a platform/device integration implements to expose tracked hand data to the SDK. Consumers obtain an instance via HandsAdapterFactory.GetAdapter(). Joint snapshots are returned as HandJointInfo[]; the array is indexed by (int)HandJointType and an empty array means no data.
Members
| Member | Type | |
|---|---|---|
SourceDevice | string | get |
GetRightJointInfos | HandJointInfo[] | method |
GetLeftJointInfos | HandJointInfo[] | method |
SourceDevice identifies the tracking source backing this adapter (e.g. a device or model name) — use it for diagnostics or to branch behavior per source.
Hands · get joint infos
HandJointInfo[] GetRightJointInfos();
HandJointInfo[] GetLeftJointInfos();
Returns the current snapshot of right- (resp. left-) hand joints. Order follows the HandJointType enum, so result[(int)HandJointType.IndexTip] is the index fingertip. An empty array means no data; joints with Confidence == 0 are considered missing.
var hands = HandsAdapterFactory.GetAdapter();
HandJointInfo[] right = hands.GetRightJointInfos();
if (right.Length > 0 && right[(int)HandJointType.IndexTip].Confidence > 0f)
Debug.Log(right[(int)HandJointType.IndexTip].Position); // Unity meters
HandsAdapterFactory
static classpublic static class HandsAdapterFactory
Static registry/factory that resolves and caches the active IHandsAdapter per platform. Register your adapter type once at startup, then retrieve it anywhere.
Method summary
| Method | Returns | |
|---|---|---|
GetAdapter | IHandsAdapter | static |
GetAdapter(PlatformType) | IHandsAdapter | static |
Register<T> | void | static |
Hands · GetAdapter
static IHandsAdapter GetAdapter();
static IHandsAdapter GetAdapter(PlatformType platform);
Returns the adapter for the current runtime platform (parameterless overload, resolved from the SDK's active platform) or for a given platform. The first call creates and caches the instance; if no adapter is registered for the platform, a no-op fallback is returned and a warning is logged.
The result is cached on first call regardless of which overload is used, so passing a different platform after the cache is populated returns the already-cached adapter, not a fresh one for that platform.
Hands · Register<T>
static void Register<T>(PlatformType platform) where T : IHandsAdapter, new();
Associates adapter type T with platform. T must be public with a public parameterless constructor. Call before the first GetAdapter for that platform.
Registering the same platform twice throws (it uses dictionary Add). This differs from BoundaryAdapterFactory.Register<T>, which overwrites.
HandsAdapterFactory.Register<MyQuestHandsAdapter>(PlatformType.Quest);
IControllerAdapter
interfacepublic interface IControllerAdapter
Interface a platform/device integration implements to expose VR controller state. Consumers obtain an instance via ControllerAdapterFactory.GetAdapter(). State is reported as ControllerInfo snapshots.
Members
| Member | Type | |
|---|---|---|
SourceDevice | string | get |
LeftControllerInfo | ControllerInfo | get |
RightControllerInfo | ControllerInfo | get |
SourceDevice identifies the controller source/device. LeftControllerInfo and RightControllerInfo are the current state snapshots of each controller.
var controllers = ControllerAdapterFactory.GetAdapter();
ControllerInfo right = controllers.RightControllerInfo;
if (right.IsDetected && right.IndexTriggerIsPressed)
Fire();
ControllerAdapterFactory
static classpublic static class ControllerAdapterFactory
Static registry/factory resolving and caching the active IControllerAdapter per platform.
Method summary
| Method | Returns | |
|---|---|---|
GetAdapter | IControllerAdapter | static |
GetAdapter(PlatformType) | IControllerAdapter | static |
Register<T> | void | static |
Controller · GetAdapter
static IControllerAdapter GetAdapter();
static IControllerAdapter GetAdapter(PlatformType platform);
Returns the adapter for the current runtime platform, or for a specified platform. Creates and caches on first call; falls back to a no-op adapter (with a warning) if none is registered.
Same single-cache caveat as HandsAdapterFactory.GetAdapter: the first call's result is cached regardless of the platform argument on later calls.
Controller · Register<T>
static void Register<T>(PlatformType platform) where T : IControllerAdapter, new();
Registers adapter type T for platform. Call before first retrieval.
Registering the same platform twice throws (dictionary Add), the same as HandsAdapterFactory and unlike BoundaryAdapterFactory.
ControllerInfo
structpublic struct ControllerInfo
State snapshot of a single VR controller. Value type; data model returned by IControllerAdapter.
Fields
| Field | Type | Description |
|---|---|---|
ControllerType | ControllerType | which controller (left/right) |
IsDetected | bool | whether the controller is currently tracked/present |
LocalToWorld | Matrix4x4 | controller pose as a local-to-world transform (position + orientation). Defaults to Matrix4x4.identity when not supplied. ⚠️ exact reference frame unconfirmed; positions are in Unity meters |
ButtonOneIsPressed | bool | primary face button pressed (e.g. A/X). ⚠️ physical button mapping not specified in source |
ButtonTwoIsPressed | bool | secondary face button pressed (e.g. B/Y). ⚠️ mapping not specified |
IndexTriggerIsPressed | bool | index (front) trigger pressed |
HandTriggerIsPressed | bool | hand/grip trigger pressed |
LocalToWorld's exact reference frame is not stated in source (positions follow Unity meters), and the ButtonOne/ButtonTwo physical mappings (A/X, B/Y) are inferred, not specified. Treat both as device-dependent.
Constructor
ControllerInfo(
ControllerType controllerType,
bool isDetected = false,
Matrix4x4? localToWorld = null,
bool buttonOneIsPressed = false,
bool buttonTwoIsPressed = false,
bool indexTriggerIsPressed = false,
bool handTriggerIsPressed = false);
Builds a snapshot. Omitted optional args default to not-pressed / not-detected, and localToWorld to Matrix4x4.identity.
ControllerType
enumpublic enum ControllerType
Identifies a controller.
| Value | Underlying | Meaning |
|---|---|---|
RightController | 0 | right controller |
LeftController | 1 | left controller |
IBoundaryAdapter
interfacepublic interface IBoundaryAdapter
Interface a platform integration implements to expose a play-area / guardian boundary. Consumers obtain an instance via BoundaryAdapterFactory.GetAdapter().
Members
| Member | Type | |
|---|---|---|
BoundaryName | string | get |
GetPoints | Vector3[] | method |
BoundaryName is the identifier/name of the active boundary.
GetPoints
Vector3[] GetPoints();
Returns the boundary outline as ordered points.
The coordinate space (world vs local) and whether the polygon is closed (last point joins the first) are not stated in source. Positions are in Unity meters.
BoundaryAdapterFactory
static classpublic static class BoundaryAdapterFactory
Static registry/factory resolving and caching the active IBoundaryAdapter per platform.
Method summary
| Method | Returns | |
|---|---|---|
GetAdapter | IBoundaryAdapter | static |
GetAdapter(PlatformType) | IBoundaryAdapter | static |
Register<T> | void | static |
Boundary · GetAdapter
static IBoundaryAdapter GetAdapter();
static IBoundaryAdapter GetAdapter(PlatformType platform);
Returns the adapter for the current runtime platform, or for a specified platform. Creates and caches on first call; falls back to a default boundary adapter (with a warning) if none is registered.
Boundary · Register<T>
static void Register<T>(PlatformType platform) where T : IBoundaryAdapter, new();
Registers adapter type T for platform.
Unlike HandsAdapterFactory and ControllerAdapterFactory, this uses an indexer assignment, so re-registering a platform overwrites the previous type rather than throwing.
See also
- Hand data —
HandJointInfo,HandJointType, and the hand-joint helpers returned byIHandsAdapter CustomHandsAdapter— an in-sceneMonoBehaviourthat implementsIHandsAdapterfrom Inspector-assigned transformsServiceManager— SDK lifecycle and the activePlatformTypethe factories resolve against- Class index — all Unity SDK types