// Update is called once per frame public void Save() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/adaptiveInfo" + userName + ".dat", FileMode.Open); AdaptiveData ad = new AdaptiveData(); ad.currLevel = currLevel; ad.currSpeed = currSpeed; ad.isStrictMode = isStrictMode; ad.noOfRestarts = noOfRestarts; ad.rateOfSpawn = rateOfSpawn; ad.sideForce = sideForce; ad.userName = userName; bf.Serialize(file, ad); file.Close(); }
public void Load() { if (File.Exists(Application.persistentDataPath + "/adaptiveInfo" + userName + ".dat")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/adaptiveInfo" + userName + ".dat", FileMode.Open); AdaptiveData ad = (AdaptiveData)bf.Deserialize(file); file.Close(); currLevel = ad.currLevel; currSpeed = ad.currSpeed; isStrictMode = ad.isStrictMode; noOfRestarts = ad.noOfRestarts; rateOfSpawn = ad.rateOfSpawn; sideForce = ad.sideForce; userName = ad.userName; } }