搞了一个小时了,也不知道为啥



好了,不报错了但是这算不算是个坑,.得加上这个Prefab,但是这个又在ide里报错,强迫症,受不了
要不把你的 Prefab改成cc.Prefab
不能改,我改了后,跟没添加一样,报错
这是导致错误的源码,你可以参考看看。
engine\cocos2d\core\asset-manager\urlTransformer.js 的82-102行。2.4.6版本
case RequestType.PATH:
if (bundles.has(item.bundle)) {
var config = bundles.get(item.bundle)._config;
var info = config.getInfoWithPath(item.path, item.type);
if (info && info.redirect) {
if (!bundles.has(info.redirect)) throw new Error(`you need to load bundle ${info.redirect} first`);
config = bundles.get(info.redirect)._config;
info = config.getAssetInfo(info.uuid);
}
if (!info) {
out.recycle();
throw new Error(`Bundle ${item.bundle} doesn't contain ${item.path}`);
}
out.config = config;
out.uuid = info.uuid;
out.info = info;
}
out.ext = item.ext || '.json';
break;
因为它的执行流程是:
preprocess.js
的
transformPipeline.sync(subTask)
函数。
是sync。
但是你的start用的
async
所以你把start的async去掉再看看。
我没用过TS,所以是我猜的。你试试。
async start() {
await new Promise((res,rej) => {
cc.resources.load("tanchuang/gxshibai",Prefab,(err,prefab) => {
if(err) {
console.log("加载预制体错误",err);
rej(err);
}
var newNode:any = cc.instantiate(prefab);
cc.director.getScene().addChild(newNode);
res(undefined);
})
})
}
我菜的。。
1赞
解决了,原来是我的文件名称后面有个空格,在编辑器里看不出来,在电脑资源管理器里看到了,文件名结为有个空格
该主题在最后一个回复创建后14天后自动关闭。不再允许新的回复。
