GraphicsOptionPanel.cs 2.0 KB

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