Page 1 of 1

ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 8:25 pm
by Le_Clair
Hi,

First of all, thank you for this asset, it is saving me so much time and second, sorry for my English.

I have a small issue with the loading of scriptableobjects. Here's the context: the player has an inventory which is a list of Item scriptableobjects. Items have fields for a sprite and a pick up sound effect. The inventory list is saved with ES3.Save("Inventory", Items). After the player picks up an item in a scene, the item sprite and audioclip are set to null when another scene is loaded. The Item is still in the inventory, but the references are lost. Even if I quit the playmode, the references are still lost and I have to manually reassign them.

My guess is that the reference numbers for the Sprite and the clip are not listed in the ES3 Manager of the loaded scene, but I cannot understand how to list them in a scene where they are instantiated...

Thank you!

Re: ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 8:49 pm
by Joel
Hi there,

Is this Sprite or AudioClip assigned or modified at runtime?

All the best,
Joel

Re: ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 8:56 pm
by Le_Clair
No they are not, but I save the inventory before a scene is loaded and I load the inventory after the scene is loaded.

Re: ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 9:57 pm
by Joel
Please could you create a new, very basic project which replicates it and private message it to me so I can see what is happening at my end?

All the best,
Joel

Re: ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 10:00 pm
by Le_Clair
I just found a solution! I simply added [ES3Nonserializable] to the fields and it now works since I don't need those values to be saved

Re: ScriptableObjects references lost between scenes

Posted: Wed Dec 30, 2020 10:22 pm
by Joel
Glad you managed to find a solution :)

All the best,
Joel

Re: ScriptableObjects references lost between scenes

Posted: Tue Jan 26, 2021 1:51 pm
by XenoBits
Hello,

I'm having the same issue and I'm not sure the fix from Le_Clair will apply in my case. Could I send you a test/basic project that illustrate the issue please?

Re: ScriptableObjects references lost between scenes

Posted: Tue Jan 26, 2021 4:36 pm
by Joel
XenoBits wrote: Tue Jan 26, 2021 1:51 pm Hello,

I'm having the same issue and I'm not sure the fix from Le_Clair will apply in my case. Could I send you a test/basic project that illustrate the issue please?
Sure, please feel free to private message it over to me :)

If you also send over your invoice number I can send our upcoming update, which resolves an issue which can also cause this behaviour.

All the best,
Joel

Re: ScriptableObjects references lost between scenes

Posted: Wed Mar 24, 2021 7:52 pm
by RemDust
Le_Clair wrote: Wed Dec 30, 2020 10:00 pm I just found a solution! I simply added [ES3Nonserializable] to the fields and it now works since I don't need those values to be saved
This is so confusing ^^'
I'm having a lot of troubles with SOs referencing other SOs and I suppose that tagging the missing fields with ES3NonSerialize told ES3 not to save the null fields ? in that case, where does ES3 get the not serialized fields from ??

Re: ScriptableObjects references lost between scenes

Posted: Wed Mar 24, 2021 7:56 pm
by Joel
RemDust wrote: Wed Mar 24, 2021 7:52 pm
Le_Clair wrote: Wed Dec 30, 2020 10:00 pm I just found a solution! I simply added [ES3Nonserializable] to the fields and it now works since I don't need those values to be saved
This is so confusing ^^'
I'm having a lot of troubles with SOs referencing other SOs and I suppose that tagging the missing fields with ES3NonSerialize told ES3 not to save the null fields ? in that case, where does ES3 get the not serialized fields from ??
Hi there,

I've replied to your post in the other thread. Your issues are unrelated to what is mentioned in this thread.

All the best,
Joel