Load assets with something different than its UUID

So far I’m unable to load any asset with assetManager.loadAny using something different from the UUID

an example:

I copy the URL and then

[Scene] download failed: db://assets/LDtk/SunnyLand_by_Ansimuz-extended?_t=1682850608528, status: 0(error)

I can’t use dir, path, and UUID doesn’t work for folders :sob:

AssetManager is meant for runtime usage, what you are trying to do is loading asset from editor path, which is not available for runtime APIs.

Either you can use loadDir if your path is a bundle, use its runtime path LDtk/SunnyLand_by_Ansimuz-extended
https://docs.cocos.com/creator/manual/en/asset/asset-manager.html#load-resources

Or you can use Editor.Message.request to send message to AssetDB, like the following

const result = await Editor.Message.request(‘asset-db’, ‘query-asset-info’,  “db://assets/LDtk/SunnyLand_by_Ansimuz-extended”);

there are two messages could be useful

    'query-asset-info': {
        params: [
            string, // uuid | url | path
        ],
        result: AssetInfo | null,
    },
    'query-asset-meta': {
        params: [
            string,
        ],
        result: IAssetMeta | null,
    },

The corresponding result are

export interface AssetInfo {
    // Asset name
    name: string;
    // Asset display name
    displayName: string;
    source: string;
    path: string;
    url: string;
    // Absolute path
    file: string;
    uuid: string;
    importer: string;
    type: string;
    isDirectory: boolean;
    library: { [key: string]: string };
    subAssets: { [key: string]: AssetInfo };
    visible: boolean;
    readonly: boolean;
    instantiation?: string;
    redirect?: IRedirectInfo;
    extends?: string[];
    imported: boolean;
    invalid: boolean;
}

export interface IAssetMeta {
    ver: string;
    importer: string;
    imported: boolean;
    uuid: string;
    files: string[];
    subMetas: {
        [index: string]: IAssetMeta;
    };
    userData: {
        [index: string]: any;
    };
    displayName: string;
    id: string;
    name: string;
}

I guess your are working on a plugin, it’s probably useful to give you more information on editor side APIs

1 Like

Thank you @pandamicro for this and the other answer. Your help is very much appreciated. :star_struck: