107 lines
3.4 KiB
C#
107 lines
3.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using AibisDream.Utility;
|
|
|
|
namespace AibisDream
|
|
{
|
|
public class SettingPanel : MonoBehaviour, IUIPanel
|
|
{
|
|
public bool IsOpen => gameObject.activeSelf;
|
|
public bool IsCloseable => true;
|
|
|
|
#region 打开和关闭
|
|
|
|
public void Show()
|
|
{
|
|
// 暂停游戏
|
|
GameManager.Instance.PauseGame();
|
|
|
|
gameObject.SetActive(true);
|
|
// 更新表单内容
|
|
var form = GetComponentInChildren<SettingForm>();
|
|
form.Init();
|
|
// 注册函数
|
|
RegisterButton();
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
// 更新表单内容
|
|
var form = GetComponentInChildren<SettingForm>();
|
|
form.UnInit();
|
|
UnRegisterButton();
|
|
|
|
gameObject.SetActive(false);
|
|
// 继续游戏
|
|
GameManager.Instance.ContinueGame();
|
|
}
|
|
|
|
#endregion
|
|
|
|
private void RegisterButton()
|
|
{
|
|
var mainGroup = transform.Find("Main");
|
|
var buttonGroup = mainGroup.Find("Button Group");
|
|
var continueBtn = buttonGroup.Find("Continue").GetComponent<Button>();
|
|
continueBtn.onClick.AddListener(BackToGame);
|
|
var backToMain = buttonGroup.Find("BackMain").GetComponent<Button>();
|
|
backToMain.onClick.AddListener(BackToMain);
|
|
var quit = buttonGroup.Find("Quit").GetComponent<Button>();
|
|
quit.onClick.AddListener(Quit);
|
|
|
|
var othersGroup = transform.Find("Others");
|
|
var wishlistBtn = othersGroup.Find("Wishlist").GetComponent<Button>();
|
|
wishlistBtn.onClick.AddListener(OpenWishlist);
|
|
var bugBtn = othersGroup.Find("Bug").GetComponent<Button>();
|
|
bugBtn.onClick.AddListener(OpenBugReport);
|
|
}
|
|
|
|
private void UnRegisterButton()
|
|
{
|
|
var mainGroup = transform.Find("Main");
|
|
var buttonGroup = mainGroup.Find("Button Group");
|
|
var continueBtn = buttonGroup.Find("Continue").GetComponent<Button>();
|
|
continueBtn.onClick.RemoveAllListeners();
|
|
var backToMain = buttonGroup.Find("BackMain").GetComponent<Button>();
|
|
backToMain.onClick.RemoveAllListeners();
|
|
var quit = buttonGroup.Find("Quit").GetComponent<Button>();
|
|
quit.onClick.RemoveAllListeners();
|
|
|
|
var othersGroup = transform.Find("Others");
|
|
var wishlistBtn = othersGroup.Find("Wishlist").GetComponent<Button>();
|
|
wishlistBtn.onClick.RemoveAllListeners();
|
|
var bugBtn = othersGroup.Find("Bug").GetComponent<Button>();
|
|
bugBtn.onClick.RemoveAllListeners();
|
|
}
|
|
|
|
private void BackToGame()
|
|
{
|
|
// 关闭Setting面板
|
|
UIManager.Instance.HidePanel<SettingPanel>();
|
|
}
|
|
|
|
private void BackToMain()
|
|
{
|
|
// 关闭Setting面板
|
|
UIManager.Instance.HidePanel<SettingPanel>();
|
|
// 重启
|
|
GameManager.Instance.QuitGame();
|
|
}
|
|
|
|
private void Quit()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
private void OpenWishlist()
|
|
{
|
|
Application.OpenURL(ConstRef.WishlistURL);
|
|
}
|
|
|
|
private void OpenBugReport()
|
|
{
|
|
Application.OpenURL(ConstRef.BugSurveyURL);
|
|
}
|
|
}
|
|
}
|