Is there a way to explicitly trigger the engine initialization when loading WebGL/WebAssembly? IOW, let WASM compile smoothly but then wait until some event before starting the next step/initialization? I know Chrome is working towards wasm streaming compilation (i.e, compile as it is downloaded) so it would be nice to let the system do that behind-the-scenes and be prepared for the engine initialization at a specific time. Thanks for any info.
There is a mechanism for doing that. You need to set Module["noInitialRun"] = true; on the game instance. Then, to run, simply call Module['callMain'](); try the following: Code (csharp): <!DOCTYPE html> <html lang="en-us"> <head> ... <script> var gameInstance = UnityLoader.instantiate("gameContainer", "Build/test.json", {onProgress: UnityProgress, Module: { "noInitialRun": true, onRuntimeInitialized: function () { document.getElementById("callMainButton").innerHTML = "Run!"; }, }}); function callMain(){ gameInstance.Module['callMain'](); } </script> </head> <body> ... <button id="callMainButton" onclick="callMain()">Loading... please wait.</button> </body> </html>
Perfect! Not sure why I couldn't find that on the emscripten docs before: https://kripken.github.io/emscripten-site/docs/api_reference/module.html Thanks much, Marco!