On Game Loaded Callback

Hi Guys,

I’m trying to make the game in a responsive webpage (bootstrap). To do this I need to change the size of the canvas that’s loaded at runtime of the webpage. In short when the window’s loaded the canvas doesn’t exist yet, so I cannot add any formatting classes to it.

Is there a callback from a Unity WebGL project that says the game’s loaded?

Thanks!

・Before Unity5.6
You can add callback to Module in index.html
e.g. preInit or preRun
http://kripken.github.io/emscripten-site/docs/api_reference/module.html?highlight=module#Module.preRun

・After Unity5.6

var gameInstance = UnityLoader.instantiate("gameContainer", "Build/your-build.json", {onProgress: UnityProgress, Module: {
  onRuntimeInitialized: function () {
    UnityProgress(gameInstance, "complete");
    // do something else
  },
}});
1 Like