How to Build a Unity Game for the Web as WebGL

Building a Unity3D game for the web is simple! Once you build a game as WebGL, you can play it directly in your web browser.

In this article I'll also show you how to upload it to the web with ease.

1200px-WebGL_Logo.svg

A Fractal Example

For this example I'll use a 3D fractal from a Catlike Coding tutorial. You can download the unitypackage file from that tutorial and import it into Unity if you want to follow along.
Screen-Shot-2017-10-20-at-8.18.33-PM
First, open up the scene file and click "Play" to make sure the asset is correctly running.

Build your game for the web

File -> Build Settings
Screen-Shot-2017-10-20-at-8.23.21-PM

Select the WebGL platform and add any scenes needed for the game. Build & Run.

Screen_Shot_2017-10-20_at_8_24_38_PM-1
Optionally you can click the "Player Settings" button if you want to change options like the width & height of your Unity export. For this example I'll leave those settings alone.

Once you've clicked "Build & Run", give your build a name. I chose "CatlikeWebGLBuild".
Screen-Shot-2017-10-20-at-8.33.58-PM

Grab a cup of coffee.
Screen-Shot-2017-10-20-at-8.39.19-PM

Boom! Your Unity WebGL game is now running in the browser.
Screen-Shot-2017-10-20-at-8.40.58-PM

Upload your game to the web

Go to https://simmer.io/upload and sign up for a free account if you don't already have one.

Drag your "WebGLBuild" folder onto the drop area.d4e4qeqogxrz

Live Example

Here's an example of the completed Unity WebGL demo. Click the play button to see a live demo:

Want to see how we embedded the above example on this blog? Check out Part II: How to Embed your Game on any Website