Item Object Visualizer displays the model or sprite for the Item currently assigned to a reusable world object. A pooled pickup can keep its interaction components while Health Potion, Iron Sword or Fire Wand supplies a different visual. Inventory transfers, equipment ownership and gameplay effects use their own components.

Configure the visual source

  1. Initialize Inventory System Manager with the intended database and add Item Object to the reusable GameObject.
  2. Declare a GameObject Definition attribute named PickupPrefab and assign each Definition’s visual prefab.
  3. Create an empty child Transform reserved exclusively for generated visuals.
  4. Add Item Object Visualizer beside Item Object and configure:
Field Default / purpose
Prefab Attribute Name Serialized empty; initialization uses PickupPrefab. Enter an exact custom attribute name when needed.
Item Prefab Visualizer Parent Unassigned falls back to the component’s Transform. Prefer the dedicated empty child.
Default Visual Prefab Unassigned. Assign a fallback for Items without the named typed attribute.
Item View Optional world-space name/icon/amount presentation.

Choose Update Item Visuals from the component context menu for an Edit Mode preview.

Item Object Visualizer Inspector with an empty Prefab Attribute Name, Item Object Parent, ItemPickupBag default visual, and Panel Item View

The legacy image uses a dedicated Item Object Parent, ItemPickupBag fallback and Panel Item View. Keep the selected prefab focused on presentation: a child that contains another visualizer resolving the same prefab can recursively instantiate itself.

Attribute ownership and fallback

Lookup order is Item, Definition, then Category. Definition/Category attributes suit shared appearances; a mutable, usually unique Item Attribute suits an independent per-copy visual override. A declared attribute must reference a valid non-null prefab. Default Visual Prefab is selected only when the typed attribute is absent.

For an equipped reusable shell, use a separate child-visual attribute. Equipper already owns its EquipmentPrefab/UsableItemPrefab representation; avoid pointing the child visualizer back at that shell.

Refresh and clear the visual

On initialization, Item Object Visualizer finds its sibling Item Object and validates the Item. While enabled, it listens for c_ItemObject_OnItemChanged and redraws immediately.

Each redraw clears the optional Item View, removes the last child under its reserved parent, updates the view with current ItemInfo and creates the resolved prefab. Play Mode uses Opsive Object Pool; Edit Mode creates a normal preview. Removed pooled children return to the pool; other children are destroyed.

Call ItemObject.SetItem to change the represented Item. Pass ItemInfo.None to clear the generated visual and Item View. For an attribute-only change on the same Item, call UpdateVisual() explicitly. Disabling the component unregisters its listener while retaining its current child; clear or hide that child when the project needs it invisible during disable. Re-enabling redraws the current Item.

Reserve the parent for this component so last-child replacement cannot remove unrelated objects.

Add a world-space Item View

Assign a configured Item View to display the current ItemInfo above the pickup. It receives ItemInfo.None when the visual clears. The Setup Manager’s Item Pickup template can create Model Parent, the visualizer and an optional Item View Canvas; its Default Pickup Model Prefab supplies the fallback, and Item View Prefab must have Item View on its root.

Choose Canvas World Space when it should follow the pickup. Add the Canvas to selection indicators so select/deselect controls its visibility. For a manual setup, create and connect that Canvas explicitly. Use normal Item View modules for inventory-grid cells.

Show one representative Inventory Item

Inventory Item Visualizer uses the same four fields and a sibling Inventory:

Inventory Item Visualizer Inspector with an empty Prefab Attribute Name, Item Object Parent, InventoryPickupBag default visual, and Panel Item View

On enable and c_Inventory_OnUpdate, it scans AllItemInfos for the first non-null Item declaring the configured GameObject attribute. If none qualifies, it uses the first non-null Item, then normal attribute/fallback lookup.

This shows one model for a chest, loot bag or Inventory Pickup. Inventory order determines the first match. Keep one eligible representative for deterministic presentation, or use Item Object Visualizer with an explicitly chosen Item. Customize selection for multi-model or priority-driven displays.

Verify and restore presentation

Bind Iron Sword, then Fire Wand: the parent settles to the corresponding model and the Item View follows its ItemInfo. Test an Item without the attribute and verify the fallback. Change an independent visual override, call UpdateVisual() and confirm only that representation changes. Clear the Item, disable/re-enable the component and check its intended visibility. For Inventory Item Visualizer, change the sole qualifying Item and confirm the Inventory update selects it.

Save authoritative Item identity, amount and mutable/unique data, then rebind after load. Generated children and pool-instance identities are transient. In multiplayer, replicate Item identity/visual-driving values and refresh local presentation.

Symptom Check
No model or fallback Exact GameObject attribute type/name, initialized Item, non-null declared value or fallback.
Unrelated/duplicate children Dedicated parent and other code adding children or bypassing refresh.
Attribute edit is invisible Call UpdateVisual() after an in-place value change.
Unexpected Inventory representative Eligibility and Inventory order; choose the representative explicitly if needed.
Empty world label Item View modules and valid ItemInfo/amount.

ItemVisualizerBase.ItemView assigns the view; UpdateVisual(ItemInfo) accepts explicit data and concrete parameterless UpdateVisual() rereads its source. Override protected SetVisualInternal/RemoveVisualInternal for another lifecycle or selection policy.

See Item Objects, Item Pickups, Equipping Items, Common Attributes, Defining Attributes, Item Views, Inventory, Save System and Events.