Hi
I use ScriptableObjects (SO) asset files to store item data.
Enemies carry a list of possible items they can drop, and the list is populated in the Inspector with the item SO asset files.
When I kill the enemy, they drop an item, and I can pick it up and add it to my inventory. If I already had an identical item in the inventory and run
if(pickedUpItem == itemInInventory)
it returns true, as it should. At this point everything works fine.
Then when I save, I serialize the game data, including references to the SOs in my inventory. To load, I deserialize the data and load SOs from an AssetBundle. So upon loading, my inventory appears to be the same as when I saved, except that all my items in the inventory are populated from an AssetBundle, rather than through the inspector.
If I at this point kill another mob, pick up an item (referenced in the Inspector) identical to one I already had in the Inventory (from an AssetBundle) and run
if(pickedUpItem == itemInInventory)
it returns false.
Is this behavior expected, or should Unity automatically treat two asset files as the same one, if one is linked in the Inspector and one is loaded from an AssetBundle (meaning I messed something up)?
If it is expected, what are my options? Do I have to stop linking assets in the Inspector if I need to compare them to assets in an AssetBundle?