123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- using System;
- using System.Collections.Generic;
- using System.Threading.Tasks;
- using UnityEngine;
- using UnityEngine.UI;
- using static System.Net.Mime.MediaTypeNames;
- namespace ET.Client
- {
- [FriendOf(typeof(UISettingComponent))]
- public static class UISettingComponentSystem
- {
- [ObjectSystem]
- public class UISettingComponentAwakeSystem : AwakeSystem<UISettingComponent>
- {
- protected override void Awake(UISettingComponent self)
- {
- ReferenceCollector rc = self.GetParent<UI>().GameObject.GetComponent<ReferenceCollector>();
- self.verCheckBtn = rc.Get<GameObject>("verCheckBtn");
- self.verCheckBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnVerCheckBtn(); });
- self.quitLoginBtn = rc.Get<GameObject>("quitLoginBtn");
- self.quitLoginBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnQuitLoginBtn(); });
- self.gameoBgVedioBtn = rc.Get<GameObject>("gameoBgVedioBtn");
- self.gameoBgVedioBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnGameoBgVedioBtn(); });
- self.gameoInVedioBtn = rc.Get<GameObject>("gameoInVedioBtn");
- self.gameoInVedioBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnGameoInVedioBtn(); });
- self.closeBtn = rc.Get<GameObject>("closeBtn");
- self.closeBtn.GetComponent<Button>().onClick.AddListener(() => { self.OnCloseBtn(); });
- self.gameoBgVedioSlider = rc.Get<GameObject>("gameoBgVedioSlider");
- self.gameoBgVedioSlider.GetComponent<Slider>().onValueChanged.AddListener((val) => { self.OnGameoBgVedioSlider(val); });
- self.gameoInVedioSlider = rc.Get<GameObject>("gameoInVedioSlider");
- self.gameoInVedioSlider.GetComponent<Slider>().onValueChanged.AddListener((val) => { self.OnGameoInVedioSlider(val); });
- self.Init();
- }
- }
- private static void Init(this UISettingComponent self)
- {
-
- }
- public static void OnVerCheckBtn(this UISettingComponent self)
- {
-
- }
- public static void OnQuitLoginBtn(this UISettingComponent self)
- {
- }
- public static async void OnGameoBgVedioBtn(this UISettingComponent self)
- {
- self.isGameBgVedio = !self.isGameBgVedio;
- string abName = self.isGameBgVedio ? "setting_max_sound_sign" : "setting_min_sound_sign";
- await ResourcesComponentHelper.Instance.LoadSprite(self.ClientScene(),"setingatlas");
- Sprite sprite = ResourcesComponentHelper.Instance.GetSprite("setingatlas",abName);
- self.gameoBgVedioBtn.GetComponent<UnityEngine.UI.Image>().sprite = sprite;
- MusicSoundComponent.Instance.MusicMuteSwitch(!self.isGameBgVedio);
- self.gameoBgVedioSlider.GetComponent<Slider>().value = self.isGameBgVedio? PlayerPrefs.GetFloat(MusicSoundComponent.MusicVolumeBgPrefsName) : 0;
- }
- public static async void OnGameoInVedioBtn(this UISettingComponent self)
- {
- self.isGameInVedio = !self.isGameInVedio;
- string abName = self.isGameInVedio ? "setting_max_sound_sign" : "setting_min_sound_sign";
- await ResourcesComponentHelper.Instance.LoadSprite(self.ClientScene(), "setingatlas");
- Sprite sprite = ResourcesComponentHelper.Instance.GetSprite("setingatlas", abName);
- self.gameoInVedioBtn.GetComponent<UnityEngine.UI.Image>().sprite = sprite;
- MusicSoundComponent.Instance.SoundMuteSwitch(!self.isGameInVedio);
- self.gameoInVedioSlider.GetComponent<Slider>().value = self.isGameInVedio ? PlayerPrefs.GetFloat(MusicSoundComponent.SoundVolumePrefsName) : 0;
- }
- public static void OnCloseBtn(this UISettingComponent self)
- {
- self.OnCloseAsync();
- }
- public static async void OnGameoBgVedioSlider(this UISettingComponent self,float val)
- {
- if (val <= 0)
- {
- return;
- }
- self.isGameBgVedio = true;
- string abName = self.isGameBgVedio ? "setting_max_sound_sign" : "setting_min_sound_sign";
- await ResourcesComponentHelper.Instance.LoadSprite(self.ClientScene(), "setingatlas");
- Sprite sprite = ResourcesComponentHelper.Instance.GetSprite("setingatlas", abName);
- self.gameoBgVedioBtn.GetComponent<UnityEngine.UI.Image>().sprite = sprite;
- MusicSoundComponent.Instance.MusicMuteSwitch(!self.isGameBgVedio);
- MusicSoundComponent.Instance.MusicBgVolume = val;
- }
- public static async void OnGameoInVedioSlider(this UISettingComponent self, float val)
- {
- if (val <= 0)
- {
- return;
- }
- self.isGameInVedio = true;
- string abName = self.isGameInVedio ? "setting_max_sound_sign" : "setting_min_sound_sign";
- await ResourcesComponentHelper.Instance.LoadSprite(self.ClientScene(), "setingatlas");
- Sprite sprite = ResourcesComponentHelper.Instance.GetSprite("setingatlas", abName);
- self.gameoInVedioBtn.GetComponent<UnityEngine.UI.Image>().sprite = sprite;
- MusicSoundComponent.Instance.SoundMuteSwitch(!self.isGameInVedio);
- MusicSoundComponent.Instance.SoundVolume = val;
- }
- public static async void OnCloseAsync(this UISettingComponent self)
- {
- await UIHelper.Remove(self.ClientScene(),UIType.UISetting);
- }
- }
- }
|