| | 1 | | using UnityEngine; |
| | 2 | |
|
| | 3 | | namespace DCL.Helpers |
| | 4 | | { |
| | 5 | | public static class PlayerPrefsUtils |
| | 6 | | { |
| 0 | 7 | | public static int GetInt(string key) { return PlayerPrefs.GetInt(key); } |
| | 8 | |
|
| 0 | 9 | | public static int GetInt(string key, int defaultValue) { return PlayerPrefs.GetInt(key, defaultValue); } |
| | 10 | |
|
| 5769 | 11 | | public static bool GetBool(string key, bool defaultValue) => PlayerPrefs.GetInt(key, defaultValue ? 1 : 0) == 1; |
| | 12 | |
|
| | 13 | | public static void SetBool(string key, bool value) |
| | 14 | | { |
| 9 | 15 | | PlayerPrefs.SetInt(key, value ? 1 : 0); |
| 9 | 16 | | } |
| | 17 | |
|
| | 18 | | public static void SetInt(string key, int value) |
| | 19 | | { |
| | 20 | | try |
| | 21 | | { |
| 0 | 22 | | PlayerPrefs.SetInt(key, value); |
| 0 | 23 | | } |
| 0 | 24 | | catch (PlayerPrefsException e) |
| | 25 | | { |
| 0 | 26 | | Debug.Log("There was an issue setting PlayerPrefs int!"); |
| 0 | 27 | | } |
| 0 | 28 | | } |
| | 29 | |
|
| 1923 | 30 | | public static bool HasKey(string key) { return PlayerPrefs.HasKey(key); } |
| | 31 | |
|
| 0 | 32 | | public static string GetString(string key, string defaultValue = null) { return PlayerPrefs.GetString(key, strin |
| | 33 | |
|
| | 34 | | public static void SetString(string key, string value) |
| | 35 | | { |
| | 36 | | try |
| | 37 | | { |
| 0 | 38 | | PlayerPrefs.SetString(key, value); |
| 0 | 39 | | } |
| 0 | 40 | | catch (PlayerPrefsException e) |
| | 41 | | { |
| 0 | 42 | | Debug.Log("There was an issue setting PlayerPrefs string!"); |
| 0 | 43 | | } |
| 0 | 44 | | } |
| | 45 | |
|
| 2 | 46 | | public static void Save() { PlayerPrefs.Save(); } |
| | 47 | |
|
| | 48 | | public static float GetFloat(string key, float defaultValue = 0f) => |
| 0 | 49 | | PlayerPrefs.GetFloat(key, defaultValue); |
| | 50 | |
|
| | 51 | | public static void SetFloat(string key, float value) => |
| 0 | 52 | | PlayerPrefs.SetFloat(key, value); |
| | 53 | | } |
| | 54 | | } |