Exemple #1
0
//	void OnApplicationQuit()
//	{
//		AutoSave ();
//	}

    private void AutoSave()
    {
        string       filename = Application.persistentDataPath + "/gold_save.txt";
        StreamWriter sw       = new StreamWriter(filename);
        GoldInfo     gi       = new GoldInfo();

        gi.gold = _gold_value;
        sw.WriteLine(JsonUtility.ToJson(gi));
        sw.Close();
    }
Exemple #2
0
    private void AutoLoad()
    {
        string filename = Application.persistentDataPath + "/gold_save.txt";

        if (File.Exists(filename))
        {
            StreamReader sr   = new StreamReader(filename);
            string       line = "";
            while ((line = sr.ReadLine()) != null)
            {
                string   g_info = line;
                GoldInfo gi     = JsonUtility.FromJson <GoldInfo>(g_info);
                _gold_value = gi.gold;
                InitValue(0, _gold_value);
            }
            sr.Close();
        }
    }