PlayerPrefManager.cs 756 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PlayerPrefManager
  5. {
  6. public const string INTERACT_CONFIG = "Interact_Config";
  7. public static bool GetBool(string label, bool defaultValue)
  8. {
  9. int i = PlayerPrefs.GetInt(label, -1);
  10. if (i == -1)
  11. {
  12. return defaultValue;
  13. }
  14. if (i == 0)
  15. {
  16. return false;
  17. }
  18. else
  19. {
  20. return true;
  21. }
  22. }
  23. public static void SaveBool(string label, bool value)
  24. {
  25. if (value)
  26. {
  27. PlayerPrefs.SetInt(label, 1);
  28. }
  29. else
  30. {
  31. PlayerPrefs.SetInt(label, 0);
  32. }
  33. PlayerPrefs.Save();
  34. }
  35. }