LocalCache.cs 820 B

1234567891011121314151617181920212223242526272829303132
  1. using UnityEngine;
  2. namespace GFGGame
  3. {
  4. public class LocalCache
  5. {
  6. public static void SetBool(string key, bool isOn)
  7. {
  8. int value = isOn ? 1 : 0;
  9. PlayerPrefs.SetInt(key, value);
  10. PlayerPrefs.Save();
  11. }
  12. public static bool GetBool(string key, bool defaultValue)
  13. {
  14. int defaultInt = defaultValue ? 1 : 0;
  15. int value = PlayerPrefs.GetInt(key, defaultInt);
  16. return value > 0;
  17. }
  18. public static void SetFloat(string key, float value)
  19. {
  20. PlayerPrefs.SetFloat(key, value);
  21. PlayerPrefs.Save();
  22. }
  23. //public static float GetFloat(string key, float defaultValue)
  24. //{
  25. // return PlayerPrefs.GetFloat(key, defaultValue);
  26. //}
  27. }
  28. }