Files
loneseDocument/Content/Blueprints/WBP_ItemViewBox.md
meishibiezb a8bdf281ff update
2026-06-05 03:01:15 +08:00

61 lines
2.7 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.
# WBP_ItemViewBox
## 基本信息
- **类型**: WidgetBlueprint (UserWidget)
- **父类**: UserWidget
- **源文件**: /Game/Blueprints/UI/Item/WBP_ItemViewBox.WBP_ItemViewBox
- **模块**: Content/Blueprints/UI/Item
## 功能概述
物品视图盒子 Widget用于在 UI 中展示单个物品的图标/外观。持有 ItemViewItemView 类型变量GetBrush 函数返回 SlateBrush 用于渲染。4 个事件, 11 个节点。
## 设计用意
物品 UI 系统中的单个物品展示组件,通过 BP_ItemViewDataView 获取数据,通过 WBP_InventoryView 与库存视图联动。
## 职责范围
- 渲染单个物品的图标
- 通过 GetBrush 提供当前物品的 SlateBrush
## 项目内依赖
| 依赖项 | 关系 | 源文件 |
|--------|------|--------|
| WBP_InventoryView | 引用 | /Game/Blueprints/UI/Item/WBP_InventoryView |
| BP_InventoryComp | 引用 | /Game/Blueprints/Playground/BP_InventoryComp |
| BP_ItemViewDataView | 引用 | /Game/Blueprints/UI/Item/BP_ItemViewDataView |
## 外部视角
WBP_ItemViewBox 是 UserWidget 的子类,从外部调用者视角:
**公开属性(蓝图可读写)**
- `ItemView`FItemView 结构体)— 当前显示的物品视图数据
**自定义函数**
- `GetBrush()``FSlateBrush` — 返回当前物品的 SlateBrush用于渲染物品图标
**外部交互方式**
- 由 WBP_InventoryView 创建,作为物品列表中的单个条目
- 通过 BP_ItemViewDataView 获取物品数据
- 通过 BP_InventoryComp 获取物品视图数据
**EventGraph 事件**
| 事件 | 类型 | 触发时机 | 行为 |
|------|------|----------|------|
| `事件预构造` | 原生覆盖 (PreConstruct) | Widget 创建时 | 预留(当前无连线逻辑) |
| `事件构造` | 原生覆盖 (Construct) | Widget 创建完成后 | 预留(当前无连线逻辑) |
| `事件Tick` | 原生覆盖 | 每帧 | 预留(当前无连线逻辑) |
| `事件列表项目对象集上` | 接口事件 (UserListEntry) | 列表项数据绑定时 | 接收 BP_ItemViewDataView 对象 → Cast → 读取 Index → 从 WBP_InventoryView 的 Comp 获取 ItemViews → GET 对应索引 → 设置 ItemView |
## 使用方法
WBP_ItemViewBox 在项目中的典型调用流程:
- **列表项渲染流程** — WBP_InventoryView.UpdateListItems → 创建 WBP_ItemViewBox 作为列表子项 → 触发 OnListItemObjectSet → 从 BP_ItemViewDataView 读取 Index → 从 InventoryComp.GetItemViews 获取对应索引的 FItemView → 存入 ItemView 变量 → GetBrush 返回 SlateBrush 渲染图标
## 用例
| 引用方 | 路径 | 用途 |
|--------|------|------|
| WBP_InventoryView | `/Game/Blueprints/UI/Item/WBP_InventoryView` | 作为列表项模板,渲染单个物品图标 |