2023-11-07 14:25:44 +08:00
|
|
|
using PhxhSDK;
|
2023-11-06 19:06:05 +08:00
|
|
|
using TMPro;
|
2023-11-07 14:25:44 +08:00
|
|
|
using UnityEngine;
|
2023-11-06 19:06:05 +08:00
|
|
|
using Button = UnityEngine.UI.Button;
|
|
|
|
|
using Image = UnityEngine.UI.Image;
|
|
|
|
|
using Slider = UnityEngine.UI.Slider;
|
|
|
|
|
using Toggle = UnityEngine.UI.Toggle;
|
|
|
|
|
|
|
|
|
|
public class UI_SettingController : UIWindow
|
|
|
|
|
{
|
2023-11-07 14:25:44 +08:00
|
|
|
private const float MinVolume = 0.1f;
|
|
|
|
|
private const float MaxVolume = 1f;
|
|
|
|
|
|
2023-11-06 19:06:05 +08:00
|
|
|
//UI GameObj
|
|
|
|
|
///Auto Gen Start///
|
|
|
|
|
public Image Image_SettingBG;
|
|
|
|
|
public TMP_Text Text_Setting;
|
|
|
|
|
public Button Button_PressedDown_Game;
|
|
|
|
|
public Button Button_UnPressed_Game;
|
|
|
|
|
public Button Button_PressedDown_Image;
|
|
|
|
|
public Button Button_UnPressed_Image;
|
|
|
|
|
public Button Button_PressedDown_Music;
|
|
|
|
|
public Button Button_UnPressed_Music;
|
|
|
|
|
public Image Image_ImageBG;
|
|
|
|
|
public TMP_Text Text_Image;
|
|
|
|
|
public TMP_Text Text_ResolutionRatio;
|
|
|
|
|
public Toggle Toggle_Max;
|
|
|
|
|
public Toggle Toggle_High;
|
|
|
|
|
public TMP_Text Text_High;
|
|
|
|
|
public Toggle Toggle_Middle;
|
|
|
|
|
public TMP_Text Text_Middle;
|
|
|
|
|
public Toggle Toggle_Low;
|
|
|
|
|
public TMP_Text Text_Low;
|
|
|
|
|
public TMP_Text Text_Frame;
|
|
|
|
|
public Toggle Toggle_60;
|
|
|
|
|
public TMP_Text Text_60;
|
|
|
|
|
public Toggle Toggle_30;
|
|
|
|
|
public TMP_Text Text_30;
|
|
|
|
|
public TMP_Text Text_RenderMode;
|
|
|
|
|
public Image Image_MusicBG;
|
|
|
|
|
public TMP_Text Text_Music;
|
|
|
|
|
public TMP_Text Text_BGM;
|
|
|
|
|
public Button Button_Max_BGM;
|
|
|
|
|
public Button Button_Min_BGM;
|
|
|
|
|
public Button Button_NoSound_BGM;
|
|
|
|
|
public Slider Slider_BGM;
|
|
|
|
|
public TMP_Text Text_SE;
|
|
|
|
|
public Button Button_Max_SoundEffect;
|
|
|
|
|
public Button Button_Min_SoundEffect;
|
|
|
|
|
public Slider Slider_SoundEffect;
|
|
|
|
|
public Button Button_NoSound_SoundEffect;
|
|
|
|
|
public Button Button_Close;
|
|
|
|
|
|
|
|
|
|
///Auto Gen End///
|
|
|
|
|
|
|
|
|
|
// Use this for initialization
|
|
|
|
|
public override void OnAwake()
|
|
|
|
|
{
|
|
|
|
|
UI_SettingBinder.GetComponents(this);
|
|
|
|
|
BindButton(Button_UnPressed_Image, OpenImagePanel);
|
|
|
|
|
BindButton(Button_UnPressed_Music, OpenMusicPanel);
|
|
|
|
|
BindButton(Button_UnPressed_Game, OpenGamePanel);
|
|
|
|
|
|
2023-11-07 14:25:44 +08:00
|
|
|
//最大音量
|
|
|
|
|
BindButton(Button_Max_BGM, delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalMusicVolume = MaxVolume;
|
|
|
|
|
Slider_BGM.value = MaxVolume;
|
|
|
|
|
});
|
|
|
|
|
BindButton(Button_Max_SoundEffect, delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalSoundsVolume = MaxVolume;
|
|
|
|
|
Slider_SoundEffect.value = MaxVolume;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//最小音量
|
|
|
|
|
BindButton(Button_Min_BGM, delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalMusicVolume = MinVolume;
|
|
|
|
|
Slider_BGM.value = MinVolume;
|
|
|
|
|
});
|
|
|
|
|
BindButton(Button_Min_SoundEffect, delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalSoundsVolume = MinVolume;
|
|
|
|
|
Slider_SoundEffect.value = MinVolume;
|
|
|
|
|
});
|
2023-11-06 19:06:05 +08:00
|
|
|
|
2023-11-07 14:25:44 +08:00
|
|
|
//静音
|
|
|
|
|
BindButton(Button_NoSound_BGM, () => AudioManager.Instance.SetMusicEnable(false));
|
|
|
|
|
BindButton(Button_NoSound_SoundEffect, () => AudioManager.Instance.SetSoundEnable(false));
|
|
|
|
|
|
|
|
|
|
//滑动条
|
|
|
|
|
Slider_BGM.value = AudioManager.Instance.GlobalMusicVolume;
|
|
|
|
|
Slider_SoundEffect.value = AudioManager.Instance.GlobalSoundsVolume;
|
|
|
|
|
|
|
|
|
|
Slider_BGM.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalMusicVolume = Slider_BGM.value;
|
|
|
|
|
});
|
|
|
|
|
Slider_SoundEffect.onValueChanged.AddListener(delegate
|
|
|
|
|
{
|
|
|
|
|
AudioManager.Instance.GlobalSoundsVolume = Slider_SoundEffect.value;
|
|
|
|
|
});
|
2023-11-06 19:06:05 +08:00
|
|
|
|
2023-11-07 14:25:44 +08:00
|
|
|
BindButton(Button_Close, () => CloseWindow());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-11-06 19:06:05 +08:00
|
|
|
private void OpenImagePanel()
|
|
|
|
|
{
|
|
|
|
|
Button_UnPressed_Image.gameObject.SetActive(false);
|
|
|
|
|
Button_UnPressed_Music.gameObject.SetActive(true);
|
|
|
|
|
Button_UnPressed_Game.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
Image_MusicBG.gameObject.SetActive(false);
|
|
|
|
|
Image_ImageBG.gameObject.SetActive(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenMusicPanel()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
Button_UnPressed_Music.gameObject.SetActive(false);
|
|
|
|
|
Button_UnPressed_Image.gameObject.SetActive(true);
|
|
|
|
|
Button_UnPressed_Game.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
Image_ImageBG.gameObject.SetActive(false);
|
|
|
|
|
Image_MusicBG.gameObject.SetActive(true);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OpenGamePanel()
|
|
|
|
|
{
|
|
|
|
|
Button_UnPressed_Music.gameObject.SetActive(true);
|
|
|
|
|
Button_UnPressed_Image.gameObject.SetActive(true);
|
|
|
|
|
Button_UnPressed_Game.gameObject.SetActive(false);
|
|
|
|
|
|
|
|
|
|
Image_ImageBG.gameObject.SetActive(false);
|
|
|
|
|
Image_MusicBG.gameObject.SetActive(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//invoke when open window
|
|
|
|
|
protected override void OnOpenWindow(object data = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//invoke when reload window
|
|
|
|
|
protected override void OnReloadWindow(object data = null)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//invoke when close window
|
|
|
|
|
protected override void OnCloseWindow(bool destroy = false)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|