Skip to main content

Adapters

namespace · AR51.Unity.SDK
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.

Internal — not documented

The platform fallback adapters returned when nothing is registered — EmptyHandsAdapter, EmptyControllerAdapter, DefaultBoundaryAdapter — are internal plumbing and not part of the public surface.

IHandsAdapter

interface
public 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

MemberType
SourceDevicestringget
GetRightJointInfosHandJointInfo[]method
GetLeftJointInfosHandJointInfo[]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

method
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.

ReturnsHandJointInfo[]the current per-joint pose/confidence snapshot, indexed by joint type
Exampleinferred
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 class
public 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

MethodReturns
GetAdapterIHandsAdapterstatic
GetAdapter(PlatformType)IHandsAdapterstatic
Register<T>voidstatic

Hands · GetAdapter

methodstatic
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.

Parameters
platformPlatformTypeplatform to resolve the adapter for; see PlatformType
ReturnsIHandsAdapterthe cached adapter, or a no-op fallback
⚠️ needs confirmation — single cache

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>

methodstatic
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.

Parameters
platformPlatformTypeplatform the adapter type applies to
⚠️ needs confirmation — throws on re-register

Registering the same platform twice throws (it uses dictionary Add). This differs from BoundaryAdapterFactory.Register<T>, which overwrites.

Exampleinferred
HandsAdapterFactory.Register<MyQuestHandsAdapter>(PlatformType.Quest);

IControllerAdapter

interface
public 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

MemberType
SourceDevicestringget
LeftControllerInfoControllerInfoget
RightControllerInfoControllerInfoget

SourceDevice identifies the controller source/device. LeftControllerInfo and RightControllerInfo are the current state snapshots of each controller.

Exampleinferred
var controllers = ControllerAdapterFactory.GetAdapter();
ControllerInfo right = controllers.RightControllerInfo;
if (right.IsDetected && right.IndexTriggerIsPressed)
Fire();

ControllerAdapterFactory

static class
public static class ControllerAdapterFactory

Static registry/factory resolving and caching the active IControllerAdapter per platform.

Method summary

MethodReturns
GetAdapterIControllerAdapterstatic
GetAdapter(PlatformType)IControllerAdapterstatic
Register<T>voidstatic

Controller · GetAdapter

methodstatic
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.

Parameters
platformPlatformTypeplatform to resolve the adapter for; see PlatformType
ReturnsIControllerAdapterthe cached adapter, or a no-op fallback
⚠️ needs confirmation — single cache

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>

methodstatic
static void Register<T>(PlatformType platform) where T : IControllerAdapter, new();

Registers adapter type T for platform. Call before first retrieval.

Parameters
platformPlatformTypeplatform the adapter type applies to
⚠️ needs confirmation — throws on re-register

Registering the same platform twice throws (dictionary Add), the same as HandsAdapterFactory and unlike BoundaryAdapterFactory.

ControllerInfo

struct
public struct ControllerInfo

State snapshot of a single VR controller. Value type; data model returned by IControllerAdapter.

Fields

FieldTypeDescription
ControllerTypeControllerTypewhich controller (left/right)
IsDetectedboolwhether the controller is currently tracked/present
LocalToWorldMatrix4x4controller 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
ButtonOneIsPressedboolprimary face button pressed (e.g. A/X). ⚠️ physical button mapping not specified in source
ButtonTwoIsPressedboolsecondary face button pressed (e.g. B/Y). ⚠️ mapping not specified
IndexTriggerIsPressedboolindex (front) trigger pressed
HandTriggerIsPressedboolhand/grip trigger pressed
⚠️ needs confirmation

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

method
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

enum
public enum ControllerType

Identifies a controller.

ValueUnderlyingMeaning
RightController0right controller
LeftController1left controller

IBoundaryAdapter

interface
public interface IBoundaryAdapter

Interface a platform integration implements to expose a play-area / guardian boundary. Consumers obtain an instance via BoundaryAdapterFactory.GetAdapter().

Members

MemberType
BoundaryNamestringget
GetPointsVector3[]method

BoundaryName is the identifier/name of the active boundary.

GetPoints

method
Vector3[] GetPoints();

Returns the boundary outline as ordered points.

ReturnsVector3[]the boundary outline, as ordered points in Unity meters
⚠️ needs confirmation

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 class
public static class BoundaryAdapterFactory

Static registry/factory resolving and caching the active IBoundaryAdapter per platform.

Method summary

MethodReturns
GetAdapterIBoundaryAdapterstatic
GetAdapter(PlatformType)IBoundaryAdapterstatic
Register<T>voidstatic

Boundary · GetAdapter

methodstatic
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.

Parameters
platformPlatformTypeplatform to resolve the adapter for; see PlatformType
ReturnsIBoundaryAdapterthe cached adapter, or the default boundary adapter

Boundary · Register<T>

methodstatic
static void Register<T>(PlatformType platform) where T : IBoundaryAdapter, new();

Registers adapter type T for platform.

Parameters
platformPlatformTypeplatform the adapter type applies to
Differs from the hands/controller factories

Unlike HandsAdapterFactory and ControllerAdapterFactory, this uses an indexer assignment, so re-registering a platform overwrites the previous type rather than throwing.

See also

  • Hand dataHandJointInfo, HandJointType, and the hand-joint helpers returned by IHandsAdapter
  • CustomHandsAdapter — an in-scene MonoBehaviour that implements IHandsAdapter from Inspector-assigned transforms
  • ServiceManager — SDK lifecycle and the active PlatformType the factories resolve against
  • Class index — all Unity SDK types
Was this page helpful?