# ObjectTransformConsumer

<Badge tone="type">sealed class · Singleton&lt;ObjectTransformConsumer&gt;</Badge> <Badge>Unity component</Badge> <Badge>singleton</Badge>

```csharp
public sealed class ObjectTransformConsumer : Singleton<ObjectTransformConsumer>
```

**Namespace:** `AR51.Unity.SDK` · **Inherits:** [`Singleton<ObjectTransformConsumer>`](/docs/sdk-api/unity-api/connection) *(MonoBehaviour)*

Receives generic object transforms — an [`ObjectTransform`](/docs/sdk-api/unity-api/classes/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**.

:::tip[How-to]
This page is **reference** (facts only). For the step-by-step *feed transforms → drive objects* walkthrough, see the [How-to guide](/docs/sdk-api/unity-api/object-detection).
:::

## Properties

<div className="apiPropTable">

| Property | Type | Default | Description |
|---|---|---|---|
| **Tracked state** | | | |
| `ObjectInfoById` | [`IDictionary<string, ObjectInfo>`](#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`](/docs/sdk-api/unity-api/classes/skeletonconsumer)'s inactive/hide timeouts instead of the two fields above |

</div>

## Method summary

**Instance**

| Method | Returns | |
|---|---|---|
| [`OnObject`](#onobject) | `void` | <Badge>Unity component</Badge> |
| [`Update`](#update) | `void` | <Badge>Unity callback</Badge> |

→ Full descriptions in [Method details](#method-details) below.

## Method details

### OnObject

<ApiBody kind="method" tags="instance">

```csharp
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)**.

<Params>
<Param name="objectTransform" type="ObjectTransform" typeHref="/docs/sdk-api/unity-api/classes/objecttransform">the object's pose — id, type, position (m), rotation, and scale</Param>
</Params>

<Example inferred>

```csharp
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
```

</Example>

</ApiBody>

### Update

<ApiBody kind="method" tags="Unity callback">

```csharp
public void Update();
```

Per-frame housekeeping: hides objects idle longer than `HideObjectMaxSeconds` and destroys objects idle longer than `InactiveObjectMaxSeconds` (or the [`SkeletonConsumer`](/docs/sdk-api/unity-api/classes/skeletonconsumer) timeouts when `UseSkeletonConsumerParameters` is set). This is the Unity `Update` callback; it runs automatically and is rarely called by hand.

</ApiBody>

## ObjectInfo

<Badge tone="type">class</Badge>

```csharp
public class ObjectInfo
```

State record for one tracked object's GameObject, held by [`ObjectInfoById`](#properties). A plain class (not a MonoBehaviour). It pairs the object's identity (`Id`, `Type`) with its spawned GameObject and update bookkeeping.

<div className="apiPropTable">

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

</div>

<Example inferred>

```csharp
// 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
}
```

</Example>

## See also

- [`ObjectTransform`](/docs/sdk-api/unity-api/classes/objecttransform) — the pose data class passed to `OnObject`
- [`ObjectDetectionConsumer`](/docs/sdk-api/unity-api/classes/objectdetectionconsumer) — the related consumer for detected markers and 6-DoF objects
- [`SkeletonConsumer`](/docs/sdk-api/unity-api/classes/skeletonconsumer) — source of the inactive/hide timeouts when `UseSkeletonConsumerParameters` is set
- [`XRHeadsetTracker`](/docs/sdk-api/unity-api/classes/xrheadsettracker) — feeds XR device poses into this consumer as `"XR"` object transforms
- [Class index](/docs/sdk-api/unity-api/classes) — all Unity SDK types
