Skip to main content

๐Ÿ“ฆ Lesson 8.2: Building Your Game (WebGL & Desktop)

Everything so far runs inside the Editor. A build turns your project into a standalone game โ€” a Windows/Mac app, or a WebGL version that runs in a browser. This is how you finally share what you made.

๐ŸŽฏ Learning Objectives

  • Open Build Profiles (formerly Build Settings) and add your scene
  • Make a Windows/Mac desktop build
  • Make a WebGL build for the browser
  • Know why a WebGL build must be served, not double-clicked

Estimated Time: 35 minutes

In This Lesson

What "Building" Means

A build packages your scenes, assets, and code into a program that runs on its own โ€” no Unity Editor required. You choose a platform (Windows, Mac, WebGL, Androidโ€ฆ) and Unity produces the files for it.

graph LR A[Your project
in the Editor] --> B[Choose platform] --> C[Build] --> D[Standalone game
.exe / .app / web page]
๐Ÿ’ก WebGL is the easiest to share โ€” it runs in any modern browser, so anyone can play via a link. That's why we installed WebGL Build Support back in Lesson 1.2.

Build Profiles

Open File โ–ธ Build Profiles (in older versions this was called Build Settings). Here you pick a platform and manage which scenes go in the build:

The Build Profiles window A recreation of Unity's Build Profiles window: a platform list (Windows, Mac, WebGL highlighted, Android, iOS), a Scene List showing MyGame, and Switch Platform and Build buttons. Build Profiles Platforms ๐Ÿ–ฅ Windows ๐ŸŽ macOS ๐ŸŒ Web (WebGL) ๐Ÿค– Android iOS Scene List Scenes/MyGame 0 Add Open Scenes โ–ธ includes the current scene Switch Platform Build
Figure 1: Build Profiles (recreated), with WebGL selected. Add your scene to the Scene List, then Build.

โš ๏ธ Add your scene first

If the Scene List is empty, click Add Open Scenes โ€” otherwise Unity builds an empty game. Your gameplay scene must be in the list (and usually first).

A Desktop Build (Windows/Mac)

  1. Select Windows (or macOS) in the platform list; Switch Platform if it isn't active.
  2. Click Build, choose an empty folder, and wait.
  3. Unity produces an .exe (plus a data folder) on Windows, or an .app on Mac. Double-click to play!

โœ… Pro Tip

Always build into a fresh, empty folder (e.g. Builds/Windows). Builds contain many files; keeping each in its own folder avoids a mess.

A WebGL Build (Browser)

  1. Select Web (WebGL) and Switch Platform (this can take a while the first time).
  2. Click Build and choose an empty folder. WebGL builds take longer โ€” be patient.
  3. Unity outputs an index.html and a Build folder โ€” a small website that is your game.

โš ๏ธ Don't just double-click index.html

Opening the WebGL index.html directly from your file system usually shows errors โ€” browsers block it for security. You must serve it over HTTP. Easiest options: use Build And Run (Unity serves it for you), or upload the folder to a host like itch.io or Netlify.

๐Ÿ’ก Sharing online: itch.io is the friendliest place to publish a WebGL game for free โ€” zip the build folder, upload, and you have a shareable link in minutes.

Hands-on Exercise

๐Ÿ‹๏ธ Exercise: Ship it

  1. Open Build Profiles and Add Open Scenes so your game scene is listed.
  2. Make a Windows/Mac build into an empty folder and run the resulting app.
  3. Switch to WebGL and use Build And Run to play it in your browser.
  4. Celebrate โ€” that's a real, standalone game you made!
๐Ÿ’ก WebGL build shows a blank page or errors

You likely opened index.html directly. Use Build And Run, or serve the folder over HTTP. Also confirm your scene was added to the Scene List.

๐ŸŽฏ Quick Quiz

Question 1: Your build runs but is empty / black. What's the most common cause?

Question 2: Why can't you just double-click a WebGL index.html?

Summary

๐ŸŽ‰ Key Takeaways

  • A build packages your game to run without the Editor.
  • Use File โ–ธ Build Profiles; Add Open Scenes so your scene is included.
  • Desktop builds produce an .exe/.app; WebGL produces a small website.
  • WebGL must be served over HTTP โ€” use Build And Run or a host like itch.io.

๐Ÿš€ What's Next?

You've built and shipped a game โ€” a huge milestone. In the final lesson, Lesson 8.3, we look at where to take your new skills next.

๐ŸŽ‰ You shipped a game!