Answer the question
In order to leave comments, you need to log in
Gives an error: index was outside the bounds of the array. Why is it being issued?
public GameObject BuyButton;
public int BuyCard = 0;
public GameObject[] VideoCard;
public void Save()
{
PlayerPrefs.SetString("VideoCard", JsonUtility.ToJson(VideoCard));
}
public void Load()
{
VideoCard = JsonUtility.FromJson<GameObject[]>(PlayerPrefs.GetString("VideoCard"));
}
private void Start()
{
BuyCard = PlayerPrefs.GetInt("BuyCard", BuyCard);
Load();
}
public void BuyCards()
{
if (Money1 >= 299)
{
BuyCard++;
Money1 -= 299;
PlayerPrefs.SetInt("Money1", Money1);
PlayerPrefs.GetInt("BuyCard", BuyCard);
VideoCard[0].SetActive(true);
Save();
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question