Skip to content

SusInventoryGrid

SusInventoryGrid

Packed bag mesh — rebuilds cells + SusInventoryItem icons from InventoryGrid + InventoryModel, DnD / click-to-place / context menu.

Package

SusGame · Inventory (commercial)

Open in Playground

SusGame · Inventory

Props

No public props.

Slots

No slots.

Events

NameFieldPayload
ItemDragStartOnItemDragStartSusInventoryItem
ItemDragEndOnItemDragEndSusInventoryItem
ItemDraggingOnItemDraggingSusInventoryItem, Vector2
ItemClickedOnItemClickedSusInventoryItem
EmptyCellClickedOnEmptyCellClickedint, int
ItemContextActionOnItemContextActionstring, SusInventoryItem

Style hooks

USS class contract — override appearance without touching C#. States toggle via these classes:

  • sus-inventory-grid

Usage

Prefer parent SusInventory via SusInventorySession — the shell assigns Grid / Model and calls Refresh. Standalone:

csharp
var grid = new SusInventoryGrid();
grid.Model = model;
grid.Grid = model.Grids["bag"];
grid.CellSize = 48f;
grid.CellGap = 0f;           // pitch = CellSize + CellGap
grid.ItemMedia = "image";    // image | icon
grid.CellLayout = "grid";    // grid (multi-cell) | slots (1×1)
grid.GhostHost = ghostOverlay;
grid.IconResolver = myResolver;
grid.OnItemClicked += item => { /* select */ };
grid.OnEmptyCellClicked += (x, y) => { /* click-to-place */ };
grid.OnItemDragStart += item => { /* … */ };
grid.OnItemContextAction += (action, item) => { /* equip|unequip|delete */ };
grid.Refresh();
xml
<template>
  <sus:SusInventoryGrid />
</template>

<script>
// No Prop<> on the grid — assign Grid / Model / sizes from C#, then Refresh.
// Events: OnItemDragStart|End|Dragging, OnItemClicked, OnEmptyCellClicked, OnItemContextAction.
</script>
Prop / APIRole
Grid / ModelCells from Grid.Def; icons from Grid.Items + ItemDefs
CellSize / CellGapPixel size + gap (pitch)
ItemMedia / CellLayoutForwarded to items / footprint resolve
Refresh() / SyncItems()Full rebuild vs item-icon sync
HighlightCells / HighlightDropPreview / ClearHighlightDnD preview
OnItem* / OnEmptyCellClickedItem & empty-cell events

Notes

  • Empty until Grid + Grid.Def are set and Refresh runs.
  • Multi-cell items span ItemDef footprint (grid); slots forces 1×1.
  • Prefer the grid over hand-placing SusInventoryCell / SusInventoryItem when you need shared DnD.