Files
loneseDocument/Content/Blueprints/BP_Hud.md
meishibiezb 29a3f77908 init
2026-06-04 21:44:13 +08:00

48 lines
2.7 KiB
Markdown
Raw 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.
# BP_Hud
## 基本信息
- **类型**: Blueprint (HUD)
- **父类**: HUD
- **源文件**: /Game/Blueprints/BP_Hud.BP_Hud
- **模块**: Content
## 功能概述
BP_Hud 是项目的 HUD 蓝图,管理三个 UI 窗口的引用物品栏窗口InvView类型 WBP_InventoryView、库存窗口InventoryWindow和提示窗口HintWindow。作为 UI 系统的"根"容器,持有并显示各种 Widget。
## 设计用意
BP_Hud 将 UI 管理集中在 HUD 中,而不是分散在各个 Widget 或 Controller 中。它将物品视图、库存窗口和提示窗口都集中持有在一个地方,作为 UI 系统的入口点,方便其他系统通过 HUD 访问和操作 UI。
## 职责范围
BP_Hud 负责持有主要 UI 窗口引用并作为 UI 系统的入口点。具体的 UI 逻辑(物品列表渲染、窗口交互、提示显示)由各 Widget 自身负责BP_Hud 仅提供引用的集中管理。
## 项目内依赖
| 依赖项 | 关系 | 源文件 |
|--------|------|--------|
| WBP_InventoryView | 引用 (InvView) | /Game/Blueprints/UI/Item/WBP_InventoryView |
| WBP_Window | 引用 (InventoryWindow, HintWindow) | /Game/Blueprints/UI/WBP_Window |
## 对外接口
- **蓝图可编辑变量**(均为 Instance Editable
- `InvView` (WBP_InventoryView_C*) -- 物品栏视图 Widget 引用,类型为 WBP_InventoryView
- `InventoryWindow` (WBP_Window_C*) -- 库存窗口 Widget 引用,类型为 WBP_Window
- `HintWindow` (WBP_Window_C*) -- 提示窗口 Widget 引用,类型为 WBP_Window
- **继承自 AHUD 的标准接口**
- `DrawHUD()` -- HUD 绘制入口
- `ReceiveDrawHUD(SizeX, SizeY)` -- 蓝图可覆盖的 UI 绘制事件
- `GetOwningPlayerController()` -- 获取所属的 PlayerController
- HUD 生命周期事件BeginPlay、EndPlay 等)
- **EventGraph**:含 4 个事件和 39 个节点,负责 Widget 的创建和初始化逻辑
## 使用方法
- 在 BP_TestMode 中设置为 `HUDClass`,每次 PlayerController 初始化时自动创建
- 在蓝图 EventGraph 中创建和初始化三个 Widget`InvView`(物品栏)、`InventoryWindow`(库存窗口)、`HintWindow`(提示窗口)
- 三个 Widget 变量为 Instance Editable可在编辑器中替换为不同的 Widget 子类
- 其他系统通过 `PlayerController->GetHUD()` 获取 BP_Hud 实例,再通过变量访问各 Widget
- 作为 UI 系统的"根"容器,所有主要 UI 窗口的引用集中在此处管理
## 用例
- BP_TestMode 的 `HUDClass`,玩家进入关卡时生成
- `InvView` 变量引用 WBP_InventoryView物品系统通过此引用更新物品列表 UI
- `InventoryWindow` 变量引用 WBP_Window库存窗口的显示和隐藏通过此引用控制
- `HintWindow` 变量引用 WBP_Window提示信息的显示通过此引用控制