manually saving values vs references of non-monobehaviours

Discussion and help for Easy Save 3
Post Reply
bzwill
Posts: 7
Joined: Mon May 14, 2018 8:58 pm

manually saving values vs references of non-monobehaviours

Post by bzwill »

Hello,

The data I want to save is all contained withing a class called Game, which does not inherit from monobehaviour.

Among other things it saves a list of instantiated scriptable objects which are bluerints for weapons. These need to be saved as values not references as they are procedurally modified at runtime, and will be different each game, even though they start off dervied from scriptable objects that are defined in the editor. This is fine as I can change the overall settings to save values instead of refererences.

Some of their fields however, reference other scriptable objects, which essentially wrap audio assets (think randomly generated gunfire sounds), and I want these to be reference type saves as they dont change, there's just a 'library' of them defined in the editor.

Is there a way I can do this? ES3 set to values serialises all of these as values too, and saves the sample data etc, when I actually want it to just point to the scriptable object. I would love to be able to avoid the overhead of saving a string reference, and recoupling them after a load via a find.

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

Re: manually saving values vs references of non-monobehaviours

Post by Joel »

Hi there,

In this case you should keep the settings so that fields are stored by reference, and instead save your List of instantiated objects using a separate ES3.Save call to ensure that the List's contents are stored by value.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
bzwill
Posts: 7
Joined: Mon May 14, 2018 8:58 pm

Re: manually saving values vs references of non-monobehaviours

Post by bzwill »

I am relatively new to the product - how do I ultimatley store this all in one file so that it is easy to rebuild the single object then? Ie, everything that I need to save is contained in the "Game" class, some of which I need reference IDs for, and some values, and sometimes one object contains a mix of things that should be stored by reference or value.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: manually saving values vs references of non-monobehaviours

Post by Joel »

Hi there,
I am relatively new to the product - how do I ultimatley store this all in one file so that it is easy to rebuild the single object then?
You use Keys to store multiple things to the same file: this is the first parameter of the ES3.Save and ES3.Load method. For more information on keys please see the Getting Started guide:
https://docs.moodkie.com/easy-save-3/getting-started/

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