Embedding Unity WebGL directly in your LDJam game page

I don't know how long it's been a feature, but it looks like you can now embed WebGL games directly in the LDJam page instead of just hosting it on something like itch.io. If you happen to use Unity and WebGL, here's how you do it:

  • File > Build Setting... > Player Settings...
  • Resolution and Presentation > Resolution > Default Canvas Width = 948
  • Resolution and Presentation > Resolution > Default Canvas Height = 489
  • Publishing Settings > Data Caching = false
  • Publishing Settings > Compression Format = Disabled
  • Create an archive of your WebGL build by selecting everything in it (Build, index.html, StreamingAssets, and TemplateData) and compressing that (ie., don't just compress the folder that contains these things because "index.html" needs to be at the top-level of the archive).
  • Go to the "Embed HTML5" of your game page and hit "Upload .zip file" to upload that archive.
  • Save, wait a few minutes for it to go live, and play the game directly on your game page!

The resolution comes from the fact that the LDJam page allocates a 948x533 canvas for the WebGL. If you use the default WebGL template in Unity, there's a 44 pixel height bar at the bottom for the logos and the full-screen button so that gives us 533 - 44 = 489 height for the game itself.

The Data Caching disabling is recommended by the LDJam Embedding Guide. They also recommend setting the compression to Brotli, but I've seen my game hang while trying to load and this YouTube video recommended disabling compression to fix that.

To see an example of this working, check out my game.