Hello guys,
first of all, top class asset, it's really saving me a lot of time in implementing saves in our game, Empires in Ruins.
Now the question/doubt i have. Premise is, that I didn't test yet (I am still heavily refactoring our code so to allow to save everything that is needed).
I have a list of Officers classes (already added and supported as ES2Type) general to the game, and then for example when one of them is used in a province of the game as governor, i reference it there through public Officer governor variable. What is the standard behavior of ES2 in this case when saving the list and the province. Would it create two duplicates of the Officer and then when reloaded would be two separate instances right?
If that is the case, is there an embedded way to avoid this or should I rewrite the code so that on load the officer is re-references on the province from the list?
Cheers,
H
Instances and references
Re: Instances and references
Hi there,
Easy Save 2 saves by value, not by reference, so you would indeed end up with two references. The workaround for this is instead of saving the object itself, maintain your own list of references and save/load the index of the object in this list.
Note that Easy Save 3 will support saving UnityEngine.Object references. Easy Save 3 will be a free update for existing users, and we hope to have a beta available soon.
All the best,
Joel
Easy Save 2 saves by value, not by reference, so you would indeed end up with two references. The workaround for this is instead of saving the object itself, maintain your own list of references and save/load the index of the object in this list.
Note that Easy Save 3 will support saving UnityEngine.Object references. Easy Save 3 will be a free update for existing users, and we hope to have a beta available soon.
All the best,
Joel
Re: Instances and references
Thanks for the quick answer, that will be my probable solution for now then.
Cheers,
H
Cheers,
H