SettingManager.cs 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using Ragdoll;
  3. using Unity.VisualScripting;
  4. using UnityEngine;
  5. namespace UI.Hall
  6. {
  7. public class SettingManager : ScriptSingleton<SettingManager>
  8. {
  9. public static readonly int Sound = 1;
  10. public static readonly int Music = 2;
  11. public static readonly int Voice = 3;
  12. public Action<int,bool> SoundAction;
  13. private string KeyForSettingByFlag(int flag)
  14. {
  15. return "setting-" + flag;
  16. }
  17. public bool isSettingOpen(int flag)
  18. {
  19. return 1 == PlayerPrefs.GetInt(KeyForSettingByFlag(flag));
  20. }
  21. public void changSetting(int flag, bool on)
  22. {
  23. if (on)
  24. {
  25. PlayerPrefs.SetInt(KeyForSettingByFlag(flag), 1);
  26. }
  27. else
  28. {
  29. PlayerPrefs.SetInt(KeyForSettingByFlag(flag), 0);
  30. }
  31. SoundAction?.Invoke(flag, on);
  32. //
  33. // switch (flag)
  34. // {
  35. // case 1:
  36. // SoundAction?.Invoke(on);
  37. // break;
  38. // case 2:
  39. //
  40. // break;
  41. // case 3:
  42. //
  43. // break;
  44. // }
  45. }
  46. }
  47. }