public void OnMouseDown()
{
for (int i = 0; i < 40; i++)
{
keyName = i.ToString();
LoadLvlList(i);
if (CountStars == 0)
{
Debug.Log(CountStars);
ButtonsList[i].transform.GetChild(0).GetComponent<Button>().interactable = false;
Debug.Log("нет звезд");
}
}
ButtonsList[0].transform.GetChild(0).GetComponent<Button>().interactable = true;
this.gameObject.SetActive(false);
}
public int LoadLvlList(int keyName)
{
if (PlayerPrefs.HasKey(keyName.ToString())) CountStars = JsonUtility.FromJson<Data>(PlayerPrefs.GetString(keyName.ToString())).value;
return CountStars;
}
public void SaveLvlList(string keyName, int CountStars)
{
PlayerPrefs.SetString(keyName, JsonUtility.ToJson(CountStars));
}
[SerializeField]
class Data
{
public string name;
public int value;
public Data(string name, int value)
{
this.name = name;
this.value = value;
}
}
public void SaveLvlList(string keyName, int CountStars)
{
PlayerPrefs.SetString(keyName, JsonUtility.ToJson(CountStars));
PlayerPrefs.Save();
}