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

@@ -9,6 +9,7 @@ namespace Script.Gameplay.Input
public class InputManager : MonoSingleton<InputManager>, IInputManager
{
public PlayerInputActions Input; // 自动生成的输入类
private UIManager _uiManager;
// 当前输入值
public Vector2 Move { get; private set; }
@@ -58,7 +59,8 @@ namespace Script.Gameplay.Input
Input.Player.Edit.performed += ctx => EditPressed = true;
Input.Player.Edit.canceled += ctx => EditPressed = false;
UIManager.Instance.RegisterInputManager(this);
_uiManager = UIManager.Instance;
_uiManager.RegisterInputManager(this);
}
private void Update()

View File

@@ -154,6 +154,15 @@ namespace Script.Gameplay.Input
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
},
{
""name"": ""Escape"",
""type"": ""Button"",
""id"": ""03c74252-1ecd-4fd7-af3e-d87cef62965f"",
""expectedControlType"": """",
""processors"": """",
""interactions"": """",
""initialStateCheck"": false
}
],
""bindings"": [
@@ -354,6 +363,17 @@ namespace Script.Gameplay.Input
""action"": ""Setting"",
""isComposite"": false,
""isPartOfComposite"": false
},
{
""name"": """",
""id"": ""a8cf95c0-2bad-4ed5-a737-e55f56e3306c"",
""path"": ""<Keyboard>/escape"",
""interactions"": """",
""processors"": """",
""groups"": """",
""action"": ""Escape"",
""isComposite"": false,
""isPartOfComposite"": false
}
]
}
@@ -376,6 +396,7 @@ namespace Script.Gameplay.Input
m_Player_ShowNextDialogue = m_Player.FindAction("ShowNextDialogue", throwIfNotFound: true);
m_Player_Read = m_Player.FindAction("Read", throwIfNotFound: true);
m_Player_Setting = m_Player.FindAction("Setting", throwIfNotFound: true);
m_Player_Escape = m_Player.FindAction("Escape", throwIfNotFound: true);
}
~@PlayerInputActions()
@@ -456,6 +477,7 @@ namespace Script.Gameplay.Input
private readonly InputAction m_Player_ShowNextDialogue;
private readonly InputAction m_Player_Read;
private readonly InputAction m_Player_Setting;
private readonly InputAction m_Player_Escape;
public struct PlayerActions
{
private @PlayerInputActions m_Wrapper;
@@ -474,6 +496,7 @@ namespace Script.Gameplay.Input
public InputAction @ShowNextDialogue => m_Wrapper.m_Player_ShowNextDialogue;
public InputAction @Read => m_Wrapper.m_Player_Read;
public InputAction @Setting => m_Wrapper.m_Player_Setting;
public InputAction @Escape => m_Wrapper.m_Player_Escape;
public InputActionMap Get() { return m_Wrapper.m_Player; }
public void Enable() { Get().Enable(); }
public void Disable() { Get().Disable(); }
@@ -525,6 +548,9 @@ namespace Script.Gameplay.Input
@Setting.started += instance.OnSetting;
@Setting.performed += instance.OnSetting;
@Setting.canceled += instance.OnSetting;
@Escape.started += instance.OnEscape;
@Escape.performed += instance.OnEscape;
@Escape.canceled += instance.OnEscape;
}
private void UnregisterCallbacks(IPlayerActions instance)
@@ -571,6 +597,9 @@ namespace Script.Gameplay.Input
@Setting.started -= instance.OnSetting;
@Setting.performed -= instance.OnSetting;
@Setting.canceled -= instance.OnSetting;
@Escape.started -= instance.OnEscape;
@Escape.performed -= instance.OnEscape;
@Escape.canceled -= instance.OnEscape;
}
public void RemoveCallbacks(IPlayerActions instance)
@@ -604,6 +633,7 @@ namespace Script.Gameplay.Input
void OnShowNextDialogue(InputAction.CallbackContext context);
void OnRead(InputAction.CallbackContext context);
void OnSetting(InputAction.CallbackContext context);
void OnEscape(InputAction.CallbackContext context);
}
}
}