GraphicsOptionPanel.cs 2.1 KB

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