public class Game : MonoBehaviour {
public int score;
public int bonus;
<i>public int[] costUpgrades;
public Text[] textUpgrades;</i>
private Save save = Save();
private string path;
void Awake ()
{
path = Path.Combine(Application.dataPath, "Save.json");
if (File.Exists (path)) {
save = JsonUtility.FromJson<Save> (File.ReadAllText (path));
score = save.score;
bonus = save.bonus;
}
void OnApplicationQuit ()
{
File.WriteAllText (path, JsonUtility.ToJson (save));
}
void Upgrade1 (int index)
{
if(score >= costUpgrades[index])
{
score -= costUpgrades[index];
...
}
}
void OnClick ()
{
score += bonus;
save.score = score;
}
}
[Serializable]
public class Save
{
public int bonus;
public int score;
public int[] costUpgrades;
public Text[] textUpgrades;
}
Нужно сделать сохранение цены улучшения (costUpgrades) и текста (textUpgrades). Если со счетом и с бонусом все понятно: save.score = score;
то массив, к сожалению, не понимаю.