Scene components & anchors
A cluster of small MonoBehaviours you drop on scene GameObjects to visualize spatial anchors and the play-area boundary, constrain a transform, billboard toward the camera, or feed Inspector-assigned hand transforms into the SDK as an adapter.
This is a Unity SDK page — all positions, lengths, and heights are in Unity world-space meters; rotations are Quaternion; angles are in degrees.
Five components live here:
| Component | Namespace | Role |
|---|---|---|
AnchorVisualization | AR51.Unity.SDK | save/disable UI control for a visual spatial anchor |
BoundaryVisualization | AR51.Unity.SDK | builds a wall mesh + outline for a recorded play-area boundary |
ConstrainPosition | AR51.Unity.SDK.Components | copies a source transform's position each frame |
CustomHandsAdapter | AR51.Unity.SDK.Components | in-scene IHandsAdapter driven by Inspector transforms |
FaceCamera | AR51.Unity.SDK.Components | yaw-billboards this GameObject toward the camera |
AnchorVisualization
class · MonoBehaviour Unity componentpublic class AnchorVisualization : MonoBehaviour
Namespace: AR51.Unity.SDK
A localized UI/control entry for an AR 51 visual spatial anchor. Attach it to a GameObject; it exposes save/disable requests both as code events and as an Inspector-wireable UnityEvent, so anchor UI (buttons, gestures) can drive persistence without your script knowing the anchor internals.
Events
| Event | Type | Fires when |
|---|---|---|
OnSaveRequest | EventHandler | RequestSave() is called |
OnDisableRequest | UnityEvent | RequestDisable() is called — wire it in the Inspector |
Method summary
| Method | Returns | |
|---|---|---|
RequestSave | void | Unity component |
RequestDisable | void | Unity component |
CallOnSaveRequest | AnchorVisualization | fluent |
RequestSave
public void RequestSave();
Raises OnSaveRequest. Call from your save button/gesture to ask whatever subscribed (e.g. anchor-persistence logic) to save this anchor.
RequestDisable
public void RequestDisable();
Invokes the OnDisableRequest UnityEvent. Use it to tear down or hide the anchor visualization; wire the response in the Inspector.
CallOnSaveRequest
public AnchorVisualization CallOnSaveRequest(EventHandler handler);
Subscribes handler to OnSaveRequest and returns this instance, so you can chain configuration fluently.
// Subscribe fluently, then keep configuring on the same line.
anchorViz
.CallOnSaveRequest((s, e) => Debug.Log("Anchor save requested"));
BoundaryVisualization
class · MonoBehaviour Unity component RequireComponentpublic class BoundaryVisualization : MonoBehaviour
Namespace: AR51.Unity.SDK
Builds a wall mesh plus an outline for a recorded play-area boundary. Requires a MeshFilter + MeshRenderer on the same GameObject and expects a child LineRenderer for the outline. Set the fields before Start — the mesh is built at startup from Points and Height. If Id matches the active boundary's name the wall renders red; otherwise an auto-color is chosen. Feed it from a boundary source such as IBoundaryAdapter.GetPoints().
Properties
| Property | Type | Description |
|---|---|---|
Id | string | boundary identifier — matches the active boundary's name → renders red, else auto-color |
Points | Vector3[] | ordered ground-plane outline points. ⚠️ world-space, meters. Fewer than 4 points skips the mesh |
Height | float | wall height in meters, extruded along +Y |
Visible | bool | get/set — toggles wall + outline rendering |
// Visualize the platform boundary reported by the active boundary adapter.
var viz = boundaryGO.GetComponent<BoundaryVisualization>();
viz.Id = BoundaryAdapterFactory.GetAdapter().BoundaryName;
viz.Points = BoundaryAdapterFactory.GetAdapter().GetPoints(); // world-space meters
viz.Height = 2.5f; // meters
// Set before Start; the wall mesh is built at startup.
ConstrainPosition
class · MonoBehaviour Unity componentpublic class ConstrainPosition : MonoBehaviour
Namespace: AR51.Unity.SDK.Components
A position-only follow constraint. Each Update it copies Source's world position onto this GameObject (rotation and scale are left untouched). A null Source is a no-op.
Properties
| Property | Type | Description |
|---|---|---|
Source | Transform | the transform to follow each frame; null = no-op |
// Pin a label to a tracked joint's world position without inheriting its rotation.
labelGO.GetComponent<ConstrainPosition>().Source = headBoneTransform;
CustomHandsAdapter
class · MonoBehaviour Unity component IHandsAdapterpublic class CustomHandsAdapter : MonoBehaviour, IHandsAdapter
Namespace: AR51.Unity.SDK.Components
An in-scene IHandsAdapter driven by Inspector-assigned Transforms instead of a device tracker. It samples the mapped transforms each request and reports them as HandJointInfo with Confidence = 1.0, and can keep the wrist anchored to a tracked source. Joint arrays are assembled on Awake. Use it to puppet hands from authored/animated transforms, or as a stand-in when no hardware hand tracking is present.
This is the scene-component counterpart to the registry-based adapters. For the adapter interface, the factory, and how the SDK resolves an active adapter per platform, see Hands, controllers & boundary adapters.
Properties
| Property | Type | Description |
|---|---|---|
SourceDevice | string | get-only — always "CustomHandModel" |
WristTrackingMode | WristTrackingModeType | how the wrist is driven: None / TrackActivePerson / TrackDeviceAdapter |
LeftHand | HandMapping | Inspector bone-transform mapping for the left hand |
RightHand | HandMapping | Inspector bone-transform mapping for the right hand |
Method summary
| Method | Returns | |
|---|---|---|
GetRightJointInfos / GetLeftJointInfos | HandJointInfo[] | IHandsAdapter |
GetJoints | Transform[] | Unity component |
GetHand | HandMapping | Unity component |
GetRightJointInfos / GetLeftJointInfos
public HandJointInfo[] GetRightJointInfos();
public HandJointInfo[] GetLeftJointInfos();
The IHandsAdapter snapshot methods. Each joint is sampled from the assigned transforms with Confidence = 1.0; order follows the HandJointType enum (index = (int)HandJointType).
GetJoints
public Transform[] GetJoints(HandType type);
The assembled joint transforms for a hand (wrist + fingers, SDK order).
GetHand
public HandMapping GetHand(HandType type);
Returns the HandMapping for the given hand.
Nested types
[Serializable] HandMapping holds the per-hand transform mapping (Type, Source, Wrist, and the per-finger groups). Each finger group — ThumbJoints, IndexJoints, MiddleJoints, RingJoints, PinkyJoints — is a serializable struct of Transform fields with a Transform[] ToArray() returning them base→tip. Assign these in the Inspector.
FaceCamera
class · MonoBehaviour Unity componentpublic class FaceCamera : MonoBehaviour
Namespace: AR51.Unity.SDK.Components
A yaw-only billboard. Each frame it rotates this GameObject about the Y axis to face the camera; pitch is ignored, so upright labels and panels stay level. Falls back to Camera.main when Camera is unset; a null camera is a no-op.
Properties
| Property | Type | Description |
|---|---|---|
Camera | Camera | target camera; falls back to Camera.main, null = no-op |
// Keep a world-space name tag turned toward the player's view, staying upright.
tagGO.AddComponent<FaceCamera>(); // uses Camera.main by default
See also
- Hands, controllers & boundary adapters — the
IHandsAdapter/IBoundaryAdapterinterfaces and factoriesCustomHandsAdapterandBoundaryVisualizationwork with HandJointInfo— the per-joint sampleCustomHandsAdapterreportsObjectTransform— pose data for the object/transform consumers- Class index — all Unity SDK types