public void SaveSettings(SettingsData settingsData) { var v_settingsJson = JsonConvert.SerializeObject(settingsData); var v_currentSettings = PlayerPrefs.GetString(nameof(Settings), string.Empty); if (v_currentSettings.Equals(v_settingsJson)) { return; } UnityEngine.Debug.LogFormat("Saving settings: {0}".ToGreen(), v_settingsJson); PlayerPrefs.SetString(nameof(Settings), v_settingsJson); }
public SettingsData GetSettings() { if (_currentSettings != null) { return(_currentSettings); } var v_currentSettings = PlayerPrefs.GetString(nameof(Settings), string.Empty); _currentSettings = string.IsNullOrEmpty(v_currentSettings) ? new SettingsData() : JsonConvert.DeserializeObject <SettingsData>(v_currentSettings); return(_currentSettings); }