Skip to main content

ObjectTransformConsumer

sealed class · Singleton<ObjectTransformConsumer> Unity component singleton
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.

How-to

This page is reference (facts only). For the step-by-step feed transforms → drive objects walkthrough, see the How-to guide.

Properties

PropertyTypeDefaultDescription
Tracked state
ObjectInfoByIdIDictionary<string, ObjectInfo>read access to all tracked objects, keyed by id (get-only)
Prefabs
PrefabsGameObject[]prefab pool, matched by name to an object's Type; Prefabs[0] is the fallback when no name matches
Lifetime timeouts
InactiveObjectMaxSecondsfloat1fseconds without updates before an object's GameObject is destroyed
HideObjectMaxSecondsfloat1f / 60seconds without updates before an object's GameObject is hidden
UseSkeletonConsumerParametersboolfalsewhen true, use SkeletonConsumer's inactive/hide timeouts instead of the two fields above

Method summary

Instance

MethodReturns
OnObjectvoidUnity component
UpdatevoidUnity callback

→ Full descriptions in Method details below.

Method details

OnObject

methodinstance
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).

Parameters
objectTransformObjectTransformthe object's pose — id, type, position (m), rotation, and scale
Exampleinferred
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

methodUnity callback
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

class
public 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.

PropertyTypeDescription
Identity
Idstringobject identifier
Typestringobject type — used to select the prefab by name
GameObject
GameObjectGameObjectthe spawned GameObject
TransformTransformcached transform of that GameObject
IsVisibleboolgets/sets the GameObject's active state
Timing
LastUpdateTimefloatTime.time (seconds) of the last update
TimeFromLastUpdatefloatseconds elapsed since LastUpdateTime (get-only)
Exampleinferred
// 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

Was this page helpful?