01 — Items & Stacks¶
Goal:
Learn how the Inventory system handles stacking, splitting, merging, and swapping — the core mechanics behind all container interactions.
Purpose¶
Demonstrate practical stack management with InventoryItemsAndStacksPanel.
Shows how to manipulate stacks directly and observe container events driving UI updates.
🎓 What This Scene Teaches¶
- Add items to a container via
SceneInventoryService.GiveExact. - Select and move stacks via service-level, authority-gated merge/swap operations.
- Split stacks manually (target index or auto-placement).
- Quick-split with right-click (½ stack) or Shift + Right-Click (1 item).
- Live refresh via
InventoryContainer.OnChangedevent.
⚠️ Authority Note
This scene runs with Inventory authority permissive by default.
Inventory mutations are allowed locally for demonstration purposes.Authority binders may appear in demo scenes to make the authority boundary explicit, but Inventory does not fail-closed by default.
Why demo scenes sometimes include binders:
https://revandrab.github.io/RevFramework/authority/#demo-scenes--binders-why-youll-sometimes-see-them
🧩 How to Use¶
- Assign 2–3 ItemDefinitions in the panel’s Quick Items row.
- Use Give to fill the Backpack with a few stacks.
- Left-click a slot to select, then click another to merge or swap.
- Right-click a slot to split half; Shift + Right-click to split 1.
- Use the Split UI to enter custom amounts or explicit target indices.
- Watch the grid update automatically via the OnChanged event.
💡 Key Takeaways¶
TryMergeThenSwapResult()is your all-in-one “drag-and-drop” handler.SplitResult()supports both targeted and auto placement.- Wrap multi-slot changes in
DeferEvents()to avoid redundant UI refreshes. - Demonstrates the core data flow — no Unity UI toolkit or prefabs required.
🔧 Scene Setup¶
| Component | Purpose |
|---|---|
InventoryItemsAndStacksPanel |
Teachable overlay demonstrating stack operations. |
SceneInventoryService |
Central inventory manager (assign an ItemDatabase). |
CharacterInventory |
Attached to the player/owner; manages the “Backpack” container. |
InventoryAuthorityBinder |
Optional baseline authority binder (default allow; toggle off to simulate NoAuthority). |
| Property | Default | Notes |
|---|---|---|
| Container | "Backpack" |
Configurable via the panel. |
| Toggle Key | Backquote (```) | Show/hide the panel overlay. |
Scene Path:
Assets/RevFramework/Runtime/Systems/Inventory/Samples/Scenes/01_Items_And_Stacks/
📝 Notes¶
- All operations use result-first (
InvOpResult) returns for clean UI handling. - Runs standalone — no other modules (Equipment, Currency, Crafting) required.
- Ideal starting point for anyone implementing drag-drop or split-stack inventory UIs.
- Authority gating is supported via
IInventoryAuthority.
If no binder is present, service-level mutations default to allowed (single-player friendly).