Saving a large amount of data..

Okay so I have a fairly complicated setup. I’ll try my best at explaining it.

So it goes like this

The parent block is the “Business
Each “Business” has 3 children and progressively gains more as the player buys plots.
The first child is some text to show how much a new plot on the business will cost (this doesn’t matter)
The second child is the BuyButton, which holds much each plot costs.
The third child is the HQ. The HQ holds how many plots there are.
Every other child is a plot. Which holds a variable on how much that plot generates.

So this is what it would look like in Unity (Hierarchy)

Businuess (no vars or data stored)
New Text (this isn’t important either)
BuyButton (Price to buy a new plot is stored here)
HeadQuaters (How many plots there are, stored here)
New Text (this isn’t important)

And if the user buys a plot this is what it would look like then.
one plot:

Businuess (no vars or data stored)
Building (How much the building generates and how much it costs to upgrade is stored here)
New Text (this isn’t important either)
BuyButton (Price to buy a new plot is stored here)
HeadQuaters (How many plots there are, stored here)
New Text (this isn’t important)

two plots:

Businuess (no vars or data stored)
Building (How much the building generates and how much it costs to upgrade is stored here)
Building (How much the building generates and how much it costs to upgrade is stored here)
New Text (this isn’t important either)
BuyButton (Price to buy a new plot is stored here)
HeadQuaters (How many plots there are, stored here)
New Text (this isn’t important)

A plots Generate number and Upgrade cost is entirely to that one plot only.
The user can then buy new Businesses and new plots for that business, so on so forth.

Plots stack on top of each other going upwards. The HQ is always at the top of the building.

What I’d like to do is to be able to save these vars in some way that I can load them up correctly:

Total Amount of businesses
How many plots each business has
The upgrade cost for each plot on each Business
And how much the plot generates
Users money
New business cost going left and right (because of how the camera is (facing forward or “platformer”) the user has the option to buy a new business going to the left or going to the right)

And I would like to load it correctly, as how the user left the game when they closed the app (yes this is an android game)

I’ll try explain better if that wasn’t enough!
But any help will be appreciated.

I think the keyword you’re looking for is “serialization”.

https://unity3d.com/learn/tutorials/modules/beginner/live-training-archive/persistence-data-saving-loading
(it’s an older tutorial so forgive the ongui :wink: )

1 Like

Thank you so much. This looks like it could work well!