Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private Save sv = new Save();
- //...
- private void Awake()
- {
- if (PlayerPrefs.HasKey("SV"))
- {
- Debug.Log("AWAKE");
- sv = JsonUtility.FromJson<Save>(PlayerPrefs.GetString("SV"));
- copper_coins = sv.copper_coins;
- silver_coins = sv.silver_coins;
- gold_coins = sv.gold_coins;
- }
- }
- private void OnApplicationQuit()
- {
- Debug.Log("OAQ");
- sv.copper_coins = copper_coins;
- sv.silver_coins = silver_coins;
- sv.gold_coins = gold_coins;
- PlayerPrefs.SetString("SV", JsonUtility.ToJson(sv));
- }
- //...
- [Serializable]
- public class Save
- {
- public int copper_coins;
- public int silver_coins;
- public int gold_coins;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement