public static void DeletePlayer(PlayerStore playerStore) { string playerStoreFolderPath = GetPlayerStoreFolderPath(); string playerStorePath = GetPlayerStorePath(playerStore, playerStoreFolderPath); File.Delete(playerStorePath); Debug.Log("Deleted player " + playerStore.Name); }
public static void SavePlayer(PlayerStore playerStore) { BinaryFormatter binaryFormatter = new BinaryFormatter(); string folderPath = GetPlayerStoreFolderPath(); if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string dataPath = GetPlayerStorePath(playerStore, folderPath); using (FileStream fs = File.Open(dataPath, FileMode.OpenOrCreate)) { binaryFormatter.Serialize(fs, playerStore); } Debug.Log("Saved player " + playerStore.Name + " to " + dataPath); }
private static string GetPlayerStorePath(PlayerStore playerStore, string folderPath) { return(Path.Combine(folderPath, playerStore.Name + FILE_EXTENSION)); }