public void SaveFarmData() { FarmSave farmSave = new FarmSave(); farmSave.playerSubFarmCount = farm.playerSubFarmCount; BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + PATH_FARM_DATA); bf.Serialize(file, farmSave); file.Close(); }
public void LoadFarmData() { if (File.Exists(Application.persistentDataPath + PATH_FARM_DATA)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + PATH_FARM_DATA, FileMode.Open); FarmSave farmSave = (FarmSave)bf.Deserialize(file); file.Close(); //print(farmSave.playerSubFarmCount); farm.SetPlayerSubFarmCount(farmSave.playerSubFarmCount); } else { } }