public void SaveItemButton(Itembutton itembutton) { string key = itembutton.ItemName; string itembuttonkey = itembutton.goldpersecond.ToString(); string itembuttoncoast = itembutton.currentcoast.ToString(); PlayerPrefs.SetInt(key + "_level", itembutton.itemLevel); PlayerPrefs.SetString(key + "_cost", itembuttoncoast); PlayerPrefs.SetString(key + "_goldPerSec", itembuttonkey); if (itembutton.isPurchased == true) { PlayerPrefs.SetInt(key + "_isPurchased", 1); } else { PlayerPrefs.SetInt(key + "_isPurchased", 0); } }
public void LoadItemButton(Itembutton itembutton) { string key = itembutton.ItemName; string strcurrentcoast = PlayerPrefs.GetString(key + "_cost", itembutton.currentcoast.ToString()); string strgoldpersec = PlayerPrefs.GetString(key + "_goldPerSec", itembutton.goldpersecond.ToString()); itembutton.itemLevel = PlayerPrefs.GetInt(key + "_level"); itembutton.currentcoast = Convert.ToInt64(strcurrentcoast); itembutton.goldpersecond = Convert.ToInt64(strgoldpersec); if (PlayerPrefs.GetInt(key + "_isPurchased") == 1) { itembutton.isPurchased = true; } else { itembutton.isPurchased = false; } }