Equipping an item into slot3 throws an error

Hi,
My project uses UCC integrated with UIS. I set my character up with the flashlight from the UCC demo, and it works fine when loaded into Slot0 and Slot1, equips fine using the UIS inventory canvas. But I want a helmet flashlight, so I
  • added an Items game object to my character rig
  • added the item slot component
  • set the ID to 2 for the flashlight prefab and the item slot
  • set the inventory slot count and the item set rule object slot count to 3
Now when equipping, I get the following error:

IndexOutOfRangeException: Index was outside the bounds of the array.
(wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.ItemSetRule.AssignItemsToItemSet (System.Int32 slotCount, Opsive.UltimateCharacterController.Inventory.ItemSet itemSet, Opsive.Shared.Utility.ListSlice`1[T] itemsInSet) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/ItemSet/ItemSetRule.cs:142)

Below is what my InventoryDatabaseItemSetRulesObject looks like:

I'm not really a programmer, and although the editors are great, I just can't wrap my head around all of the dependencies when creating new items and getting them to equip.
Can anybody tell me what I should look into here?


Iitemset.jpg
 
Looking at the steps you mentioned it looks like you did everything correctly.

looking at the error line the itemSet slot count doesn't match.
That doesn't make sense since they look ok in the sceenshot you sent.

Unity can be a bit fussy with serialization sometimes. Can you try making an edit to each of your ItemSetRules to force them to reserialize.
If that does not work can you add a log just before the error.

C#:
protected virtual void AssignItemsToItemSet(int slotCount, ItemSet itemSet, ListSlice<Item> itemsInSet)
{
    if (slotCount != itemsInSet.Count) {
        Debug.LogError("The Inventory System Item Set Data Slot Count must match the array size of items in a set.");
    }
    for (int i = 0; i < slotCount; i++) {
        Debug.Log($"{i}/{slotCount} {i}/{itemSet.Slots.Length} {i}/{itemsInSet.Count} {GetType()}");
        itemSet.Slots[i] = itemsInSet[i]?.ItemDefinition;
        itemSet.ItemIdentifiers[i] = itemsInSet[i];
        Debug.Log($"{itemsInSet[i]?.ItemDefinition.ToString() ?? "Null"}");
    }
}

That should give me something to go on
 
Thanks for the reply. I edited my ItemSetRules, but no go.
However, when I added the Debug.Log lines above, everything magically worked.
I think that changing the code reloaded the script assemblies and reserialized my ItemSetRules, does that sound about right?
 
Top