docs: update resources API docs
This commit is contained in:
51
docs/api/resources/resource-file-system/add-directory.md
Normal file
51
docs/api/resources/resource-file-system/add-directory.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# ResourceFileSystem::AddDirectory
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
bool AddDirectory(const Containers::String& directoryPath);
|
||||
```
|
||||
|
||||
## 所属类
|
||||
|
||||
`XCEngine::Resources::ResourceFileSystem`
|
||||
|
||||
## 描述
|
||||
|
||||
添加文件系统目录作为资源来源。指定的目录会被注册为可搜索的资源位置。
|
||||
|
||||
此方法线程安全。
|
||||
|
||||
## 参数
|
||||
|
||||
| 参数名 | 类型 | 描述 |
|
||||
|--------|------|------|
|
||||
| `directoryPath` | `const Containers::String&` | 目录的路径 |
|
||||
|
||||
## 返回值
|
||||
|
||||
- `bool` - 成功添加返回 `true`
|
||||
|
||||
## 示例
|
||||
|
||||
```cpp
|
||||
#include "Resources/ResourceFileSystem.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
ResourceFileSystem& fs = ResourceFileSystem::Get();
|
||||
fs.Initialize("C:/Game/Resources");
|
||||
|
||||
// 添加多个目录作为资源来源
|
||||
fs.AddDirectory("C:/Game/Assets/Textures");
|
||||
fs.AddDirectory("C:/Game/Assets/Shaders");
|
||||
fs.AddDirectory("C:/Game/Assets/Models");
|
||||
|
||||
// 读取目录中的资源
|
||||
auto data = fs.ReadResource("textures/player/diffuse.png");
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 目录搜索优先级:根路径 > 先添加的目录
|
||||
- 路径末尾的斜杠会自动处理
|
||||
Reference in New Issue
Block a user