How to host Unity games on the Web

Jaime
3 min readMay 6, 2021

--

To be able to host Unity games on the web, you will need to change go to Build Settings in File->Build Settings… and select WebGL as the platform.

As you can see above, there’s incompatibilities with the Color Space. Particular if the Color Space is in Linear, you’ll need to set it back to Gamma. Click the Player Settings… and on the Other Settings section of the HTML5 tab, make this change.

You need to change the Color Space from Linear to Gamma in WebGL.

There’s also seems to be a bug when compression is enabled in Unity 2020. Under Publishing Settings, change Compression Format to Disabled and then you can close the Project Settings window. On the Build Settings window, click Switch Platform button again. If successful, both Build and Build And Run button should be enabled.

Let’s select Build, and create a folder called Web. This is where the web build of your game will be stored.

Select the created folder, specify a name for your game and click Save.

At this point, Unity is building the game and on my end it will store the web files in Web/2DSpaceShooter of my project folder.

Unity is building the game

Once the build has been completed, you may now upload 2DSpaceShooter folder in a web server. If you want to test this easily from your computer, you can install Python as you can invoke it as a simple web server. For MacOs, this is already bundled. Just go to the directory where the web files are created and run: python3 -m http.server

developer$ cd Web/2DSpaceShooter/(base) developer:2DSpaceShooter developer$ python3 -m http.server
Serving HTTP on :: port 8000 (http://[::]:8000/) ...

Next, open a web brower and go to http://l27.0.0.1:8000

And voila! Your game can now be played on the web.

--

--

Jaime
Jaime

No responses yet