Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix: execute user scripts before scene loading in WeChat build

esengine532d90f55b08
diff --git a/editor/src/builder/WeChatBuilder.ts b/editor/src/builder/WeChatBuilder.ts
index 35ada528f..97827677f 100644
--- a/editor/src/builder/WeChatBuilder.ts
+++ b/editor/src/builder/WeChatBuilder.ts
@@ -335,6 +335,10 @@ function applyTextureMetadata(module, sceneData, textureCache) {
}
});
+ ${userCode}
+
+ SDK.flushPendingSystems(app);
+
${firstSceneName ? `
try {
var sceneJson = wx.getFileSystemManager().readFileSync('scenes/${firstSceneName}.json', 'utf-8');
@@ -351,10 +355,6 @@ function applyTextureMetadata(module, sceneData, textureCache) {
console.error('[ESEngine] Failed to load scene:', err);
}
` : ''}
-
- ${userCode}
-
- SDK.flushPendingSystems(app);
app.run();
})();
`;