Files
aibis-dream/Assets/Scripts/UI/Panel/MainPanel.cs
T
2025-05-28 15:58:50 +08:00

71 lines
1.9 KiB
C#

using UnityEngine;
using UnityEngine.UI;
namespace AibisDream
{
public class MainPanel : MonoBehaviour, IUIPanel
{
public bool IsOpen => gameObject.activeSelf;
public bool IsCloseable => false;
#region 面板控制
public void Show()
{
gameObject.SetActive(true);
}
public void Hide()
{
gameObject.SetActive(false);
}
#endregion
private void Awake()
{
RegisterButton();
}
private void Update()
{
if (Input.GetKey(KeyCode.Q) && Input.GetKeyDown(KeyCode.P))
{
var obj = transform.Find("Top Bar").Find("Quick Forward").gameObject;
var active = obj.activeSelf;
obj.SetActive(!active);
}
}
private void RegisterButton()
{
// 为按钮注册事件
var topBar = transform.Find("Top Bar");
topBar.Find("Setting").GetComponent<Button>().onClick.AddListener(OpenSettingPanel);
topBar.Find("Record").GetComponent<Button>().onClick.AddListener(OpenRecordPanel);
topBar.Find("Auto Skip").GetComponent<Button>().onClick.AddListener(AutoSkip);
topBar.Find("Quick Forward").GetComponent<Button>().onClick.AddListener(QuickForward);
}
private void AutoSkip()
{
DialogController.Instance.autoRunMode = !DialogController.Instance.autoRunMode;
}
private void QuickForward()
{
DialogController.Instance.quickRunMode = !DialogController.Instance.quickRunMode;
}
private void OpenSettingPanel()
{
UIManager.Instance.ShowPanel<SettingPanel>();
}
private void OpenRecordPanel()
{
UIManager.Instance.ShowPanel<RecordPanel>();
}
}
}