- Home /
Question by
KloverGames · Jan 23, 2021 at 08:10 AM ·
google playsave dataupdatessave gameoverwrite
How to make an update file function for app updates?
So I have a script for saving and loading the player data, but what about when I launch a new update for the game? I don't want the player's data to be overwritten. So I need to understand how to append an update file if the update files don't exist or something??
using UnityEngine; using System.IO; using System.Runtime.Serialization.Formatters.Binary;
public static class SaveManager {
public static void SaveStats(UIManager manager)
{
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/usc.GameData";
FileStream stream = new FileStream(path, FileMode.Create);
PlayerData data = new PlayerData(manager);
formatter.Serialize(stream, data);
stream.Close();
}
public static PlayerData LoadStats()
{
string path = Application.persistentDataPath + "/usc.GameData";
if(File.Exists(path))
{
Debug.Log("File found" + path);
BinaryFormatter formatter = new BinaryFormatter();
FileStream stream = new FileStream(path, FileMode.Open);
PlayerData data = formatter.Deserialize(stream) as PlayerData;
stream.Close();
return data;
}
else
{
Debug.Log("File not found" + path);
return null;
}
}
}
Comment
Guys please tell me if I'm doing this right
//For Future Game Updates
public static void gameUpdate()
{
BinaryFormatter formatter = new BinaryFormatter();
string path = Application.persistentDataPath + "/usc.GameUpdateOne";
if (!File.Exists(path))
{
FileStream stream = new FileStream(path, File$$anonymous$$ode.Append);
}
}
Your answer
Follow this Question
Related Questions
Will appending a save file keep your save after an update? 0 Answers
Save Game Folder 1 Answer
What is freezing my android game? (using Google Play Services) 0 Answers
How do I save a List in my project? 0 Answers
How can i save the games inventory? 1 Answer