微信小游戏使用云开发,下载prefab预制资源,下载后文件类型为.bin,无法加载为.prefab。
请问各位大神,如何处理?
下载:
wx.cloud.downloadFile({
fileID: xiazaiid, // 文件 ID
success: res => {
Global.yixiazaidizhi_prefab[xzprefab]=res.tempFilePath;
var zhongzhuanshuzi=Global.xiazaichenggonggeshu;
Global.xiazaichenggonggeshu=zhongzhuanshuzi+1;
console.log('prefab...res.tempFilePath='+Global.yixiazaidizhi_prefab[xzprefab]);
console.log('Global.xiazaichenggonggeshu...success...'+Global.xiazaichenggonggeshu);
},
fail: res => {
console.log(res+'...1');
},
})
加载:
for(var jzprefab in Global.yixiazaidizhi_prefab){
cc.resources.load(Global.yixiazaidizhi_prefab[jzprefab], cc.Prefab, null,function(err,prefab){
Global.prefab[this]=prefab;
console.log('this...'+this);
console.log('Global.prefab[this]...'+Global.prefab[this]);
}.bind(jzprefab));
};
临时地址:
http://tmp/TLt7DJvAVSwE650a227024fced75636ba2a68babf10d.bin
打印结果:
index.js:1 this…xueliangbianhua
Global.prefab[this]…undefined