2025-10-26 09:32:28 +08:00
|
|
|
using System;
|
|
|
|
|
using Core;
|
|
|
|
|
using Script.Gameplay.Global;
|
|
|
|
|
using TMPro;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using Script.Gameplay.Input;
|
2025-10-26 10:19:23 +08:00
|
|
|
using UnityEngine.InputSystem;
|
2025-10-27 10:31:01 +08:00
|
|
|
using UnityEngine.UI;
|
2025-10-26 09:32:28 +08:00
|
|
|
|
|
|
|
|
namespace UI
|
|
|
|
|
{
|
|
|
|
|
public class SettingViewer : UIBase
|
|
|
|
|
{
|
|
|
|
|
[SerializeField] private TMP_Text TitleText;
|
|
|
|
|
[SerializeField] private TMP_Text ContentText;
|
2025-10-27 10:31:01 +08:00
|
|
|
[SerializeField] private Button reloadButton;
|
2025-10-26 09:32:28 +08:00
|
|
|
|
|
|
|
|
private InputManager inputManager;
|
|
|
|
|
protected override void Awake()
|
|
|
|
|
{
|
|
|
|
|
base.Awake();
|
|
|
|
|
inputManager = InputManager.Instance;
|
2025-10-26 10:19:23 +08:00
|
|
|
inputManager.Input.Player.Setting.performed += RegisterInput;
|
2025-10-27 10:31:01 +08:00
|
|
|
reloadButton.onClick.AddListener(OnReloadButtonClicked);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnReloadButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
GameManager.Instance.ReStartGame();
|
|
|
|
|
ContentText.text = "循环次数:" + GameDataManager.Instance.TotalLoopCount.ToString();
|
|
|
|
|
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
|
|
|
|
inputManager.SetInputForLook(true);
|
|
|
|
|
inputManager.SetInputForMove(true);
|
2025-10-26 10:19:23 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void RegisterInput(InputAction.CallbackContext ctx)
|
|
|
|
|
{
|
|
|
|
|
if (!isActiveAndEnabled)
|
|
|
|
|
{
|
|
|
|
|
Show();
|
2025-10-27 10:31:01 +08:00
|
|
|
inputManager.SetCursorState(true, CursorLockMode.Confined);
|
2025-10-26 10:19:23 +08:00
|
|
|
inputManager.SetInputForLook(false);
|
|
|
|
|
inputManager.SetInputForMove(false);
|
|
|
|
|
}
|
|
|
|
|
else
|
2025-10-26 09:32:28 +08:00
|
|
|
{
|
2025-10-26 10:19:23 +08:00
|
|
|
Hide();
|
2025-10-27 10:31:01 +08:00
|
|
|
inputManager.SetCursorState(false, CursorLockMode.Locked);
|
2025-10-26 10:19:23 +08:00
|
|
|
inputManager.SetInputForLook(true);
|
|
|
|
|
inputManager.SetInputForMove(true);
|
|
|
|
|
}
|
2025-10-26 09:32:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Show()
|
|
|
|
|
{
|
|
|
|
|
base.Show();
|
|
|
|
|
ContentText.text = "循环次数:" + GameDataManager.Instance.TotalLoopCount.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Hide()
|
|
|
|
|
{
|
|
|
|
|
base.Hide();
|
|
|
|
|
}
|
2025-10-26 10:19:23 +08:00
|
|
|
|
|
|
|
|
private void OnDestroy()
|
|
|
|
|
{
|
|
|
|
|
inputManager.Input.Player.Setting.performed -= RegisterInput;
|
|
|
|
|
}
|
2025-10-26 09:32:28 +08:00
|
|
|
}
|
|
|
|
|
}
|