【bundle】关于Bundle热加载,脚本更新的问题

你试试上面的回复。应该是可以的。

原生端,我使用插件在构建后注入代码已经把download的脚本加载缓存干掉了,但是还是进入不到setup里面

image 最好看看构建目录有没有注入成功

我看了的,注入成功了,构建后这一行已经被我删掉了

并且system.bundle.js里面的register代码也走到了,就是没走到setup里面去

我这边试了也是如此,download那边也注入成功了,但是就是不走setup的代码。我估计是热更重新解析index.js的时候因为相同的类已经被解析过,有缓存,所以就不再解析了。

不知道加载bundle的时候通过哪个流程调到setup的,原生端不知道怎么调试

@huanxinyin 如何实现原生端不重启游戏让热更后的代码生效呀?

3.x用SystemJS这个加载js 要修改一下

在window7是了一下是可以的。脚本可以重新加载了。需要魔改

14:48:16 [DEBUG]: D/ JS: [WARN]: Failed to set shading scale, pipelineSceneData is invalid.
14:48:16 [DEBUG]: EGL context bounded to thread ed4d41b27595a77
14:48:16 [INFO]: Device thread detached.
14:48:16 [DEBUG]: D/ JS: downloadBundle internal
14:48:16 [DEBUG]: D/ JS: Cocos Creator v3.6.1
14:48:16 [DEBUG]: D/ JS: downloadBundle main
14:48:16 [INFO]: Shader ‘util/splash-screen|splash-screen-vs:vert|splash-screen-fs:frag’ compilation succeeded.
14:48:20 [DEBUG]: D/ JS: Success to load scene: db://assets/scene-2d.scene
14:48:20 [INFO]: Shader ‘builtin-sprite|sprite-vs:vert|sprite-fs:frag|CC_USE_EMBEDDED_ALPHA0|USE_TEXTURE1|IS_GRAY0’ compilation succeeded.
14:48:20 [INFO]: Shader ‘util/profiler|profiler-vs:vert|profiler-fs:frag’ compilation succeeded.
14:48:22 [DEBUG]: D/ JS: bundle
14:48:22 [DEBUG]: D/ JS: 加载bundle
14:48:22 [DEBUG]: D/ JS: downloadBundle bundle_01
14:48:22 [DEBUG]: D/ JS: bundle_game_1脚本
14:48:22 [DEBUG]: D/ JS: bundle_game_1 2脚本
14:48:22 [DEBUG]: D/ JS: bundle_game_2脚本
14:48:22 [DEBUG]: D/ JS: bundle_01脚本
线程 0x2880 已退出,返回值为 0 (0x0)。
14:48:23 [DEBUG]: D/ JS: bundle
14:48:23 [DEBUG]: D/ JS: 移除bundle
14:48:25 [DEBUG]: D/ JS: bundle
14:48:25 [DEBUG]: D/ JS: 加载bundle
14:48:25 [DEBUG]: D/ JS: downloadBundle bundle_01
14:48:25 [DEBUG]: D/ JS: bundle_game_1脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “60a25hgAXhCToShSex+/DtA”.
14:48:25 [DEBUG]: D/ JS: bundle_game_1 2脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “6aafcsOxEBCO4dmDo/bwnm/”.
14:48:25 [DEBUG]: D/ JS: bundle_game_2脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “3b44auPptdF15ef2vvdHW1L”.
14:48:25 [DEBUG]: D/ JS: bundle_01脚本
14:48:25 [DEBUG]: D/ JS: [ERROR]: A Class already exists with the same cid : “41285oJOYFPTrUxRpiEPEFX”.
14:48:25 [DEBUG]: D/ JS: bundle
14:48:25 [DEBUG]: D/ JS: 移除bundle

我也找到了,就是有点烦,需要先移除SystemJS[REGISTRY]里面的缓存,然后再修改instantiated.js里面setup,这就有点烦了

这个是构建之后的文件吧,要改他引擎构建前的,我回头试下

可以.关注了.

大佬有联系方式吗?请教下


image



这样卸载就可以了,版本3.6.1

6赞

不错不错,借鉴下

已经是精髓代码了





我不想动引擎,通过插件hack构建后的代码实现了

这个tsFileNames.json文件是自己生成写进去的吗?引擎这边没有找到这个文件。

一看就是自己写的啦。