Inventory display with dynamic amount of items?

Bernkastel

Member
The documentation refers to the list view of an inventory having a fixed size. Is there a way to add or remove items from a list at runtime? What if I have an inventory list view that needs to become bigger as I buy more permanent items. In my use case I have a shop to buy weapons, once I have that weapon it would be included in an "owned inventory" as opposed to the shop.
 
I'm not sure I understand your question.

The Inventory Grid (the list view is a grid with one column) shows a fixed amount of ItemViewSlots but it can show any amount of items as you navigate through using the scrollbar.

I don't understand our question about the shop. When you buy an item in the shop it gets added to your inventory (as long as you do not have any restrictions on your inventory)

Would you mind rephrasing your question?
 
I was under the impression that the Grid Size & Layout Group's size was the amount of items that can be shown in total. If I have an inventory with 100 different items, what do I set the List Length in the Inventory Grid Creator in order to display 5 items at a time in the scrollbar? Ignore the shop question for now, its not important at the moment.
 
You'll set the list length to 5.

The ItemView Slots are recycled. Meaning the ItemViewSlots are always the same, only their contents change.

If that does not make sense check the hiearchy of the shop at runtime, hopefully it clarifies it.
1) open the demo scene
2) pickup/add a ton of unique items on the player character
3) go to the shop menu
4) press "Sell"
5) check the shop hierachy for the Inventory List
6) have a look at the ItemViewSlots as you scroll through the list, you'll see that we do not add/remove ItemViewSlots, on the ItemView inside the slot changes.

The UI cannot affect the Inventory in any way. The Inventory is just a collection of items organized in ItemCollections. If you want to limit the size of your Inventory you need to create an ItemRestriction component.
The UI is only used to display the data within the Inventory in any way you want (grid, list, filters, sorters, etc...)

In the next major update I'll be adding some new scriptableObject to create restrictions for your item collections easily, write now the best way is to write custom code for it, inheriting the IItemRestriction interface:

I hope this clarifies your doubts about the inventory.
 
Ah ok perfect sorry for the confusion. I thought that it might work like the grid type inventories that have a fixed size no matter what, and would just display the first X items in an inventory if the inventory > gridSize.

Ty for the help
 
No problem, if you have time I would recommend you watch the video tutorials about the ItemVewSlotContainers. I think you'll find a lot of useful information that you might have missed:
 
Top