public class GetItemInSpecificSlot : MonoBehaviour
{
[SerializeField] protected Inventory m_UISInventory;
[SerializeField] protected UltimateInventorySystemBridge m_InventorySystemBridge;
[ContextMenu("Get Right Hand Item UCC")]
public void GetItemInSlotUCCway()
{
//Get the item at slot 0 (Right Hand)
var item = m_InventorySystemBridge.GetActiveItem(0);
Debug.Log("UCC: "+item);
Debug.Log("Converted to UIS: "+ConvertUCCItemToUISItem(item));
}
[ContextMenu("Get Right Hand Item UIS")]
public void GetItemInSlotUISway()
{
//Get the equipment item collection as an ItemSlotCollection
var itemSlotCollection = m_UISInventory.GetItemCollection("Equipped") as ItemSlotCollection;
//Check the item slot set to get the index
for (int i = 0; i < itemSlotCollection.ItemSlotSet.ItemSlots.Count; i++) {
var itemSlot = itemSlotCollection.ItemSlotSet.ItemSlots[i];
if (itemSlot.Name == "RightHand") {
var itemInRightHand = itemSlotCollection.GetItemAtSlot(i);
Debug.Log("UIS: "+itemInRightHand);
Debug.Log("Converted to UCC: "+ConvertUISItemToUCCItem(itemInRightHand));
}
}
//From V1.1 you'll be able to do this, instead of using the for loop above
itemSlotCollection.GetItemInfoAtSlot("RightHand");
}
public Item ConvertUISItemToUCCItem(Opsive.UltimateInventorySystem.Core.Item uisItem)
{
return m_InventorySystemBridge.GetItem(uisItem, 0);
}
public Opsive.UltimateInventorySystem.Core.Item ConvertUCCItemToUISItem(Item uccItem)
{
return uccItem?.ItemIdentifier as Opsive.UltimateInventorySystem.Core.Item;
}
}