ObjectTransformConsumer
public sealed class ObjectTransformConsumer : Singleton<ObjectTransformConsumer>
Namespace: AR51.Unity.SDK · Inherits: Singleton<ObjectTransformConsumer> (MonoBehaviour)
Receives generic object transforms — an ObjectTransform carrying id, type, position, rotation, and scale — and maintains a matching set of prefab GameObjects, one per object id. As transforms arrive it spawns or updates the corresponding GameObject; objects that stop updating are hidden after HideObjectMaxSeconds and destroyed after InactiveObjectMaxSeconds. A MonoBehaviour; drop it on a scene GameObject and reach the live instance through the static Instance.
All positions/rotations/scales are in Unity world space, lengths in meters, angles in degrees.
This page is reference (facts only). For the step-by-step feed transforms → drive objects walkthrough, see the How-to guide.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| Tracked state | |||
ObjectInfoById | IDictionary<string, ObjectInfo> | — | read access to all tracked objects, keyed by id (get-only) |
| Prefabs | |||
Prefabs | GameObject[] | — | prefab pool, matched by name to an object's Type; Prefabs[0] is the fallback when no name matches |
| Lifetime timeouts | |||
InactiveObjectMaxSeconds | float | 1f | seconds without updates before an object's GameObject is destroyed |
HideObjectMaxSeconds | float | 1f / 60 | seconds without updates before an object's GameObject is hidden |
UseSkeletonConsumerParameters | bool | false | when true, use SkeletonConsumer's inactive/hide timeouts instead of the two fields above |
Method summary
Instance
| Method | Returns | |
|---|---|---|
OnObject | void | Unity component |
Update | void | Unity callback |
→ Full descriptions in Method details below.
Method details
OnObject
public void OnObject(ObjectTransform objectTransform);
Creates (if the id is new) or updates the GameObject for the given transform, setting its position, rotation, and scale and marking it active and updated. The prefab is chosen by matching the object's Type to a name in Prefabs, falling back to Prefabs[0]. No-op if the consumer is disabled or Prefabs is empty. Position, rotation, and scale are applied in Unity world space (meters / degrees).
var consumer = ObjectTransformConsumer.Instance;
// Feed a pose for object "drone-1" of type "Drone" (meters, world space).
consumer.OnObject(new ObjectTransform(
"drone-1", "Drone",
new Vector3(0.5f, 1.2f, 2.0f), // position, meters
Quaternion.Euler(0f, 90f, 0f))); // rotation, degrees
Update
public void Update();
Per-frame housekeeping: hides objects idle longer than HideObjectMaxSeconds and destroys objects idle longer than InactiveObjectMaxSeconds (or the SkeletonConsumer timeouts when UseSkeletonConsumerParameters is set). This is the Unity Update callback; it runs automatically and is rarely called by hand.
ObjectInfo
classpublic class ObjectInfo
State record for one tracked object's GameObject, held by ObjectInfoById. A plain class (not a MonoBehaviour). It pairs the object's identity (Id, Type) with its spawned GameObject and update bookkeeping.
| Property | Type | Description |
|---|---|---|
| Identity | ||
Id | string | object identifier |
Type | string | object type — used to select the prefab by name |
| GameObject | ||
GameObject | GameObject | the spawned GameObject |
Transform | Transform | cached transform of that GameObject |
IsVisible | bool | gets/sets the GameObject's active state |
| Timing | ||
LastUpdateTime | float | Time.time (seconds) of the last update |
TimeFromLastUpdate | float | seconds elapsed since LastUpdateTime (get-only) |
// Inspect tracked objects and their staleness.
foreach (var info in ObjectTransformConsumer.Instance.ObjectInfoById.Values)
{
if (info.TimeFromLastUpdate > 0.5f) // seconds since last update
info.IsVisible = false; // hide stale object's GameObject
var worldPos = info.Transform.position; // meters, world space
}
See also
ObjectTransform— the pose data class passed toOnObjectObjectDetectionConsumer— the related consumer for detected markers and 6-DoF objectsSkeletonConsumer— source of the inactive/hide timeouts whenUseSkeletonConsumerParametersis setXRHeadsetTracker— feeds XR device poses into this consumer as"XR"object transforms- Class index — all Unity SDK types