37 lines
1.0 KiB
Markdown
37 lines
1.0 KiB
Markdown
# AddDependency
|
||
|
||
添加资源之间的依赖关系。
|
||
|
||
## 方法签名
|
||
|
||
```cpp
|
||
void AddDependency(ResourceGUID owner, ResourceGUID dependency);
|
||
```
|
||
|
||
## 详细描述
|
||
|
||
在两个已存在的节点之间建立依赖关系。`owner` 节点依赖于 `dependency` 节点,即 `dependency` 会被 `owner` 使用。该方法会同时更新两个节点的关联数组:
|
||
- 将 `dependency` 添加到 `owner` 的 `dependencies` 列表
|
||
- 将 `owner` 添加到 `dependency` 的 `dependents` 列表
|
||
|
||
如果任一节点不存在或依赖关系已存在,则不做任何操作。
|
||
|
||
## 参数
|
||
|
||
| 参数 | 类型 | 描述 |
|
||
|------|------|------|
|
||
| `owner` | `ResourceGUID` | 依赖方(被依赖项的使用者)的全局唯一标识符 |
|
||
| `dependency` | `ResourceGUID` | 被依赖项(owner 所依赖的资源)的全局唯一标识符 |
|
||
|
||
## 返回值
|
||
|
||
无
|
||
|
||
## 示例
|
||
|
||
```cpp
|
||
graph.AddNode("material"_guid, ResourceType::Material);
|
||
graph.AddNode("texture"_guid, ResourceType::Texture);
|
||
graph.AddDependency("material"_guid, "texture"_guid); // material 依赖 texture
|
||
```
|