| | 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 | |
|
| 5760 | 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 | | { |
| 18 | 22 | | PlayerPrefs.SetInt(key, value); |
| 18 | 23 | | } |
| 0 | 24 | | catch (PlayerPrefsException e) |
| | 25 | | { |
| 0 | 26 | | Debug.Log("There was an issue setting PlayerPrefs int!"); |
| 0 | 27 | | } |
| 18 | 28 | | } |
| | 29 | |
|
| 1920 | 30 | | public static bool HasKey(string key) { return PlayerPrefs.HasKey(key); } |
| | 31 | |
|
| 10 | 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 | | { |
| 19 | 38 | | PlayerPrefs.SetString(key, value); |
| 19 | 39 | | } |
| 0 | 40 | | catch (PlayerPrefsException e) |
| | 41 | | { |
| 0 | 42 | | Debug.Log("There was an issue setting PlayerPrefs string!"); |
| 0 | 43 | | } |
| 19 | 44 | | } |
| | 45 | |
|
| 72 | 46 | | public static void Save() { PlayerPrefs.Save(); } |
| | 47 | | } |
| | 48 | | } |