36 lines
939 B
Markdown
36 lines
939 B
Markdown
|
|
# ResourceManager::LoadGroup
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
template<typename T>
|
|||
|
|
void LoadGroup(const Containers::Array<Containers::String>& paths,
|
|||
|
|
std::function<void(ResourceHandle<T>)> callback)
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
批量异步加载同类资源。为路径数组中的每个路径提交一个异步加载请求,所有加载完成时通过回调通知。
|
|||
|
|
|
|||
|
|
**参数:**
|
|||
|
|
- `paths` - 资源路径数组
|
|||
|
|
- `callback` - 每个资源加载完成时的回调
|
|||
|
|
|
|||
|
|
**返回:** 无
|
|||
|
|
|
|||
|
|
**复杂度:** O(k),k 为路径数量(每个加载为 O(n))
|
|||
|
|
|
|||
|
|
**示例:**
|
|||
|
|
|
|||
|
|
```cpp
|
|||
|
|
Containers::Array<Containers::String> texPaths = {
|
|||
|
|
"textures/a.png", "textures/b.png", "textures/c.png"
|
|||
|
|
};
|
|||
|
|
ResourceManager::Get().LoadGroup<Texture>(texPaths,
|
|||
|
|
[](ResourceHandle<Texture> tex) {
|
|||
|
|
if (tex.IsValid()) {
|
|||
|
|
printf("Loaded: %s\n", tex->GetPath().CStr());
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
```
|
|||
|
|
|
|||
|
|
## 相关文档
|
|||
|
|
|
|||
|
|
- [ResourceManager 总览](resourcemanager.md) - 返回类总览
|