Hello,
I'm making a tycoon style game, and various objects currently save lists which reference people, etc, sometimes via a particular component or interface type.
In order to save these references, I am looking for help for a best practice pattern. I have a few questions:
[*] I need to be able to use lists which either reference a component type (like Person) or an interface like (IHasInventory) etc. so Ideally i'd like a solution for all fits.
[*] Assuming I need to use a unique reference system, I assume I need to do some post - load work to relink things - if so whats the best way?
[*] Should I be starting this project with ES2 or ES3!?
I've looked through the documentation, but I can't seem to find a long guide which goes into detail about how to save a complex save state such as this - If there's already something that exists, please point me to it
Thanks!
Saving references to types in game with a complex save state
Re: Saving references to types in game with a complex save s
Hi there,
In Easy Save 3, Component types will be saved by reference and by value, so you can simply do:
All the best,
Joel
In Easy Save 3, Component types will be saved by reference and by value, so you can simply do:
ES3.Save<List<Person>("personList", personList); var personList = ES3.Load<List<Person>("personList");Unfortunately saving interfaces is not currently possible, so you would need to save Lists of the concrete type instead. As this is the first time it has been requested, I have added a Feature Request for interface support here.
All the best,
Joel
Re: Saving references to types in game with a complex save s
Hey Joel,
Thanks for the reply, and that's good to know about interfaces now!
Can I just clarify that I understand correctly:
I have three GameObject instantiated at runtime from Prefabs called 'Person', with a MonoBehavior on them called Person. These three Persons are employed at a Building (With a monobehaviour Building) which maintains a List<Person> employees;
I need ES3 to save the three gameobjects of Person, and the Building gameobject with its list.
When I reload, the three Persons and the building with be instantiated and the Building will still have a List<Person> that references the three gameobjects Person behaviours?
Thanks
Thanks for the reply, and that's good to know about interfaces now!
Can I just clarify that I understand correctly:
I have three GameObject instantiated at runtime from Prefabs called 'Person', with a MonoBehavior on them called Person. These three Persons are employed at a Building (With a monobehaviour Building) which maintains a List<Person> employees;
I need ES3 to save the three gameobjects of Person, and the Building gameobject with its list.
When I reload, the three Persons and the building with be instantiated and the Building will still have a List<Person> that references the three gameobjects Person behaviours?
Thanks
Re: Saving references to types in game with a complex save s
Hi there,
In this case you would need to follow the Saving Prefabs guide to save your prefab instances: https://docs.moodkie.com/easy-save-3/es ... s-prefabs/
Then you would need to add support for your Person MonoBehaviour in Window > Easy Save 3 > Types (see https://docs.moodkie.com/easy-save-3/es ... -es3types/) so that it knows to save the Person Component.
All the best,
Joel
In this case you would need to follow the Saving Prefabs guide to save your prefab instances: https://docs.moodkie.com/easy-save-3/es ... s-prefabs/
Then you would need to add support for your Person MonoBehaviour in Window > Easy Save 3 > Types (see https://docs.moodkie.com/easy-save-3/es ... -es3types/) so that it knows to save the Person Component.
All the best,
Joel