How to Host Unity Games on the Web

Objective: deploy your build as a WebGL to run on the Web, and use the Servez web server tool for testing on your local machine.

Making a build for WebGL begins the same way as any other build in Unity. Go to File, Build Settings…, and select WebGL as your Platform. If this is your first build on WebGL, you will need to select the Switch Platform button on the bottom right.

Select WebGL and Switch Platform.

Unity will then recompile all of its scripts in preparation for a WebGL environment.

Color Space warning…

If not already done so, you will also need to resolve the Color Space setting by going into Player Settings…, and in the settings for WebGL, select Other Settings and change the Rendering / Color Space from Linear to Gamma. Close the Project Settings window and you’re good to go!

Changing your Color Space from Linear to Gamma.

To dig deeper into WebGL development, you can find more information from the Unity manual here.

Once ready to go, select Build, select a folder location in which to save, and Unity will then compile your project. You will then find the following three items in your destination folder:

Select the folder where you wish to save your WebGL build.

If you had a HTML server, you could then take these three files and save them to your server and play your game. Unfortunately, if all you have is your standalone platform, you will get the following error:

Error message… :(

Now, there are various ways to test your build prior uploading to a server. What I’m about to present is a fairly simple solution using a program called Servez.

Servez is a simple web server for local web development and it can be found here.

GitHub repository for Servez.
Servez GUI. Select the folder, Start and Launch Browser. Simple :)

Go ahead and download/install the required version for your machine. Upon execution, Servez will open the GUI shown to the left. Go ahead and select the folder location of your WebGL build, press Start, and Launch Browser to test your project.

Testing your project in WebGL.

There you have it. I hope you enjoyed this simple guide on WebGL builds, along with the solution demonstrated to test on your local machine using Servez. Thanks for reading! :)



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Michel Besnard

Michel Besnard

Military member with 35+ years of service, undertaking an apprenticeship with GameDevHQ with the objective of developing solid software engineering skills.