我用了好几个版本发现我的资源好像都无法被识别,最后发现有人说配置为 Bundle后再这个文件夹内会生成cc.assetbundle,但是我的不管是哪个版本的软件我都没见有生成过这个文件,文件夹选择配置为 Bundle后分配完优先级,为了怕资源被漏掉特地加上了包含所有文件夹内的文件,保存后还是没见有cc.assetbundle生成,其实有没有都能用的话也没事,但是现在就是用不了,我是个野孩子没老师教只能求大佬们照顾一下,我的代码内容部分:private async loadImages(): Promise {
const promises = this.TEST_RESOURCES.images.map((path, index) => {
return new Promise((resolve) => {
const bundleName = this.getBundleName(path);
const bundle = assetManager.getBundle(bundleName);
if (!bundle) {
if (bundleName === 'main') {
warn(`主资源包未加载,无法加载资源: ${path}`);
} else {
warn(`资源包${bundleName}未加载,跳过资源: ${path}`);
}
resolve();
return;
}
bundle.load(path, SpriteFrame, (err: Error | null, spriteFrame: SpriteFrame) => {
if (err) {
warn(`加载图片失败: ${path}`, err);
this.tryAlternativeLoad(bundle, path, index).finally(resolve);
} else if (index < this.displaySprites.length) {
this.displaySprites[index].spriteFrame = spriteFrame;
resolve();
} else {
resolve();
}
});
});
});
await Promise.all(promises);
}
private getBundleName(path: string): string {
if (path.indexOf(‘female_characters’) === 0) return ‘female-characters’;
if (path.indexOf(‘pve_mode’) === 0) return ‘pve-mode’;
if (path.indexOf(‘common_battle’) === 0) return ‘common-battle’;
return ‘main’;
}还有代码中的资源路径:private readonly TEST_RESOURCES = {
images: [
‘textures/bg_t’, // 修改为相对路径
‘female_characters/1_n/poses/1_n_stand’,
‘pve_mode/boss/boss_male_seyou’, // 相关路径
‘common_battle/items/icons/dingshen’
],
audio: ‘sounds/click’ // 修改为相对路径
};下面是报错的一部分: [PreviewInEditor] 加载图片失败: pve_mode/boss/boss_male_seyou Error: Bundle pve_mode doesn’t contain pve_mode/boss/boss_male_seyou
at parse (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:117036:25)
at Pipeline.sync (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115715:28)
at preprocess (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115993:53)
at Pipeline._flow (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115759:11)
at Pipeline.async (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115755:16)
at AssetManager.loadAny (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:109614:20)
at Bundle.load (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:112965:33)
at file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:102:24
at new Promise ()
at map (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:88:20)
at Array.map ()
at TestScene.loadImages (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:87:53)
at TestScene.loadAndDisplayResources (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:77:22)
at TestScene.start (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:32:24)
Error: [PreviewInEditor] 加载图片失败: pve_mode/boss/boss_male_seyou Error: Bundle pve_mode doesn’t contain pve_mode/boss/boss_male_seyou
at Pipeline._flow (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115759:11)
at Pipeline.async (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:115755:16)
at AssetManager.loadAny (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:109614:20)
at Bundle.load (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:112965:33)
at file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:102:24
at new Promise ()
at map (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:88:20)
at Array.map ()
at TestScene.loadImages (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:87:53)
at TestScene.loadAndDisplayResources (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:77:22)
at TestScene.start (file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:32:24)
at Logger._logHandler (K:\cocosbianjiqi\Creator\3.8.6\resources\app.asar\builtin\scene\dist\script\3d\manager\startup\log.ccc:1:487)
at Logger.record (K:\cocosbianjiqi\Creator\3.8.6\resources\app.asar\node_modules@base\electron-logger\lib\renderer.ccc:1:458)
at console. (K:\cocosbianjiqi\Creator\3.8.6\resources\app.asar\node_modules@base\electron-logger\lib\renderer.ccc:1:1260)
at console.warn (K:\cocosbianjiqi\Creator\3.8.6\resources\app.asar\node_modules@sentry\src\instrument\console.ts:40:20)
at warn (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:146866:12)
at file:///K:/386/525/temp/programming/packer-driver/targets/editor/chunks/d0/file:/K:/386/525/assets/testscene.ts:104:25
at eval (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:117467:9)
at eval (K:\cocosbianjiqi\Creator\3.8.6\resources\resources\3d\engine\bin.cache\dev\editor\bundled\index.js:151169:9)
at sentryWrapped (K:\cocosbianjiqi\Creator\3.8.6\resources\app.asar\node_modules\src\helpers.ts
17)
[PreviewInEditor] 加载图片失败: common_battle/items/icons/dingshen Error: Bundle common_battle doesn’t contain common_battle/items/icons/dingshen可能有些乱,非常抱歉QAQ