-
Creator 版本: 3.8.5
-
目标平台:微信小游戏
-
重现方式:
-
首个报错:
-
之前哪个版本是正常的:
-
手机型号:
-
手机浏览器:
-
编辑器操作系统:
-
重现概率:
之前没做小游戏分包,从cocos creator构建微信小游戏后,可以正常运行。但发现包体很大,非常接近4096KB,所以在研究了cocos和微信开发文档中关于分包的介绍后,决定进行小游戏分包。
我的分包思路是,除了游戏首场景所需的资源作为主包外,其余的场景和依赖的资源分类进行分包,设置为Asset Bundle。于是,我在cocos creator中设置了3个Asset Bundle,把首场景以外的所有资源分类放进了这三个Asset Bundle中,每个Asset Bundle的目标平台选择微信小游戏,压缩方式为:小游戏分包。在配置这三个Asset Bundle过程中,重新组织了asset目录下的目录结构,这导致资源的路径都被打乱了,我仔细检查了每个场景里的每个节点挂载的组件以及依赖的脚本和资源,对出问题的地方都重新修复了,然后在cocos creator中可以正常运行了,但是构建到微信小游戏后,每次运行微信开发者工具,首场景都是黑屏,然后报出5个错误。分别是:
错误1:
debug.ts:92 Can not find class ‘51907lvFf9N8pbbW9DbTcBm’(env: Windows,mg,1.06.2412050; lib: 3.7.11)
error @ debug.ts:92
errorID @ debug.ts:291
reportMissingClass @ report-missing-class.ts:37
getMissingClass @ deserialize.ts:797
proxy @ deserialize.ts:810
deserializeCCObject @ deserialize.ts:608
parseClass @ deserialize.ts:675
(anonymous) @ deserialize.ts:663
deserializeCCObject @ deserialize.ts:627
parseInstances @ deserialize.ts:751
deserialize @ deserialize.ts:966
deserializeAsset @ deserialize.ts:63
parseImport @ parser.ts:185
parse @ parser.ts:289
parse @ load.ts:164
_flow @ pipeline.ts:261
(anonymous) @ pipeline.ts:271
(anonymous) @ load.ts:116
(anonymous) @ pack-manager.ts:277
unpackJson @ pack-manager.ts:124
unpack @ pack-manager.ts:196
(anonymous) @ pack-manager.ts:258
finale @ downloader.ts:483
(anonymous) @ utilities.ts:84
done @ downloader.ts:462
(anonymous) @ web-adapter.js? [sm]:4581
success @ web-adapter.js? [sm]:4544
错误2:
TypeError: Cannot set property ‘x’ of undefined
at System.register.execute.setterMap (builtin-value-type.ts:51)
at deserializeBuiltinValueTypeInto (builtin-value-type.ts:125)
at deserializeCCObject (deserialize.ts:627)
at parseClass (deserialize.ts:675)
at deserialize.ts:663
at deserializeCCObject (deserialize.ts:627)
at parseInstances (deserialize.ts:751)
at deserialize (deserialize.ts:966)
at deserializeAsset (deserialize.ts:63)
at parseImport (parser.ts:185)(env: Windows,mg,1.06.2412050; lib: 3.7.11)
错误3:
debug.ts:92 Cannot set property ‘x’ of undefined TypeError: Cannot set property ‘x’ of undefined
at System.register.execute.setterMap (http://127.0.0.1:12057/game/cocos-js/cc.js:24813:15)
at deserializeBuiltinValueTypeInto (http://127.0.0.1:12057/game/cocos-js/cc.js:24843:11)
at deserializeCCObject (http://127.0.0.1:12057/game/cocos-js/cc.js:24949:11)
at parseClass (http://127.0.0.1:12057/game/cocos-js/cc.js:24985:22)
at http://127.0.0.1:12057/game/cocos-js/cc.js:24975:13
at deserializeCCObject (http://127.0.0.1:12057/game/cocos-js/cc.js:24949:11)
at parseInstances (http://127.0.0.1:12057/game/cocos-js/cc.js:25048:33)
at deserialize (http://127.0.0.1:12057/game/cocos-js/cc.js:25194:27)
at deserializeAsset (http://127.0.0.1:12057/game/cocos-js/cc.js:25268:19)
at parseImport (http://127.0.0.1:12057/game/cocos-js/cc.js:31349:22)(env: Windows,mg,1.06.2412050; lib: 3.7.11)
错误4:
debug.ts:92 Cannot set property ‘x’ of undefined TypeError: Cannot set property ‘x’ of undefined
at System.register.execute.setterMap (http://127.0.0.1:12057/game/cocos-js/cc.js:24813:15)
at deserializeBuiltinValueTypeInto (http://127.0.0.1:12057/game/cocos-js/cc.js:24843:11)
at deserializeCCObject (http://127.0.0.1:12057/game/cocos-js/cc.js:24949:11)
at parseClass (http://127.0.0.1:12057/game/cocos-js/cc.js:24985:22)
at http://127.0.0.1:12057/game/cocos-js/cc.js:24975:13
at deserializeCCObject (http://127.0.0.1:12057/game/cocos-js/cc.js:24949:11)
at parseInstances (http://127.0.0.1:12057/game/cocos-js/cc.js:25048:33)
at deserialize (http://127.0.0.1:12057/game/cocos-js/cc.js:25194:27)
at deserializeAsset (http://127.0.0.1:12057/game/cocos-js/cc.js:25268:19)
at parseImport (http://127.0.0.1:12057/game/cocos-js/cc.js:31349:22)(env: Windows,mg,1.06.2412050; lib: 3.7.11)
错误5:
TypeError: Cannot set property ‘x’ of undefined
at System.register.execute.setterMap (builtin-value-type.ts:51)
at deserializeBuiltinValueTypeInto (builtin-value-type.ts:125)
at deserializeCCObject (deserialize.ts:627)
at parseClass (deserialize.ts:675)
at deserialize.ts:663
at deserializeCCObject (deserialize.ts:627)
at parseInstances (deserialize.ts:751)
at deserialize (deserialize.ts:966)
at deserializeAsset (deserialize.ts:63)
at parseImport (parser.ts:185)(env: Windows,mg,1.06.2412050; lib: 3.7.11)
很奇怪的是,最后log还打印了一句:Success to load scene: db://assets/Scenes/Scene0_Home.scene
另外,还有个很大的疑惑:我查看了构建目录里的subpackages文件夹,它里面除了我构建的3个Asset Bundle外,总是会包含internal和main两个目录,其中main目录里有我首场景的资源。 按照微信文档介绍,按道理只有我那三个Asset Bundle会放进subpackages目录里,其余的都会打包进主包,可是为什么cocos creator构建后,每次我的主包资源都会被放进subpackages目录的main目录里面,我也不知道是不是因为这个原因导致的错误。
求大神不吝赐教,着急!!!