Files
XCSDD/docs/api/resources/resourcemanager/loadasync.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

1.2 KiB
Raw Blame History

ResourceManager::LoadAsync

void LoadAsync(const Containers::String& path, ResourceType type,
               std::function<void(LoadResult)> callback)
void LoadAsync(const Containers::String& path, ResourceType type,
               ImportSettings* settings, std::function<void(LoadResult)> callback)

异步加载资源。将加载请求提交到 AsyncLoader,在后台工作线程执行加载,完成后在主线程通过回调通知。

参数:

  • path - 资源路径
  • type - 资源类型
  • settings - 导入设置(可为 nullptr
  • callback - 加载完成回调

返回:

复杂度: 提交 O(1),实际加载 O(n)

示例:

ResourceManager::Get().LoadAsync("textures/terrain.png", ResourceType::Texture,
    [](LoadResult result) {
        if (result.success) {
            ResourceHandle<Texture> tex(result.resource);
            printf("Loaded: %s\n", tex->GetPath().CStr());
        }
    });

ResourceManager::Get().LoadAsync("models/player.fbx", ResourceType::Mesh,
    nullptr,
    [](LoadResult result) {
        if (result.success) {
            ResourceHandle<Mesh> mesh(result.resource);
        }
    });

相关文档