docs: update resources API docs
This commit is contained in:
51
docs/api/resources/resource-file-system/add-archive.md
Normal file
51
docs/api/resources/resource-file-system/add-archive.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# ResourceFileSystem::AddArchive
|
||||
|
||||
## 方法签名
|
||||
|
||||
```cpp
|
||||
bool AddArchive(const Containers::String& archivePath);
|
||||
```
|
||||
|
||||
## 所属类
|
||||
|
||||
`XCEngine::Resources::ResourceFileSystem`
|
||||
|
||||
## 描述
|
||||
|
||||
添加档案压缩包作为资源来源。档案文件(如 ZIP、Pak 等格式)会被注册为可搜索的资源位置。
|
||||
|
||||
此方法线程安全。
|
||||
|
||||
## 参数
|
||||
|
||||
| 参数名 | 类型 | 描述 |
|
||||
|--------|------|------|
|
||||
| `archivePath` | `const Containers::String&` | 档案压缩包的路径 |
|
||||
|
||||
## 返回值
|
||||
|
||||
- `bool` - 成功添加返回 `true`
|
||||
|
||||
## 示例
|
||||
|
||||
```cpp
|
||||
#include "Resources/ResourceFileSystem.h"
|
||||
|
||||
using namespace XCEngine::Resources;
|
||||
|
||||
ResourceFileSystem& fs = ResourceFileSystem::Get();
|
||||
fs.Initialize("C:/Game/Resources");
|
||||
|
||||
// 添加多个档案作为资源来源
|
||||
fs.AddArchive("C:/Game/Paks/Common.pak");
|
||||
fs.AddArchive("C:/Game/Paks/Textures.pak");
|
||||
fs.AddArchive("C:/Game/Paks/Audio.pak");
|
||||
|
||||
// 读取档案中的资源
|
||||
auto data = fs.ReadResource("textures/player/diffuse.png");
|
||||
```
|
||||
|
||||
## 注意事项
|
||||
|
||||
- 当前实现仅存储路径,实际档案加载功能待实现
|
||||
- 档案中的资源会通过 `FindInArchives` 被搜索
|
||||
Reference in New Issue
Block a user