LocalCache.cs 495 B

12345678910111213141516171819202122
  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. }
  19. }