GraphicsOptionPanel.cs 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. using UnityEngine.Events;
  6. public class GraphicsOptionPanel : OffAnimation
  7. {
  8. [SerializeField] Animator _anim;
  9. [SerializeField] Toggle _showBackgroundParticleToggle;
  10. public void Close()
  11. {
  12. Close_(true);
  13. }
  14. public void Close_(bool playSE)
  15. {
  16. if (playSE)
  17. {
  18. if (Opening.instance != null)
  19. {
  20. Opening.instance.PlayCancelSE();
  21. }
  22. else if (GManager.instance != null)
  23. {
  24. GManager.instance.PlayCancelSE();
  25. }
  26. }
  27. _anim.SetInteger("Open", 0);
  28. _anim.SetInteger("Close", 1);
  29. }
  30. public void Init()
  31. {
  32. Off();
  33. }
  34. public void Open()
  35. {
  36. if (ContinuousController.instance != null)
  37. {
  38. OptionUtility.InitToggle(
  39. toggle: _showBackgroundParticleToggle,
  40. onToggleChanged: OnShowBackgroundParticleToggleChanged,
  41. value: ContinuousController.instance.showBackgroundParticle
  42. );
  43. }
  44. gameObject.SetActive(true);
  45. _anim.SetInteger("Open", 1);
  46. _anim.SetInteger("Close", 0);
  47. }
  48. #region Auto select mode
  49. public void OnShowBackgroundParticleToggleChanged(bool value)
  50. {
  51. if (ContinuousController.instance == null) return;
  52. OptionUtility.OnToggleChanged(
  53. value: value,
  54. toggle: _showBackgroundParticleToggle,
  55. onToggleChanged: OnShowBackgroundParticleToggleChanged,
  56. settingRef: ref ContinuousController.instance.showBackgroundParticle,
  57. saveAction: ContinuousController.instance.SaveShowBackgroundParticle
  58. );
  59. }
  60. public void HandleShowBackgroundParticleToggle()
  61. {
  62. OnShowBackgroundParticleToggleChanged(!_showBackgroundParticleToggle.isOn);
  63. }
  64. #endregion
  65. }