reference
API reference
The public surface, condensed. Everything is in the flat InventorySystem namespace; all types carry full XML documentation in-source, so IntelliSense has the details.
InventoryController (grid)
| Member | Type | Description |
|---|---|---|
| Initialize() | bool | Builds grid, placer, and save system; runs automatically in Start. Idempotent. |
| AddItem(data, position?, rotated?) | virtual bool | Place at a cell, or auto-place when position is null (retries rotated for rotatable items). |
| RemoveItem(id) / MoveItem(id, pos, rotated?) / RotateItem(id) | virtual bool | Mutations by instance ID. |
| GetItemAt(pos) | ItemInstance | Occupant of a cell, or null. |
| CanPlaceItem(data, pos, rotated?) / CanPlaceItemIgnoring(…, ignoreID) | bool | Placement validation; the Ignoring variant supports move-in-place checks. |
| FindFirstAvailablePosition(data, rotated?) | Vector2Int | First fitting cell, or (-1,-1). |
| SplitStack(id, amount, destination) | bool | Splits a stack onto a destination cell. |
| WouldMergeAt(source, dest) / TryPlaceDraggedItem(source, dest) | bool | The drag-and-drop pipeline: merge prediction and verified placement. |
| TransferItemTo(target, item, preferredDest) | bool | Cross-grid move to a preferred cell, with merge support and rollback. |
| OrganizeTopLeft/TopRight/BottomLeft/BottomRight(allowRotate?) | bool | Auto-pack the grid into a corner. |
| ResizeGrid(w, h) | bool | Rebuilds the grid — destructive to current placements. |
| SaveInventory(file?) / LoadInventory(file?) | bool | JSON persistence (default file per inventory type). |
| CanAddItem / CanRemoveItem / CanPerformAction | virtual bool | Permission gates — override for game rules; defaults allow everything. |
| OnItemAdded / OnItemRemoved | event Action<ItemInstance> | Item entered/left this inventory. |
| OnInventoryChanged | event Action | Any state change. |
| Grid / Placer / GridWidth / GridHeight / InventoryType / InventoryId | props | State access. Plus enums InventoryType { Player, Shop, Stash } and InventoryAction { AddItem, RemoveItem, MoveItem, RotateItem }. |
SlotInventoryController & HotbarController
| Member | Type | Description |
|---|---|---|
| AddItem(data) / AddItems(data, count) / AddItemAt(data, slot, count?) | bool | Slot placement; AddItems is all-or-nothing with rollback. |
| MoveItem(id, newSlot) | bool | Move to empty, merge into same-type stack, or swap. |
| GetItemAt(slot) / FindItemSlot(id) / FindFirstFreeSlot() | query | Lookups by index / instance ID. |
| OnItemMoved | event Action<ItemInstance,int,int> | Slot-only extra event: (item, oldIndex, newIndex). |
| ItemDataResolver | static Func<int,ItemData> | Override save-load item lookup (Addressables, custom catalogs). |
| HotbarController.OnSlotActivated | event Action<int,ItemInstance> | Digit key or click activated a slot; item is null for empty slots. |
| HotbarController.ActivateSlot(i) / BaseSlot / ListenForNumberKeys | members | Manual activation, key offset, and built-in polling switch. |
EquipmentController & EquipmentSlot
| Member | Type | Description |
|---|---|---|
| Equip(data) / EquipAt(data, slot) / Unequip(slot) | bool | Typed placement into paper-doll slots. |
| FindAcceptingSlot(data) / FindAcceptingSlotIndex(data) | query | First empty slot whose accepted types match the item. |
| OnItemEquipped / OnItemUnequipped | event Action<ItemInstance, EquipmentSlotType> | Loadout changes, with the resolved slot type — hang stat recalculation here. |
| EquipmentSlot.CanAccept(data) | bool | True when empty and the item’s EquipSlot is in acceptedTypes. |
| EquipmentSlot.AcceptedTypes / SlotLabel / CurrentItem / IsEmpty | props | Slot configuration and state. |
Data types
| Member | Type | Description |
|---|---|---|
| ItemData | ScriptableObject | Definition: ItemName, Description, Icon, ItemID, Width/Height, CanRotate, Stackable/MaxStackSize, Category, Rarity, IsEquippable/EquipSlot. Plus GetShape(), CanStackWith(), ValidateConfiguration(), BackgroundColor/AccentColor. |
| ItemInstance | class | Runtime state: Position, StackCount, IsRotated, Condition (0–1), CustomName, CurrentWidth/Height. Methods: Rotate(), AddToStack(), RemoveFromStack(), SetCondition(), SetCustomName(), GetOccupiedPositions(). Event: OnInstanceChanged. |
| ItemCategory | enum | Weapon, Armor, Consumable, Tool, Misc, QuestItem. |
| ItemRarity | enum | Common, Rare, Epic, Legendary, Unique. |
| EquipmentSlotType | enum | None, Helm, Chest, Legs, Boots, Gloves, Shoulders, Cloak, MainHand, OffHand, Ring1, Ring2, Amulet, Belt, Trinket (stable ints 0–14). |
| RarityPaletteSO | ScriptableObject | Rarity→color mapping. Statics: Current (assignable), Active (Current ?? defaults), DefaultColorFor(rarity). Pair with RarityPaletteApplier for no-code activation. |
| GridData / GridSlot | class | Pure grid occupancy model — dimensions, per-cell occupancy, no UI. Exposed via InventoryController.Grid. |
Transfers & economy
| Member | Type | Description |
|---|---|---|
| InventoryTransfer.TransferItem(source, target, id | item) | static bool | Overloads for grid pairs and any IInventory pair; auto-placement with rollback on failure. |
| OnItemTransferred / OnTransferFailed | static events | Grid-overload family: (source, target, newInstanceID, fromPos, toPos) / (…, reason). Note the new instance ID. |
| OnAnyItemTransferred / OnAnyTransferFailed | static events | IInventory-overload family: (source, target, item) / (source, target, id, reason). |
| IEconomy | interface | GetBuyPrice, GetSellPrice, CanPlayerBuy, CanShopBuy, ApplyPlayerBought, ApplyPlayerSold. |
| EconomyProvider.Current | static IEconomy | The active economy; null means all trades are free. |
| IInventory | interface | Unified container contract implemented by all four controllers: Items, CanAccept, AddItem(data, count), RemoveItem(instance). |
Persistence & UI singletons
| Member | Type | Description |
|---|---|---|
| SaveSystem | class | SaveInventory/LoadInventory, GetSaveFiles, SaveFileExists, GetSaveFileInfo, CreateBackup, DeleteSave. Atomic writes with .bak recovery; files under persistentDataPath/InventorySaves/{Type}/. |
| ItemDataCache | static class | Session cache for ID→ItemData resolution (Resources scan). Clear() after creating items at runtime. |
| ItemTooltip | singleton | Self-spawning hover tooltip. Statics: ShowDelayed(item, owner), HideFor(owner), HideImmediate(); content builders BuildInfoLine/BuildStatsLine/BuildEquipLine are reusable in your own UI. |
| TooltipHover | component | Auto-attached hover trigger; SetResolver(() => item) if you build custom item visuals. |
| StackSplitDialog | singleton | Self-spawning split dialog: ShowDialog(item, onConfirmed, onCancelled?) / HideDialog(). |
| ItemValidator | static class | Pure placement/collision math behind the controller — useful for custom previews. Throws on null args. |
| InventoryAPI | static class | Global convenience over the first scene controller: AddItem, RemoveItem, SplitStack, Save, Load, ClearCache. |
// note
UI binders (
GridUI, SlotInventoryUI, EquipmentPanelUI) and their item visuals are also public and virtual-friendly, but most projects only touch their inspector fields — slot size, columns, colors, icon fill ratio.