Demo1 Inventories
Examples/Demo1 Inventories/InventoriesDemo.unity
This is the most basic asset example. It shows an inventory without separate game logic, economy, or world integration.
What The Demo Shows
- a simple
ItemExampleSOlist ListInventoryDataBinding<ItemExampleSO, ItemAdapterSoAdapter>- loading a list into
UniversalInventory - synchronizing UI changes back to data
- local
CanStartDragandCanDropoverrides
How It Is Structured
Main parts:
ItemExampleSO.cs— item dataAdapters/ItemAdapterSoAdapter.cs— UI-layer adapterDataBindings/ItemsSOInventoryDataBinding.cs— binding between the data list and inventorySO/Rules/*— example rule preset
flowchart LR
Data["List<ItemExampleSO>"] <--> Binding["ItemsSOInventoryDataBinding"] <--> UI["UniversalInventory"]
The binding reads the list, creates adapters, and synchronizes changes back into the same list.
How It Works
GetItems()returns theitemslist.ReloadUI()builds the initial UI stacks from that list throughCreateAdapter(...). You can call it when data changes to redraw the inventory, butListInventoryDataBindingdoes not preserve positions.- After a successful transfer, the inventory calls the binding's
AddToData(...)andRemoveFromData(...), updating the source list.
The example also shows where to add simple local restrictions:
CanStartDrag(...)— block dragging from a specific inventoryCanDrop(...)— block dropping into a specific inventory
When To Use This Example
- you need a first inventory without a complex model