Saving Nested ScriptableObjects

Discussion and help for Easy Save 3
Post Reply
thsbrown1@gmail.com
Posts: 5
Joined: Fri May 17, 2019 6:53 pm

Saving Nested ScriptableObjects

Post by thsbrown1@gmail.com »

Hey guys, just started using EasySave and I was a bit disheartened to find out that it doesn't support nested ScriptableObjects out of the box.

It also doesn't look like there has been a tutorial or example showing this use case.

Would love some help. I created a new ES3Type but i'm thinking surely there must be a way to tell ES3 to quickly serialize all sub fields.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Nested ScriptableObjects

Post by Joel »

Hi there,

Easy Save 3 is capable of saving and loading nested ScriptableObjects. Please could you create a very basic project which replicates your problem and PM it over to me with instructions to replicate it?

Note that fields of UnityEngine.Object types (such as ScriptableObjects) are stored by reference, so if your inner ScriptableObject is generated at runtime, a reference to this will not exist in the reference manager.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thsbrown1@gmail.com
Posts: 5
Joined: Fri May 17, 2019 6:53 pm

Re: Saving Nested ScriptableObjects

Post by thsbrown1@gmail.com »

Hey Joel I wen't ahead and sent along the example project via pm a few days ago and am eager to see how I might get this working.

Thanks in advance!
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Nested ScriptableObjects

Post by Joel »

Hi there,

Apologies for the delay, it would seem I didn't get a notification regarding your PM. Thanks for your patience.

In your case there's actually an easy workaround in form of a bit of undocumented functionality we have. You can create an ES3Settings object which tells Easy Save's serialiser to store all fields by reference AND value:
var settings = new ES3Settings();
settings.memberReferenceMode = ES3.ReferenceMode.ByRefAndValue;
ES3.Save<Data>("saveData", gameData, "GameData.es3", settings);
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
thsbrown1@gmail.com
Posts: 5
Joined: Fri May 17, 2019 6:53 pm

Re: Saving Nested ScriptableObjects

Post by thsbrown1@gmail.com »

This seams to be exactly what i'm looking for!

Thanks so much!

It would be great if this was documented as it would probably save someone else a headache haha :)
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving Nested ScriptableObjects

Post by Joel »

There are a few edge cases we need to account for, but we're hoping to get this added in a coming update :)

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