internal void Save() { try { string json = JsonUtility.ToJson(this, true); File.WriteAllText(SETTINGS_PATH, json, System.Text.Encoding.UTF8); HomeImprovement.Log("Config file saved to " + SETTINGS_PATH); } catch (Exception ex) { HomeImprovement.Log("Error while trying to write config file:"); Debug.LogException(ex); } }
internal static HomeImprovementSettings Load() { if (!File.Exists(SETTINGS_PATH)) { HomeImprovement.Log("Settings file did not exist, using default settings."); return(new HomeImprovementSettings()); } try { string json = File.ReadAllText(SETTINGS_PATH, System.Text.Encoding.UTF8); return(JsonUtility.FromJson <HomeImprovementSettings>(json)); } catch (Exception ex) { HomeImprovement.Log("Error while trying to read config file:"); Debug.LogException(ex); // Re-throw to make error show up in main menu throw new IOException("Error while trying to read config file", ex); } }