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

Discussion and help for Easy Save 3
Post Reply
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

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

Post 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?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

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

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

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

Post 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.
Radicals
Posts: 8
Joined: Thu Jan 04, 2024 8:32 pm

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

Post 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.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

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

Post by Joel »

Glad you managed to resolve your issue :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply