An Item View Slots Container presents a group of selectable Item slots through one consistent interaction model. Inventory Grid, Item Hotbar, Item Slot Collection View, and Item Shape Grid specialize that model for different jobs while reusing selection, click, Item Actions, descriptions, and Item movement.

For a typical character, use an Inventory Grid for the Bag and an Item Slot Collection View for Equipment. The player can select an Iron Sword in Bag, inspect it, run an Equip action, or move it to an Equipment slot without each panel inventing a different input flow.

Choose the right container

Start with the specialized page that matches the player-facing result:

Goal Continue with
Understand one selectable slot, its Item View, and restrictions Item View Slot
Show a scrollable or paged Bag, shop, or storage list Inventory Grid
Assign Items to quick-use positions without moving the source Items Item Hotbar
Show named Equipment positions backed by an Item Slot Collection Item Slot Collection View (Equipment)
Let Items occupy multiple cells in a finite layout Item Shape Grid
Filter or reorder the ItemInfo values shown by a grid Item Info Filter and Sorters
Move Items with drag and drop or keyboard/controller actions Move Items (Drag and Drop)

Filtering and sorting change the visible order; they do not reorder the underlying Inventory by themselves. Likewise, a Hotbar can monitor assigned Items without transferring them out of Bag. Choose the data behavior first, then customize the shared container options.

Create and inspect the slots

Create the specialized view from its UI Designer page, then select the generated container. The plain Item View Slots Container retrieves the Item View Slot children beneath Content when it initializes. Each slot normally contains an Item View that draws the assigned ItemInfo.

A configured hotbar Item View Slots Container with its Item View Drawer and category Item Action Set binding visible in the Inspector.

The important container fields are:

Inspector field Default Purpose
Container Name Empty Identifies this container to drop-action conditions and other rules. Use a distinct name such as Bag or Equipment.
Slot Cursor None Direct Item View Slot Cursor Manager reference.
Slot Cursor ID 1 Runtime lookup ID used when Slot Cursor is unassigned.
Inventory None Inventory used when a panel binding does not provide one.
Draw On Enable Off Schedules a redraw when the object becomes enabled. Leave it off for a panel that controls its own redraw.
Draw On Inventory Update On Schedules a redraw when the bound Inventory sends its update event.
Item View Drawer None Chooses and creates Item View prefabs through a Category Item View Set.
Swap Item View On Assign Off Replaces the slot’s Item View when a new ItemInfo is assigned. Enable only with a configured drawer.
Content None Parent containing the Item View Slot children; the container’s RectTransform is used when this is unassigned.

The container passes Content to its Item View Drawer during initialization. The drawer can choose a different prefab for Health Potion and Iron Sword based on the configured Category Item View Set. If every Item uses the same slot layout, keep Swap Item View On Assign off and let the existing Item View redraw.

An Item View Slot reads any Item View Slot Restriction components on its own GameObject. Container CanAddItem and CanMoveItem checks use those restrictions before assigning or swapping values. Specialized containers add their own Inventory or Item Collection rules.

Bind the Inventory and panel owner

Use an Item View Slots Container Panel Binding when the container belongs to a Display Panel. It initializes the container, assigns the panel, binds an Inventory, redraws on open, and controls the initial selection.

The Main Inventory Grid Display Panel with an Item View Slots Container Panel Binding that uses the panel owner's Inventory and selects a slot when opened.

The Inventory source is chosen in this order:

  1. An explicit Inventory reference, when assigned.
  2. The Display Panel Manager’s Panel Owner Inventory when Bind To Panel Owner Inventory is enabled. This is enabled by default.
  3. The Inventory registered to Bind To Inventory By Identifier, when the value is not 0 and panel-owner binding is disabled.

For a single-player Bag, panel-owner binding is usually the simplest choice. For a second local player or a panel that is not owned by the character, disable panel-owner binding and use the correct Inventory Identifier ID or explicit Inventory. Do not give two players the same identifier.

The panel binding’s runtime defaults are:

Inspector field Default Effect
Draw On Initialize Off Does not draw during binding initialization.
Reset Draw On Open On Resets view-specific state, then schedules a draw when the panel opens.
Draw On Open On Schedules a normal draw only when Reset Draw On Open is off.
Select Slot On Open On Selects index 0, or the remembered valid index.
Deselect Slot On Close On Deselects the current slot and clears the container selection.
Remember Selected Slot Off Returns to index 0 instead of the most recently selected index.

An Equipment Item Slot Collection View still needs the correct Equipment collection and Item Slot Set. The panel binding chooses the owning Inventory; the specialized view chooses the collection and maps its slots.

Configure selection, focus, and input

