[HELP]Saving incremental game upgrades using PlayerPrefs

I’ve made a basic incremental game loosely following these tutorials:

This is my first time using unity.

I essentially have 10 buttons to purchase different gold per second upgrades, and 10 buttons for purchasing gold per click upgrades. Each can be purchased multiple times (leveled up), and the price increases with each purchase.

I currently have it so that PlayerPrefs saves the current gold, but I can not figure out how to have it save the information for each button ( ex. number owned and cost), since the UI buttons are all running the same scripts.

I have one script which controlls gpcUpgrades, and another for gpsUpgrades, so I do not know how I would save the instances of each class. I am trying to save the level and cost for each one.

Name the UI buttons and use that to reference what the data is representing?

Is this the correct way? Where I just link the just the one to each button?


When I do it this way I am unable to do gpcUpgrade7.level for example

uhh… maybe? Not really sure what you’re trying to demonstrate here.

I simply meant you could do something like:

PlayerPrefs.SetInt(button.gameObject.name, button.value);

and

button.value = PlayerPrefs.GetInt(button.gameObject.name);