Page 1 of 1

[Bug] Losing reference to a shared reference on load(?)

Posted: Sun Mar 31, 2024 10:38 pm
by Radicals
Hi, firstly I want to say thank you - this asset is amazing and has been super helpful, and thank you for your support so far :)

I am facing a new issue:
<For context, my game is a first person game with an inventory and quickslot bar>

I am trying to implement saving of the quickslot bar & it's associated items that have been allocated to it from the players inventory. It is working in the sense that I can allocate several items from inside the players inventory to the quickslot bar, save the game, then exit, and load it, and the items appear in the quickslot bar correctly and I can indeed equip them, great!

But when I equip any items using the quickslot bar, then go into the inventory to see what's what, it has duplicated the item. The item is now both equipped and still where it was in the player's bag, duplicated. It is as if the player's inventory and the quickslot bar are no longer referencing the same 'ItemData' instance of the item.

I am wondering what I could be doing wrong?

Re: [Bug] Losing reference to a shared reference on load(?)

Posted: Mon Apr 01, 2024 8:28 am
by Joel
Hi there,

Are you getting any warnings in the console when you save or load?

Also what does ItemData derive from? Only objects which derive from UnityEngine.Object (e.g. MonoBehaviours, ScriptableObjects, etc) can be saved by reference.

All the best,
Joel

Re: [Bug] Losing reference to a shared reference on load(?)

Posted: Mon Apr 01, 2024 7:55 pm
by Radicals
Ahhh I did not realise that - itemData is it's own class, no mono behaviour, I'll look into that some more, thank you.

Re: [Bug] Losing reference to a shared reference on load(?)

Posted: Thu Apr 11, 2024 7:34 pm
by Radicals
Good news - turns out I had another class (ItemUI) that was not ES3Serializable at all, once I added those to it, it fixed it. It had a reference to ItemData that was required for saving to work.

Re: [Bug] Losing reference to a shared reference on load(?)

Posted: Fri Apr 12, 2024 7:59 am
by Joel
Glad you managed to resolve your issue :)

All the best,
Joel