ScriptableObjects references lost between scenes

Discussion and help for Easy Save 3
Post Reply
Le_Clair
Posts: 5
Joined: Tue Oct 13, 2020 9:24 pm

ScriptableObjects references lost between scenes

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

Re: ScriptableObjects references lost between scenes

Post by Joel »

Hi there,

Is this Sprite or AudioClip assigned or modified at runtime?

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Le_Clair
Posts: 5
Joined: Tue Oct 13, 2020 9:24 pm

Re: ScriptableObjects references lost between scenes

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

Re: ScriptableObjects references lost between scenes

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Le_Clair
Posts: 5
Joined: Tue Oct 13, 2020 9:24 pm

Re: ScriptableObjects references lost between scenes

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

Re: ScriptableObjects references lost between scenes

Post by Joel »

Glad you managed to find a solution :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
XenoBits
Posts: 3
Joined: Sun Jan 24, 2021 4:45 pm

Re: ScriptableObjects references lost between scenes

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

Re: ScriptableObjects references lost between scenes

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
RemDust
Posts: 4
Joined: Wed Mar 24, 2021 7:13 pm

Re: ScriptableObjects references lost between scenes

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

Re: ScriptableObjects references lost between scenes

Post 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
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply