How to submit an Unity game in WebGL format to Itch.io

What is WebGL and why do I care?

If you landed on this post, most likely you already know what WebGL is: WebGL (Web Graphics Library) is a JavaScript API for rendering interactive 2D and 3D graphics within a web browser without the use of any additional plugin, or installing anything else.

As it is designed to be compatible with HTML5, works on a wide range of devices: Desktops, smartphones, tablets, … you name it.

Now, Unity games can be exported and run in WebGL, and by definition on a browser. This can be done by exporting the Unity project as a WebGL build, which can then be hosted on a web server and accessed via a web link.

Alright, that sounds good. How do I export my Unity game to WebGL?

To export an Unity game as a WebGL build, you can follow these steps:

  • Go to “File”, click on “Build Settings”
  • In the Build Settings window, select “WebGL” as the target platform
  • Click on “Switch Platform” to set WebGL as the active platform
  • Click on “Player Settings” to open the Player Settings window
  • In the Player Settings window, you can configure various settings such as the name of the game, the default screen resolution, and the logo that will be displayed on the loading screen
  • Click on “Add Open Scenes” to add the current scene to the build
  • Click on “Build” and choose a directory to save the build

Done! You have a WebGL build of your game now.

That sounds good, but where do I host my game so people can play it? How can I upload my game to internet?

I use Itch.io to share my games. Just after creating a new project in Itch.io, you only need to fill/enable 3 options to make this playable on browser:

Kind of project:Select HTML.
Upload Files:Be sure to upload a .zip file, if this is generated via Unity it will already have the needed index.html file to play on browser.
Enable option:“This will be played in the browser”.

That’s it!

Always test this built both locally and in Itch.io website, as with newer Unity versions (2020+) there may be some problems based on the engine compression.

It is worth noting that not all Unity features are fully supported in WebGL and you may encounter performance issues when running a game in the browser, be sure to test your games on different devices and browsers to ensure that they run smoothly.

The game is not loading on my computer, but loads in the browser:

You may see the game not loading locally, but actually loading through Itch.io browser. If you see the following error:

both async and sync fetching of the wasm failed

Here’s how to fix it:

  • Go to Unity > File > Build Settings > Player Settings > Compression.
  • Option 1) There, disable Compression, and enable Decompression Fallback.
  • Option 2) If the previous doesn’t work, select GZIP compression and enable Decompression Fallback.

Last update: 2023-01-15


Posted

in

, , , ,

by

Comments

Leave a Reply

%d bloggers like this: