Files
XCEngine/docs/api/resources/resource-dependency-graph/add-dependency.md

37 lines
1.0 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.
# 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
```