On WebGL and Unity (and uploading games to the web)

Marcus Ansley
3 min readMay 6, 2021

--

Preamble

I have a bit of a love-hate relationship with WebGL. On the one hand, it’s allowed me to build out prototypes which are easily-shareable, work on a wide variety of platforms, and have essentially no installation process (namely, downloading and unzipping files). On the other hand, there are a variety of technical limitations and constraints (which Unity is perfectly open about), such as a lack of support for threading and anything beyond basic audio functionality.

But for me the biggest frustration I have with it is also part of it’s main appeal: people can play these on virtually any device. Including that ancient Android phone or iPhone, or perhaps that new phone with strange dimensions and a prominent notch, and testers often implicitly expect the same kind of performance from a WebGL game on their phone as they would a native app. But instead, the games really aren’t supported on mobile all that well (as Unity warns players by default when starting the application), and as a result insufficient memory can lead to choppy framerates and a slew of bugs which might not otherwise exist. So I suppose my problem is less with WebGL and more with people’s expectations. I’d say if you can direct people towards playing them on a desktop device, or at the very least make it clear that their experience on a mobile device probably won’t be ideal, then things might be alright.

Guide

But I’m digressing: in order to build and host some of your games and/or prototypes online you’ll first need to ensure the WebGL module is installed for the Unity version you’re using. You can do this from Unity Hub by clicking the ellipsis icon on your Unity version in the Installs tab.

Click ‘Add Modules’ and select ‘WebGL Build Support’, then hit ‘Done’ and set this to download and install.

Once this is finished, you should now be able to switch platforms for your project. You can do this from the Projects tab in the Unity launcher by selecting ‘Current platform’ under Target Platform for your project (and choosing WebGL) or from within the editor by going to Build Settings, clicking on the WebGL build platform, and selecting Switch Platform (nb. this could take awhile).

Once this is done, you can set up the build as you’d like from within the Player Settings window before selecting Build, choosing and/or creating a folder, and then leaving Unity to do its stuff. I do hope you aren’t in a rush with this, because in my experience WebGL builds take infamously long to build (although for me 30 minutes+ is pretty agonizing, at least when I need to get something out to test quickly).

When this is finished, you can zip up this folder, and upload it to itch.io if you choose. From the dropdown menu in the top right of the page you can choose to ‘Upload new project’, which should take you to a page where you can set up your game/upload to your liking. The main thing to adjust is to set ‘Kind of project’ to HTML rather than downloadable, then upload the zipped files. Once you’re ready, and have set the Visibility & access to Draft, Restricted, or Public, you can hit Save and View Page to give your game/prototype a play in browser. You should also be able to share this with others, although they may need a password if you chose Restricted (as I often do).

While there are ways of hosting WebGL games on your own websites using the index.html file in the build files, I’ve found itch.io to be incredibly quick, easy, and indie-friendly as an option 😉 (It does also make it quite easy for you to fully release your game to a wider audience should you choose!)

--

--

Marcus Ansley
Marcus Ansley

Written by Marcus Ansley

Game Developer | Game Design and Literature Graduate

No responses yet