public static void Load() { try { string path = Path.Combine(Main.ModPath, "SkySave.json"); if (!File.Exists(path)) { File.Create(path).Close(); State = new SkySaveData(Main.ModVersion); File.WriteAllText(path, JsonUtility.ToJson(State, true)); } else { State = JsonUtility.FromJson <SkySaveData>(File.ReadAllText(path)); Debug.Log($">>> >>> >>> LOAD Version: [{State.version}]"); if (string.IsNullOrEmpty(State.version) || State.version != JsonUtility.FromJson <UnityModManagerNet.UnityModManager.ModInfo>(File.ReadAllText(Path.Combine(Main.ModPath, "Info.json"))).Version) { if (string.IsNullOrEmpty(State.version)) { Debug.LogWarning(">>> >>> >>> No Version Available"); } else if (State.version != Main.ModVersion) { Debug.LogWarning(">>> >>> >>> No Version Compatibility"); } State = new SkySaveData(Main.ModVersion); File.WriteAllText(path, JsonUtility.ToJson(State, true)); Debug.LogWarning($">>> >>> >>> Created New File with Version: [{State.version}]"); } } } catch (Exception ex) { Debug.Log(ex); throw; } }
static SkySaveManager() { State = new SkySaveData(); }