Hi,
just had to debug this issue I was facing in a new build I created.
In Inventory (and ShootableWeapon, but the issue is the same), Item objects are used as dictionary keys. Items would get added and later when a lookup is attempted the lookup would fail for what should have been a matching Item object. It doesnt look like Item or its ancestor classes define GetHashCode(), it would just seem like it being a MonoBehavior and whatever GetHashCode() definition comes with that changes over it's lifetime. I googled a bit and it seems like others have encountered this issue (not with UFPS but in general) as well.
This resulted in weapons not being equippable after being picked up and reloads throwing an error. The fix was to replace the Items as dictionary keys with the ItemIdentifier.ID uint values instead.
Has anyone encountered this as well? This only affected me in a the build (both for Mac and UWP builds), NOT in the editor.
Also, I dont believe this was happening before I upgreaded from Unity 2019 to 2020.
Looks like there are more instances in the UFPS codebase of using GameObject or other Unity objects as dictionary keys, Im wondering if I should be changing them all to use GetInstanceID() instead.
just had to debug this issue I was facing in a new build I created.
In Inventory (and ShootableWeapon, but the issue is the same), Item objects are used as dictionary keys. Items would get added and later when a lookup is attempted the lookup would fail for what should have been a matching Item object. It doesnt look like Item or its ancestor classes define GetHashCode(), it would just seem like it being a MonoBehavior and whatever GetHashCode() definition comes with that changes over it's lifetime. I googled a bit and it seems like others have encountered this issue (not with UFPS but in general) as well.
This resulted in weapons not being equippable after being picked up and reloads throwing an error. The fix was to replace the Items as dictionary keys with the ItemIdentifier.ID uint values instead.
Has anyone encountered this as well? This only affected me in a the build (both for Mac and UWP builds), NOT in the editor.
Also, I dont believe this was happening before I upgreaded from Unity 2019 to 2020.
Looks like there are more instances in the UFPS codebase of using GameObject or other Unity objects as dictionary keys, Im wondering if I should be changing them all to use GetInstanceID() instead.