Item View Slots are Unity UI Action Buttons. The EventSystem drives selection and submit, while pointer clicks and drag events are forwarded through the container. Selecting a slot updates the container’s selected slot; submitting or clicking raises the click event and notifies the slot’s Item View modules.

For predictable keyboard and controller navigation:

  1. Keep one valid slot selected while the panel is active.
  2. Leave Select Slot On Open enabled unless another control deliberately receives focus.
  3. Use Remember Selected Slot only when returning to the previous slot is helpful.
  4. Leave Deselect Slot On Close enabled so a hidden panel does not keep focus.
  5. In local multiplayer, give each player the intended EventSystem/input ownership and Inventory binding; the container does not infer player ownership from its position in the hierarchy.

Selection and click are separate events. A description commonly redraws on selection, while an Item Action panel commonly opens on click or submit.

Add shared container behavior

The UI Designer’s Item View Slots Container Common Options page adds and edits the shared components on a generated container.

Item Actions

Choose one of these bindings:

  • Item View Slots Container Item Action Binding uses one Item Action Set and first checks whether that set matches the Item.
  • Item View Slots Container Category Item Action Set Binding selects actions by category. Max Number Of Actions defaults to 5 and sets initial array capacity. The array grows automatically to include every matching action; it does not limit the displayed list.

Both bindings use the container’s selected slot. Use Item On Click is enabled by default. With an Item Action Panel assigned, click opens that panel; without one, Use Item Action Index defaults to -1, which invokes every available action. For a Bag, a category set can offer Use for Health Potion and Equip for Iron Sword. Enable Disable Action On Empty Slots and Prevent Open When No Action when empty or unsupported slots should do nothing.

Auto Set Item User is enabled by default and takes the Item User from the bound Inventory. Indexed and named Item Action Handler components can trigger actions through input; Handle Input Only If Panel Selected prevents a hidden or background panel from responding.

Item descriptions and tooltips

An Item View Slot Container Description Binding passes the selected or optionally clicked slot’s ItemInfo to an Item Description. An Item View Slot Panel To Tooltip only places and shows a panel beside a slot; it does not supply description or action content. See Item Description for the exact binding defaults and tooltip setup.

Current Version 1 uses Anchor Relative Offset for tooltip placement. Configure Panel Bounds and test edge slots so the tooltip remains within the visible Canvas.

Item View Drawer

The Item View Drawer uses a Category Item View Set to choose the best matching Item View prefab. Category order and inheritance matter. Use it when Health Potion, Iron Sword, and other categories require structurally different slot views; use Item View Modules when the structure is shared and only the values differ.

Moving Items

Pointer drag and non-pointer movement share an Item View Slot Cursor Manager and Item View Drop Handler. The Drop Handler needs an Item View Slot Drop Action Set to decide whether a move, swap, transfer, or rejection occurs.

  • Add an Item View Slot Drag Handler for pointer drag and drop.
  • Add an Item View Slot Move Cursor for the Move Item Action used by keyboard or controller.
  • Put conflicting bindings, such as Item Actions, in Unbind While Moving so the placement click does not also invoke an Item Action.

Use the drop action set for movement between Bag and Equipment. Directly swapping the visible Item Views is not a substitute for a valid Inventory transaction.

How it runs

  1. The specialized container finds or creates its Item View Slots and initializes each slot index.
  2. It binds every Item View Slots Container Binding on the same GameObject.
  3. The panel binding assigns its Display Panel and resolves the Inventory from an explicit reference, panel owner, or Inventory Identifier.
  4. When the Inventory updates, Draw On Inventory Update schedules Draw().
  5. Draw() defers work until LateUpdate; ForceDraw() redraws immediately. The container assigns ItemInfo values to Item Views and raises OnDraw after the redraw.
  6. Selection, click, pointer, and drag events include the container, slot, current ItemInfo, local slot index, and any specialized index offset.
  7. Description, Item Action, movement, and other bindings respond to the same container events.

The base container coordinates UI. Inventory Grid, Item Slot Collection View, Item Shape Grid, and hotbar variants override add, remove, or move behavior to match their data source. Use the specialized container API when a change must affect the Inventory or Item Collection.

Editor checkpoint

Before entering Play Mode, confirm that:

  • Content contains the expected number of active Item View Slots and each slot has an Item View;
  • Container Name is meaningful and unique wherever drop conditions use it;
  • the Slot Cursor reference or Slot Cursor ID resolves to the Canvas manager used by this player;
  • the Category Item View Set has a valid fallback and mappings for Health Potion and Iron Sword;
  • the panel binding references this container and resolves the intended Inventory;
  • Bag and Equipment do not accidentally bind to another player’s Inventory Identifier;
  • Item Action bindings have a valid Item Action Set or Category Item Action Set and intended Item User;
  • description and action bindings sit on the same GameObject as the container;
  • movement has a Cursor Manager, Drop Handler, Drop Action Set, and the correct pointer or Move Cursor handler; and
  • Equipment uses the intended Item Slot Collection and compatible Item Slot Set.

