[Bug] Possible Bug in ItemSetManagerBase.IsDefaultItemCategory: categoryParents is null if I build and run the application.

echtnice

Member
1. Character controller variant (Ultimate Character Controller, First Person Controller, etc).
Third Person Controller

2. Unity version (include which SRP, beta Unity versions aren't supported)
2019.3.9f1

3. Bug description
- I have a custom ability that uses "Immediate Unequip"
- If I built the application for Windows, run the game, and start the ability, I get a Null Reference Exception because "categoryParents" in Inventory/ItemSetManagerBase.cs Line: 157 is null.

- If I run the same application in Editor, "categoryParents" is an empty array and i do not get an error.

Maybe it has something to do with how ScriptableObejcts and created in Editor vs Builds?

I added a null check in ItemSetManagerBase.IsDefaultItemCategory for now and everything seems to work as expected.

ItemSetManagerBase.IsDefaultItemCategory:
private bool IsDefaultItemCategory(ItemDefinitionBase itemDefinition, IItemCategoryIdentifier itemCategory)
{
var categoryParents = itemCategory.GetDirectParents();
+ if (categoryParents != null) {
for (int i = 0; i < categoryParents.Count; ++i)
{
if (IsDefaultItemCategory(itemDefinition, categoryParents))
{
return true;
}
}
+ }



4. Steps to reproduce
Sorry, but no TestProject yet.

5. The full error message (if any)
NullReferenceException: Object reference not set to an instance of an object
at Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsDefaultItemCategory (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition, Opsive.Shared.Inventory.IItemCategoryIdentifier itemCategory) [0x00033] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Inventory\ItemSetManagerBase.cs:157
at Opsive.UltimateCharacterController.Inventory.ItemSetManagerBase.IsDefaultItemCategory (Opsive.Shared.Inventory.ItemDefinitionBase itemDefinition) [0x00025] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Inventory\ItemSetManagerBase.cs:145
at Opsive.UltimateCharacterController.Character.Abilities.ItemEquipVerifier.IsDefaultItemIdentifier (Opsive.Shared.Inventory.IItemIdentifier itemIdentifier) [0x00012] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\Abilities\ItemEquipVerifier.cs:213
at Opsive.UltimateCharacterController.Character.Abilities.ItemEquipVerifier.TryToggleItem (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean activate) [0x0014f] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\Abilities\ItemEquipVerifier.cs:106
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean ignorePriority, System.Boolean ignoreCanStartCheck) [0x002e4] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotion.cs:1144
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability, System.Boolean ignorePriority) [0x00001] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotion.cs:1052
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotion.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) [0x00001] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotion.cs:1041
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.TryStartAbility (Opsive.UltimateCharacterController.Character.Abilities.Ability ability) [0x00001] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotionHandler.cs:231
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput (Opsive.UltimateCharacterController.Character.Abilities.Ability[] abilities) [0x00083] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotionHandler.cs:128
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.UpdateAbilityInput () [0x000cf] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotionHandler.cs:98
at Opsive.UltimateCharacterController.Character.UltimateCharacterLocomotionHandler.Update () [0x0004c] in C:\Users\Nutzer\projects\Echtnice\GunFu\Assets\Opsive\UltimateCharacterController\Scripts\Character\UltimateCharacterLocomotionHandler.cs:73

(Filename: C:/Users/Nutzer/projects/Echtnice/GunFu/Assets/Opsive/UltimateCharacterController/Scripts/Inventory/ItemSetManagerBase.cs Line: 157)


Thanks!
 
Thank you. That null check is correct and I've included it in the next update :)
 
Top