Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using System.IO;
- using System;
- public class SaveLoad : MonoBehaviour
- {
- private Save sv = new Save();
- private string path;
- public int ss;
- private void Start()
- {
- #if UNITY_ANDROID && !UNITY_EDITOR
- path = Path.Combine(Application.persistenDataPath, "Save.json");
- #else
- path = Path.Combine(Application.persistentDataPath, "Save.json");
- #endif
- if (File.Exists(path))
- {
- sv = UnityEngine.JsonUtility.FromJson<Save>(File.ReadAllText(path));
- Debug.Log(sv.score);
- ss = sv.score;
- }
- }
- public void Update()
- {
- GetComponent<Money>().vov(ss);
- }
- public void Ggdrop(int gkf)
- {
- ss = gkf;
- sv.score = ss;
- }
- #if UNITY_ANDROID && !UNITY_EDITOR
- private void OnApplicationPause(bool pause)
- {
- if (pause) File.WriteAllText(path, JsonUtilly.ToJson(sv));
- }
- #endif
- private void OnApplicationQuit()
- {
- File.WriteAllText(path, UnityEngine.JsonUtility.ToJson(sv));
- }
- }
- [Serializable]
- public class Save
- {
- public int score ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement