Ejemplo n.º 1
0
 public void savingCoin(CoinManager coinManager, string urlShop)
 {
     try
     {
         SaveCoin saveData = new SaveCoin();
         // Save Data
         // Do something
         saveData.coin = coinManager.getCoin();
         //
         BinaryFormatter bf = new BinaryFormatter();
         FileStream      fs = new FileStream(Application.persistentDataPath + urlShop, FileMode.OpenOrCreate);
         bf.Serialize(fs, saveData);
         fs.Close();
     }
     catch (Exception e)
     {
         print(e);
     }
     print("saved data to " + Application.persistentDataPath + urlShop);
 }
Ejemplo n.º 2
0
 public void loadingCoin(CoinManager coinManager, string urlShop)
 {
     Debug.Log(Application.persistentDataPath + urlShop);
     if (File.Exists(Application.persistentDataPath + urlShop))
     {
         try
         {
             SaveCoin        saveData = new SaveCoin();
             BinaryFormatter bf       = new BinaryFormatter();
             FileStream      fs       = new FileStream(Application.persistentDataPath + urlShop, FileMode.Open);
             saveData = (SaveCoin)bf.Deserialize(fs);
             fs.Close();
             // do somthing
             coinManager.setCoin(saveData.coin);
         }
         catch (Exception e)
         {
             print(e);
         }
     }
 }