refactor(UI):完善对于各个界面的管理逻辑,esc可以直接关闭所有的顶层UI
This commit is contained in:
@@ -12,7 +12,7 @@ namespace UI
|
||||
public TMP_Text countdownText;
|
||||
private GameCountdownManager _countdownManager;
|
||||
|
||||
private void Start()
|
||||
protected override void Start()
|
||||
{
|
||||
_countdownManager = GameCountdownManager.Instance;
|
||||
if (_countdownManager != null)
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace UI
|
||||
{
|
||||
[SerializeField] private TMP_Text dialogueText;
|
||||
[SerializeField] private GameObject panel;
|
||||
private bool isShowingPanel = false;
|
||||
private PlayerDialogueController playerDialogueController;
|
||||
private InputManager inputManager;
|
||||
|
||||
@@ -29,23 +28,12 @@ namespace UI
|
||||
playerDialogueController = controller;
|
||||
playerDialogueController.RegisterDialogueViewer(this);
|
||||
}
|
||||
|
||||
|
||||
public void ReceiveDialogue(string content)
|
||||
{
|
||||
if(!isShowingPanel) OpenPanel();
|
||||
UIManager.Instance.OpenUI<PlayerDialogueViewer>();
|
||||
dialogueText.text = content;
|
||||
}
|
||||
|
||||
private void OpenPanel()
|
||||
{
|
||||
isShowingPanel = true;
|
||||
Show();
|
||||
}
|
||||
|
||||
public void ClosePanel()
|
||||
{
|
||||
isShowingPanel = false;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace UI
|
||||
|
||||
public void OnBeginEdit(GameObject target)
|
||||
{
|
||||
this.gameObject.SetActive(true);
|
||||
UIManager.Instance.OpenUI<PlayerEditViewer>();
|
||||
if (target == null)
|
||||
{
|
||||
if (noEditableTargetPanel != null)
|
||||
@@ -46,8 +46,7 @@ namespace UI
|
||||
|
||||
public void OnEndEdit(GameObject target)
|
||||
{
|
||||
this.gameObject.SetActive(false);
|
||||
|
||||
UIManager.Instance.CloseUI<PlayerEditViewer>();
|
||||
ClearComponentUI();
|
||||
if (noEditableTargetPanel != null)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace UI
|
||||
private PlayerController _playerController;
|
||||
public TMP_Text hpText;
|
||||
|
||||
private void Awake()
|
||||
protected override void Awake()
|
||||
{
|
||||
ControllerLocator.Instance.TryGetWait<PlayerController>(OnGet);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace UI
|
||||
private PlayerWatchModeController watchModeController;
|
||||
[SerializeField] private TMP_Text modeText;
|
||||
|
||||
private void Awake()
|
||||
protected override void Awake()
|
||||
{
|
||||
ControllerLocator.Instance.TryGetWait<PlayerWatchModeController>(OnGet);
|
||||
}
|
||||
|
||||
@@ -16,14 +16,20 @@ namespace UI
|
||||
[SerializeField] private Button reloadButton;
|
||||
|
||||
private InputManager inputManager;
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
inputManager = InputManager.Instance;
|
||||
inputManager.Input.Player.Setting.performed += RegisterInput;
|
||||
reloadButton.onClick.AddListener(OnReloadButtonClicked);
|
||||
}
|
||||
|
||||
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
inputManager = InputManager.Instance;
|
||||
inputManager.Input.Player.Setting.performed += (ctx) => { UIManager.Instance.SwitchUI<SettingViewer>(); };
|
||||
}
|
||||
|
||||
private void OnReloadButtonClicked()
|
||||
{
|
||||
GameManager.Instance.ReStartGame();
|
||||
@@ -32,7 +38,7 @@ namespace UI
|
||||
inputManager.SetInputForLook(true);
|
||||
inputManager.SetInputForMove(true);
|
||||
}
|
||||
|
||||
|
||||
private void RegisterInput(InputAction.CallbackContext ctx)
|
||||
{
|
||||
if (!isActiveAndEnabled)
|
||||
|
||||
Reference in New Issue
Block a user