Hi,
I get an error when I try to assign a weapon to the character. I must have something set up incorrectly in my project, but I am not sure how to fix this. Here are the details:
The problem is the CharacterInventoryBridge.Awake is being called before the InventoryItemSetManager.Initialise is called. This results in the BridgeEquippableProcess.m_PreviousActiveSets getting initialised with a CategoryCount of zero.
Then When I attempt to assign weapon to right hand. BridgeEquippableProcessing.ReEquipItems attempts to assign previousItemSet with the empty array on m_PreviousActiveSets.
This is where error is thrown:
BridgeEquippableProcessing.ReEquipItems (@ line 507): var previousItemSet = m_PreviousActiveSets.Active.Data[categoryIndex]; // m_PreviousActiveSets.Active has Category Count of Zero from when is created before. So throws an error
Start up steps occuring in wrong order:
CharacterInventoryBridge.Awake (@ line 134): m_BridgeEquippableProcessing = new BridgeEquippableProcessing(this);
=> In BridgeEquippableProcessing Constructor (@ line 109): m_PreviousActiveSets = new ActiveAndNextItemSetData(ItemSetManager.CategoryCount,ItemSetManager.SlotCount); // ItemSetManager.CategoryCount is zero at this point
InventoryItemSetManager.Initialize => Loads ItemSetRules with the categories
@ line 115: System.Array.Resize(ref m_CategoryItemSets, validCategoryCount); // Now sets m_CategoryItemSets to correct size. But too late for m_PreviousActiveSets which has zero length
The Error:
I get an error when I try to assign a weapon to the character. I must have something set up incorrectly in my project, but I am not sure how to fix this. Here are the details:
The problem is the CharacterInventoryBridge.Awake is being called before the InventoryItemSetManager.Initialise is called. This results in the BridgeEquippableProcess.m_PreviousActiveSets getting initialised with a CategoryCount of zero.
Then When I attempt to assign weapon to right hand. BridgeEquippableProcessing.ReEquipItems attempts to assign previousItemSet with the empty array on m_PreviousActiveSets.
This is where error is thrown:
BridgeEquippableProcessing.ReEquipItems (@ line 507): var previousItemSet = m_PreviousActiveSets.Active.Data[categoryIndex]; // m_PreviousActiveSets.Active has Category Count of Zero from when is created before. So throws an error
Start up steps occuring in wrong order:
CharacterInventoryBridge.Awake (@ line 134): m_BridgeEquippableProcessing = new BridgeEquippableProcessing(this);
=> In BridgeEquippableProcessing Constructor (@ line 109): m_PreviousActiveSets = new ActiveAndNextItemSetData(ItemSetManager.CategoryCount,ItemSetManager.SlotCount); // ItemSetManager.CategoryCount is zero at this point
InventoryItemSetManager.Initialize => Loads ItemSetRules with the categories
@ line 115: System.Array.Resize(ref m_CategoryItemSets, validCategoryCount); // Now sets m_CategoryItemSets to correct size. But too late for m_PreviousActiveSets which has zero length
The Error:
Code:
IndexOutOfRangeException: Index was outside the bounds of the array.
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing.ReEquipItems (System.Int32 categoryIndex, System.Int32& allowedSlotsLayerMask) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/BridgeEquippableProcessing.cs:507)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing.UpdateItemSetItems (System.Boolean equip) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/BridgeEquippableProcessing.cs:463)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing.OnItemAddedToEquippable (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.Core.DataStructures.ItemStack addedItemStack) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/BridgeEquippableProcessing.cs:196)
Opsive.UltimateCharacterController.Integrations.UltimateInventorySystem.BridgeEquippableProcessing.OnAddItemToInventory (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.Core.DataStructures.ItemStack addedItemStack) (at Assets/Opsive/UltimateCharacterController/Integrations/UltimateInventorySystem/Scripts/BridgeEquippableProcessing.cs:770)
Opsive.Shared.Events.InvokableAction`2[T1,T2].Invoke (T1 arg1, T2 arg2) (at <27da9e1afec54f2fb2a11d46a234f9df>:0)
Opsive.Shared.Events.EventHandler.ExecuteEvent[T1,T2] (System.Object obj, System.String eventName, T1 arg1, T2 arg2) (at <27da9e1afec54f2fb2a11d46a234f9df>:0)
Opsive.UltimateInventorySystem.Core.InventoryCollections.ItemCollection.NotifyAdd (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, Opsive.UltimateInventorySystem.Core.DataStructures.ItemStack addedItemStack) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/ItemCollection.cs:430)
Opsive.UltimateInventorySystem.Core.InventoryCollections.ItemSlotCollection.SetItemAmount (Opsive.UltimateInventorySystem.Core.DataStructures.ItemInfo itemInfo, System.Int32 slotIndex, System.Boolean removePreviousItem) (at Assets/Opsive/UltimateInventorySystem/Scripts/Core/InventoryCollections/ItemSlotCollection.cs:264)