public void loadingID(ref int id, string urlShop) { Debug.Log(File.Exists(Application.persistentDataPath + urlShop)); if (File.Exists(Application.persistentDataPath + urlShop)) { try { SaveID saveData = new SaveID(); BinaryFormatter bf = new BinaryFormatter(); FileStream fs = new FileStream(Application.persistentDataPath + urlShop, FileMode.Open); saveData = (SaveID)bf.Deserialize(fs); fs.Close(); // do somthing id = saveData.currentItemID; } catch (Exception e) { print(e); } } }
public void savingID(ShopManager shopManager, string urlShop) { try { Debug.Log("shopManager: " + shopManager); SaveID saveData = new SaveID(); // Save Data // Do something saveData.currentItemID = shopManager.currentItemID; // 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); }