Item Pouch
Scripting with the ItemPouch class.
An class that stores a pack of items.
Fields & Properties
Name
Description
Type
Access
itemStacks
A list of items stacks in this pouch.
List<ItemStack>
public
Creating an Item Pouch
Since item pouches are scriptable objects, you can create them with ScriptableObject.CreateInstance
.
ItemPouch itemPouch = ScriptableObject.CreateInstance<ItemPouch>();
Working with an Item Pouch
In the examples below, itemStack
is an instance of an Item Stack.
Setting Item Stacks
Adding
itemPouch.itemStacks.Add(itemStack);
Remove
itemPouch.itemStacks.Remove(itemStack);
Getting Items
Its recommended to use the GetItems
method to get all item stacks from an ItemPouch
. However, you can get all items by simply accessing the itemStacks
field.
var itemStacks = itemPouch.GetItems();
You can also get a single random item from the pouch with the GetRandom
method.
var itemStack = itemPouch.GetRandom();
Last updated