Item Slot Collection

Item Slot Collection is a custom Item Collection which only allows you to add items within specific slots defined by an Item Slot Set scriptable object. This collection type is often used for storing equipped items.

Lear more about Equipping items and the Equipper script here.

 

To create an Item Slot Set right click the Project window and press Create -> Ultimate Inventory System -> Inventory -> Item Slot Set.

Item Slot Collection API

 

// Get the Item Slot Collection within the inventory using Get Item Collection and cast it to its type.
var equipmentItemCollection = m_Inventory.GetItemCollection(m_EquipmentItemCollectionID) as ItemSlotCollection;

//Use the slot Index to add, get and remove.
var itemAdded = equipmentItemCollection.AddItem(itemInfo, slotIndex);
var itemInSlot = equipmentItemCollection.GetItemInfoAtSlot(slotIndex);
var itemRemoved = equipmentItemCollection.RemoveItem(slotIndex, amountToRemove);

//Or use the slot name.
itemAdded = equipmentItemCollection.AddItem(itemInfo, slotName);
itemInSlot = equipmentItemCollection.GetItemInfoAtSlot(slotName);
itemRemoved = equipmentItemCollection.RemoveItemInSlot(slotName, amountToRemove);

var item = equipmentItemCollection.GetAllItemStacks()[0];

//Might not be equal to.
var otherItem = equipmentItemCollection.GetItemInfoAtSlot(0);
Item myItem = InventorySystemManager.CreateItem("myItem");

//Gets the slot where the item actually is.
var realSlotIndex = equipmentItemCollection.GetItemSlotIndex(myItem);

//Get the index where the item could potentially fit if it was added.
var potentialSlotIndex = equipmentItemCollection.GetTargetSlotIndex(myItem);