Files
XCEngine/docs/api/resources/asyncloader/submit.md

37 lines
933 B
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.
# AsyncLoader::Submit
```cpp
void Submit(const Containers::String& path, ResourceType type,
std::function<void(LoadResult)> callback)
void Submit(const Containers::String& path, ResourceType type, ImportSettings* settings,
std::function<void(LoadResult)> callback)
```
提交异步加载请求。将请求加入待处理队列,由工作线程在后台执行加载。
**参数:**
- `path` - 资源路径
- `type` - 资源类型
- `settings` - 导入设置(可为 nullptr
- `callback` - 加载完成回调
**返回:**
**复杂度:** O(1)
**示例:**
```cpp
AsyncLoader::Get().Submit("textures/player.png", ResourceType::Texture,
[](LoadResult result) {
if (result.success) {
ResourceHandle<Texture> tex(result.resource);
}
});
```
## 相关文档
- [AsyncLoader 总览](asyncloader.md) - 返回类总览
- [Cancel](cancel.md) - 取消指定请求