Files
Echo/Assets/_Project/Docs/InGamePauseMenu_Setup.md
2026-07-08 20:42:51 +08:00

52 lines
2.4 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## InGame 暂停菜单(ESC)接入说明
目标:在游戏场景按 ESC 打开中置菜单(保存并退出 / 设置 / 返回游戏),并在 UI 打开时锁定玩家移动/互动。
### 一、脚本清单
- 暂停菜单控制器:[InGamePauseMenuController.cs](file:///e:/Unity/Unity%20Program/Test_2022/Assets/_Project/Scripts/UI/PauseMenu/InGamePauseMenuController.cs)
- 输入锁定服务:[PlayerControlLockService.cs](file:///e:/Unity/Unity%20Program/Test_2022/Assets/_Project/Scripts/Core/InputLock/PlayerControlLockService.cs)
- 面板栈(ESC 关闭顺序):[UIPanelStack.cs](file:///e:/Unity/Unity%20Program/Test_2022/Assets/_Project/Scripts/UI/PanelStack/UIPanelStack.cs)
- 设置面板控制器:[SettingsController.cs](file:///e:/Unity/Unity%20Program/Test_2022/Assets/_Project/Scripts/UI/Settings/SettingsController.cs)
### 二、Hierarchy 结构建议
- InGamePauseMenuRootSetActive=false
- ButtonsVerticalLayoutGroup
- BtnSaveAndExitReach ButtonManager
- BtnSettingsReach ButtonManager
- BtnReturnToGameReach ButtonManager
### 三、场景操作步骤
1) 确保场景里有 `_Bootstrap` 并挂 `SettingsBootstrap`
- `SettingsBootstrap` 会自动创建:
- SettingsService
- UIPanelStack + UIPanelStackInput
- PlayerControlLockService
2) 创建菜单 Root
- 新建 `InGamePauseMenuRoot`(初始 SetActive=false
- 用 Reach Button 创建三个按钮并摆成垂直布局
3) 新建控制器并拖引用
- 新建空物体 `InGamePauseMenuController`
- Add Component`InGamePauseMenuController`
- Inspector
- Menu Root:拖 `InGamePauseMenuRoot`
- Save And Exit Button:拖 `BtnSaveAndExit` 的 ButtonManager
- Settings Button:拖 `BtnSettings` 的 ButtonManager
- Return To Game Button:拖 `BtnReturnToGame` 的 ButtonManager
- Settings Controller:拖场景中的 `SettingsRoot` 上的 SettingsController(不拖也可自动 Find
- Title Scene Build Index:填 TitleScene 的 BuildIndex(默认 1
### 四、运行逻辑
- ESC
- 若面板栈为空:打开暂停菜单(并入栈)
- 若面板栈非空:只关闭栈顶面板(例如先关设置,再关暂停菜单)
- 保存并退出:
- 调用 `SaveManager.Instance.SaveGame()`(若存在)
- 关闭菜单并加载 TitleScene
- 设置:
- 调用 `settingsController.OpenAtIndex(0)` 打开设置面板
- 返回游戏:
- 关闭菜单并恢复输入