I am struggeling to grasp how to handle save/load of every GameObject
in a Scene. I currently save data in a Json and it works fine, the part I'm struggeling with is the logic of saving an entire game state.
For example, I'm making a sandbox game where you can shop trees, hoe ground, plant crops, pick herbs, etc, etc. All of these interactable GameObjects
are created from prefabs and that works fine. But I need to somehow save every GameObject
and its state (i.e is a crop fully grown or not, etc) to a file that I can save/load every time I exit/enter a scene (or the game).
Take this scene I created below, All tiles (except the tall grass) are interactable, i.e I can cut down those trees, pick the flowers, and I planted some crops that have grown:
I cannot wrap my head around how to best save/load all this information. Say I save every GameObject
in a file, then would I read that file and Instantiate
each object at runtime every time I enter the scene? Is it even possible to save an entire GameObject
and just Instantiate
it from file? How would I best go about doing this? And this would also mean a scene would load differently depending on if it's the first time I enter it (Everything is in original state) and any time after that it will load from file (without creating a bunch of duplicates).
I use this method by Programmer to save/load data.