Files
2025TapTapGameJam/Assets/Script/Gameplay/UI/SettingViewer.cs

58 lines
1.5 KiB
C#
Raw Normal View History

using System;
using Core;
using Script.Gameplay.Global;
using TMPro;
using UnityEngine;
using Script.Gameplay.Input;
using UnityEngine.InputSystem;
using UnityEngine.UI;
namespace UI
{
public class SettingViewer : UIBase
{
[SerializeField] private TMP_Text TitleText;
[SerializeField] private TMP_Text ContentText;
[SerializeField] private Button reloadButton;
private InputManager inputManager;
protected override void Awake()
{
base.Awake();
reloadButton.onClick.AddListener(OnReloadButtonClicked);
}
protected override void Start()
{
base.Start();
inputManager = InputManager.Instance;
inputManager.Input.Player.Setting.performed += OnSettingOnperformed;
}
private void OnSettingOnperformed(InputAction.CallbackContext ctx)
{
UIManager.Instance.SwitchUI<SettingViewer>();
}
private void OnReloadButtonClicked()
{
StartCoroutine(GameManager.Instance.ReStartGame());
}
public override void Show()
{
base.Show();
ContentText.text = "循环次数:" + GameDataManager.Instance.TotalLoopCount.ToString();
}
private void OnDestroy()
{
inputManager.Input.Player.Setting.performed -= OnSettingOnperformed;
}
public override void Hide()
{
base.Hide();
}
}
}