UIStartAudioOptionController.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using System;
  2. using UnityEngine;
  3. public class UIStartAudioOptionController : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. this._effectButtonLabel.alpha = ((!R.Audio.IsEffectsMute) ? 1f : 0.5f);
  8. this._bgmButtonLabel.alpha = ((!R.Audio.IsBGMMute) ? 1f : 0.5f);
  9. this._effectProgressBar.value = R.Audio.EffectsVolume / 100f;
  10. this._effectProgressBar.alpha = ((!R.Audio.IsEffectsMute) ? 1f : 0.5f);
  11. this._bgmProgressBar.value = R.Audio.BGMVolume / 100f;
  12. this._bgmProgressBar.alpha = ((!R.Audio.IsBGMMute) ? 1f : 0.5f);
  13. }
  14. private void OnEnable()
  15. {
  16. EventDelegate.Add(this._effectProgressBar.onChange, new EventDelegate.Callback(this.OnEffectVolumeChanged));
  17. EventDelegate.Add(this._bgmProgressBar.onChange, new EventDelegate.Callback(this.OnBGMVolumeChanged));
  18. }
  19. private void OnDisable()
  20. {
  21. EventDelegate.Remove(this._effectProgressBar.onChange, new EventDelegate.Callback(this.OnEffectVolumeChanged));
  22. EventDelegate.Remove(this._bgmProgressBar.onChange, new EventDelegate.Callback(this.OnBGMVolumeChanged));
  23. R.Settings.Save();
  24. }
  25. private void OnEffectVolumeChanged()
  26. {
  27. R.Audio.EffectsVolume = this._effectProgressBar.value * 100f;
  28. }
  29. private void OnBGMVolumeChanged()
  30. {
  31. R.Audio.BGMVolume = this._bgmProgressBar.value * 100f;
  32. }
  33. public void OnEffectClick()
  34. {
  35. R.Audio.IsEffectsMute = !R.Audio.IsEffectsMute;
  36. this._effectButtonLabel.alpha = ((!R.Audio.IsEffectsMute) ? 1f : 0.5f);
  37. this._effectProgressBar.alpha = ((!R.Audio.IsEffectsMute) ? 1f : 0.5f);
  38. }
  39. public void OnBgmClick()
  40. {
  41. R.Audio.IsBGMMute = !R.Audio.IsBGMMute;
  42. this._bgmButtonLabel.alpha = ((!R.Audio.IsBGMMute) ? 1f : 0.5f);
  43. this._bgmProgressBar.alpha = ((!R.Audio.IsBGMMute) ? 1f : 0.5f);
  44. }
  45. [SerializeField]
  46. private GameObject _effectButton;
  47. [SerializeField]
  48. private UILabel _effectButtonLabel;
  49. [SerializeField]
  50. private GameObject _bgmButton;
  51. [SerializeField]
  52. private UILabel _bgmButtonLabel;
  53. [SerializeField]
  54. private UIProgressBar _effectProgressBar;
  55. [SerializeField]
  56. private UIProgressBar _bgmProgressBar;
  57. }