Add Item and Equip code

Zaddo

Active member
Could you please let me know if the code below is the correct way to add a weapon and equip it to a UCC character with UIS inventory. It appears to be working. But I am not sure how to test this for completeness.

I can't follow how to use a pooled item for the weapon gameobject that is then attached to the character. Does UCC automatically pool these? or would I have to code for this, and if so, is there any tips on how to do this?

Thx.

C#:
            m_Inventory = gameObject.GetComponent<InventoryBase>();
            var uisInventory = gameObject.GetComponent<Inventory>();
            var itemDefinition = InventorySystemManager.GetItemDefinition("Glock");
            var newItem = InventorySystemManager.CreateItem(itemDefinition);
            var itemInfo = new ItemInfo((1, newItem));
            uisInventory.AddItem(itemInfo);

            var bridge = gameObject.GetComponent<UltimateInventorySystemBridge>();
            var uccItem = bridge.GetItem(newItem, 0);

            m_Inventory.EquipItem(uccItem.ItemIdentifier, 0, true);
 
Last edited:
It all seems good to me.
You first add the item in the UIS inventory, which triggers some events and sets it up automatically to be used as a UCC Item thanks to the bridge.

Just a heads up that UltimateInventorySystemBridge inherits from InventoryBase, therefore "m_Inventory" and "bridge" is the same object in the code above.

In the bridge you look for the uccItem from the uis item. And then you equip it.

PS: now that v1.1.5 of UIS is out, I will focus on improving the integration. This will take a while but there will be definite improvements.
 
Top