Сделал сохранение, проверяю но не загружает/сохраняет данные.
Вот код, помогите пожалуйста.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class Clicker : MonoBehaviour
{
public int money;
public GameObject b1;
public GameObject b2;
public GameObject b3;
public GameObject b4;
public int bonusplus = 2;
public int bonusplus2 = 7;
public Text moneyText;
public int bonus = 1;
public int autoclickbonus2 = 0;
public void OnApplicationQuit()
{
PlayerPrefs.GetInt("money", money);
}
private void Update()
{
moneyText.text = money.ToString();
}
public void LoadGame()
{
money = PlayerPrefs.GetInt("money");
Debug.Log("Game data loaded!");
}
private void Start()
{
moneyText.text = money.ToString();
LoadGame();
}
public void ToShop()
{
SceneManager.LoadScene(1);
}
public void Return()
{
SceneManager.LoadScene(0);
}
public void ButtonClick()
{
money += bonus;
}
public void Buy()
{
if (money >= 300)
{
bonus += bonusplus;
money -= 300;
b1.SetActive(false);
}
else
{
Debug.Log("Not enough money");
}
}
public void Buy2()
{
if (money >= 900)
{
b2.SetActive(false);
bonus += bonusplus2;
money -= 900;
}
else
{
Debug.Log("Not enough money");
}
}
public void Buy3()
{
if (money >= 3000)
{
b3.SetActive(false);
StartCoroutine(IdleFarm());
money -= 3000;
}
else
{
Debug.Log("Not enough money");
}
}
public void Buy4()
{
if (money >= 4000)
{
b4.SetActive(false);
autoclickbonus2 += 4;
money -= 4000;
}
else
{
Debug.Log("Not enough money");
}
}
IEnumerator IdleFarm()
{
yield return new WaitForSeconds(1);
money += autoclickbonus2;
Debug.Log(money);
StartCoroutine(IdleFarm());
}
}