using System.IO; using BansheeGz.BGDatabase; using UnityEngine; //this is a minimalistic save/load example public static class SaveLoadManager { public static bool DebugOn; private static string FilePath { get { return Path.Combine(Application.persistentDataPath, "save.dat"); } } //this method saves current database state to a file save.dat public static void Save() { var filePath = FilePath; File.WriteAllBytes(filePath, BGRepo.I.Addons.Get().Save()); DebugMessage("Data saved to " + filePath); } //this method loads database state from a file save.dat public static void Load() { var filePath = FilePath; if (File.Exists(filePath)) { BGRepo.I.Addons.Get().Load(File.ReadAllBytes(filePath)); DebugMessage("Data loaded from " + filePath); } else DebugMessage("Loading is skipped cause no save file found at " + filePath); } private static void DebugMessage(string message) { if (!DebugOn) return; Debug.Log("SaveLoadManager: " + message); } }