Verify in Play Mode

  1. Open Bag. Slot 0 or the remembered valid slot should receive focus, and the grid should show the bound Inventory.
  2. Navigate with keyboard/controller and pointer. Selection, submit, and click should affect only the active player’s panel.
  3. Select Health Potion and Iron Sword. The Item Description should replace its content without stale values.
  4. Submit Health Potion and confirm the intended Use action or action panel appears. Empty slots should remain inactive when configured.
  5. Move Iron Sword from Bag to a valid Equipment slot. Both data collections and both views should update.
  6. Attempt an invalid Equipment drop. The drop action set and slot restrictions should reject it without losing the Item.
  7. Close and reopen the panel. Confirm the reset or remembered-selection behavior and ensure the hidden panel no longer receives input.
  8. Change the Inventory from code or another system and confirm Draw On Inventory Update refreshes the visible slots.

Save and network boundaries

ItemViewSlotsContainerBase does not save UI selection, focus, tooltip position, or a pending cursor move. Save the underlying Inventory, Item Collections, hotbar assignment data where supported, and mutable Items through the relevant UIS save components. Reopen or redraw the container after loading.

These Version 1 UI classes do not replicate Inventory transactions or assign network ownership. A networking integration must authorize and synchronize the underlying data change, then refresh each client’s local container. Do not treat AssignItemToSlot on a generic UI container as a networked Inventory transfer.

Troubleshooting

  • The container has no slots: Check Content and confirm its active children have Item View Slot components with Item View children.
  • The first open is blank: Check the panel binding’s Inventory source, Reset Draw On Open, and Draw On Open. Remember that Draw() completes in LateUpdate.
  • The wrong character’s Items appear: Check the Display Panel Manager’s Panel Owner, Bind To Panel Owner Inventory, and Bind To Inventory By Identifier. An explicit Inventory reference takes priority.
  • Opening the panel selects the wrong slot: Check Remember Selected Slot and the last recorded index; invalid remembered indices fall back to 0.
  • A background panel responds to input: Enable Handle Input Only If Panel Selected on its Item Action Handler and verify EventSystem ownership.
  • Every Item uses the same appearance: Check Item View Drawer, Swap Item View On Assign, and Category Item View Set matching order.
  • Clicking an Item runs several actions: With no Action Panel, -1 for Use Item Action Index invokes all actions. Assign a panel or choose one index.
  • A description or action binding never updates: Place the binding on the same GameObject as the container and verify its target references.
  • Dragging moves the picture but not the Item: Check the Drop Handler and Item View Slot Drop Action Set. The cursor visual is not the Inventory transaction.
  • Keyboard movement also invokes an Item Action: Add the action binding to Unbind While Moving on Item View Slot Move Cursor.
  • A tooltip uses an unexpected offset: Recheck the current Anchor Relative Offset and Panel Bounds rather than copying the retired Anchor Offset label from older screenshots.

Developer details

  • ItemViewSlotsContainerBase exposes ItemViewSlots, SlotCount, Inventory, Panel, ContainerName, SelectSlot(int), and GetSelectedSlot().
  • Use GetItemViewSlot(int), GetItemViewAt(int), and GetItemAt(int) to inspect a slot. GetItemViewAt is the current Version 1 method name.
  • Draw() schedules a redraw; ForceDraw() performs it immediately; ResetDraw() lets a specialized container restore its initial navigation or paging state.
  • AddItem, RemoveItem, CanMoveItem, and MoveItem are virtual. Their data effects depend on the specialized container.
  • Selection events are OnItemViewSlotSelected, OnItemViewSlotDeselected, and OnItemViewSlotClicked. Pointer events include OnItemViewSlotPointerDownE, OnItemViewSlotBeginDragE, OnItemViewSlotDragE, OnItemViewSlotEndDragE, and OnItemViewSlotDropE.
  • ItemViewSlotEventData exposes ItemViewSlotsContainer, ItemViewSlot, ItemView, ItemInfo, SlotIndex, SlotIndexOffset, and ItemIndex.
  • OnBindInventory, OnUnBindInventory, OnDraw, and OnResetDraw support custom bindings. Unsubscribe custom handlers when their owner is destroyed or unbound.
  • SetOneTimeClickAction(ItemViewSlotActionEvent) intercepts the next submit/click event and can stop normal propagation when constructed with stopPropagation: true.