refactor(UI):完善对于各个界面的管理逻辑,esc可以直接关闭所有的顶层UI

This commit is contained in:
2025-10-27 21:41:25 +08:00
parent 1462f4689e
commit 4951f25187
21 changed files with 18049 additions and 6374 deletions

View File

@@ -50,6 +50,7 @@ namespace Script.Gameplay.Player
{
inputManager = InputManager.Instance;
inputManager.Input.Player.Edit.performed += OnEditOnperformed;
inputManager.Input.Player.Escape.performed += OnEscapeOnperformed;
timePauseManager = TimePauseManager.Instance;
if (raycaster == null)
raycaster = GetComponent<FirstPersonRaycaster>() ?? GetComponentInChildren<FirstPersonRaycaster>();
@@ -62,7 +63,19 @@ namespace Script.Gameplay.Player
private void OnEditOnperformed(InputAction.CallbackContext context)
{
EditTarget();
if (!isEditing)
{
BeginEdit();
}
else
{
EndEdit();
}
}
private void OnEscapeOnperformed(InputAction.CallbackContext context)
{
EndEdit();
}
void Update()
@@ -85,34 +98,28 @@ namespace Script.Gameplay.Player
}
CurrentTarget = hitEditable;
}
private void EditTarget()
private void BeginEdit()
{
if (isEditing)
if (CurrentTarget == null) return;
if (!IsEnableEditing) return;
if(isEditing) return;
isEditing = true;
OnBeginEditTarget?.Invoke(CurrentTarget);
if (timePauseManager != null)
{
isEditing = false;
OnEndEditTarget?.Invoke(CurrentTarget);
inputManager.SetCursorState(false, CursorLockMode.Locked);
inputManager.SetInputForLook(true);
inputManager.SetInputForMove(true);
if (timePauseManager != null)
{
timePauseManager.SetPaused(false);
}
timePauseManager.SetPaused(true);
}
else
}
private void EndEdit()
{
if (!isEditing) return;
isEditing = false;
OnEndEditTarget?.Invoke(CurrentTarget);
if (timePauseManager != null)
{
if (CurrentTarget == null) return;
if (!IsEnableEditing) return;
isEditing = true;
OnBeginEditTarget?.Invoke(CurrentTarget);
inputManager.SetCursorState(true, CursorLockMode.Confined);
inputManager.SetInputForLook(false);
inputManager.SetInputForMove(false);
if (timePauseManager != null)
{
timePauseManager.SetPaused(true);
}
timePauseManager.SetPaused(false);
}
}
@@ -121,6 +128,7 @@ namespace Script.Gameplay.Player
if (inputManager != null)
{
inputManager.Input.Player.Edit.performed -= OnEditOnperformed;
inputManager.Input.Player.Escape.performed -= OnEscapeOnperformed;
}
ControllerLocator.Instance.Unregister(this);
}