๐ฆ 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.
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:
โ ๏ธ 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)
- Select Windows (or macOS) in the platform list; Switch Platform if it isn't active.
- Click Build, choose an empty folder, and wait.
- Unity produces an
.exe(plus a data folder) on Windows, or an.appon 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)
- Select Web (WebGL) and Switch Platform (this can take a while the first time).
- Click Build and choose an empty folder. WebGL builds take longer โ be patient.
- Unity outputs an
index.htmland aBuildfolder โ 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
- Open Build Profiles and Add Open Scenes so your game scene is listed.
- Make a Windows/Mac build into an empty folder and run the resulting app.
- Switch to WebGL and use Build And Run to play it in your browser.
- 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.