Chapter 2

Installing Unity & Project Setup

Download Unity Hub, install the right Unity version, set up your code editor, and create the project that will become our infinite runner.

Step 1: Download and Install Unity Hub

Unity Hub is a small application that manages your Unity installations and projects. Think of it as a launcher — you don't open Unity directly; you open Unity Hub, and it opens the correct Unity version for your project. This is important because you might eventually have multiple Unity versions installed for different projects.

  1. Open your web browser and go to https://unity.com/download.
  2. Click the "Download Unity Hub" button. The website will automatically detect your operating system (Windows, macOS, or Linux) and give you the correct installer.
  3. Run the downloaded installer:
    • Windows: Double-click the .exe file. Click "I Agree" on the license agreement, then "Install." It will install to C:\Program Files\Unity Hub by default.
    • macOS: Open the .dmg file and drag Unity Hub to your Applications folder.
    • Linux: Follow the AppImage or .deb instructions on the download page.
  4. Launch Unity Hub once the installation is complete.
  5. You'll be asked to sign in or create a Unity account. This is required (even for the free tier). Click "Create account" if you don't have one, or sign in with your existing credentials.
  6. After signing in, Unity Hub will ask you to activate a license. Choose "Get a free personal license." The Personal license is completely free and lets you use Unity with no restrictions as long as your revenue or funding is under $100K/year. For learning, this is exactly what you need.
💡 What Is Unity Hub, Really?

Unity Hub does three things: (1) it lets you install and manage multiple Unity editor versions side by side, (2) it stores your list of projects so you can open any of them with one click, and (3) it handles license activation. You'll always start here when working with Unity. If you ever can't find your project, open Unity Hub and it will be listed under the "Projects" tab.

Step 2: Install the Right Unity Version

Unity releases new versions frequently. There are three types of releases:

For this course, we recommend Unity 6 LTS (also known as Unity 6000.0 LTS). If that's not available yet when you're reading this, use Unity 2022 LTS instead. Both will work perfectly with everything in this tutorial.

  1. In Unity Hub, click the "Installs" tab in the left sidebar.
  2. Click the "Install Editor" button in the top-right corner.
  3. You'll see a list of available Unity versions. Look for the one labeled "LTS" with a green badge. This is the version you want. Click "Install" next to it.
  4. A dialog will ask which modules to install alongside the editor. Modules add support for building to specific platforms. For now, select:
    • Microsoft Visual Studio Community (Windows only) — This is our code editor. If you already have Visual Studio or prefer VS Code, you can skip this.
    • WebGL Build Support — Optional but useful if you want to publish your game to the web later.
    • Android Build Support — Optional, only if you want to build for Android phones.
    • iOS Build Support — Optional, only available on macOS, for building iPhone/iPad games.
  5. Click "Install" and wait. This download is large (several gigabytes). It may take 15–60 minutes depending on your internet speed. Go get a coffee.
⚠️ Don't Skip Visual Studio (Windows Users)

If you're on Windows and don't already have a C# code editor, make sure to install Visual Studio Community when prompted. Unity and Visual Studio are tightly integrated — double-clicking a script in Unity will open it directly in Visual Studio at the right line. You can use VS Code instead (instructions below), but Visual Studio provides the smoothest experience for beginners on Windows.

Step 3: Set Up Your Code Editor

You'll write all your C# code in a code editor, not inside Unity itself. Unity has a tiny built-in text area, but it's not meant for real development. You need a proper editor with syntax highlighting, autocompletion, and error detection.

Option A: Visual Studio (Recommended for Windows)

If you installed Visual Studio Community through Unity Hub in the previous step, you're already set. Visual Studio will be configured automatically to work with Unity. You can verify this by going to Edit → Preferences → External Tools in Unity and checking that "External Script Editor" is set to Visual Studio.

Option B: Visual Studio Code (All Platforms)

VS Code is a lightweight, free code editor by Microsoft that works on Windows, macOS, and Linux. If you prefer it over Visual Studio (or you're on Mac/Linux), follow these steps:

  1. Download VS Code from https://code.visualstudio.com and install it.
  2. Open VS Code and install the C# extension:
    • Click the Extensions icon in the left sidebar (it looks like four squares).
    • Search for "C#" and install the one by Microsoft (called "C# Dev Kit").
  3. Also install the "Unity" extension by Microsoft for better Unity integration.
  4. Back in Unity, go to Edit → Preferences → External Tools and set "External Script Editor" to Visual Studio Code.
✅ Which Editor Should You Choose?

Windows users: Start with Visual Studio Community. It has the best out-of-the-box Unity support, including debugging, IntelliSense (code autocompletion), and integrated help. Mac/Linux users: Use VS Code with the C# Dev Kit extension. It's lighter and cross-platform. You can always switch later — your code files are just text files that any editor can open.

Step 4: Create a New 3D (URP) Project

Now for the exciting part — creating the actual project that will become our infinite runner.

  1. In Unity Hub, click the "Projects" tab in the left sidebar.
  2. Click the "New project" button in the top-right corner.
  3. You'll see a list of project templates. Look for and select "3D (URP)" or "Universal 3D". It may be labeled slightly differently depending on your Unity version, but it will mention "URP" or "Universal Render Pipeline."
  4. In the "Project name" field, type: InfiniteRunner. No spaces — this keeps file paths clean and avoids potential issues on some platforms.
  5. Choose a location for your project. Pick somewhere easy to find, like C:\Unity Projects\ on Windows or ~/Unity Projects/ on Mac. Avoid paths with special characters or very deep nesting.
  6. Make sure "Connect to Unity Cloud" is unchecked (we don't need cloud services for this tutorial).
  7. Click "Create project" and wait. Unity will generate the project structure, import default packages, and compile everything. This takes 2–5 minutes on first launch.
⛔ Do NOT Choose "3D (Built-in)" or "3D Core"

Unity offers multiple 3D templates. The "3D" or "3D Core" template uses the older Built-in Render Pipeline, which is legacy. We specifically want 3D (URP) — the Universal Render Pipeline. If you create a project with the wrong pipeline, you'll need to start over or go through a painful conversion process. Double-check before clicking "Create project."

What Is URP and Why Do We Use It?

URP stands for Universal Render Pipeline. A render pipeline is the system that decides how Unity draws everything on screen — how it handles lighting, shadows, post-processing effects, and materials. Unity has three render pipelines:

We choose URP because:

💡 You Can Always Change Your Mind (But It's Painful)

Technically, you can convert a project from one render pipeline to another, but it requires changing all your materials and shaders. It's a tedious process. That's why we pick URP from the start and stick with it. Starting with the right pipeline saves you hours of work later.

Step 5: First Time Opening Unity

After Unity finishes creating the project, the editor will open. You'll see a lot of panels, buttons, and menus. Don't panic — we'll explore every one of them in detail in the next chapter. For now, here's a quick orientation so you can confirm everything is working:

You should see these main areas:

If you see all of these, your installation is working correctly. If Unity looks different or a panel is missing, don't worry — you can reset the layout by going to Window → Layouts → Default from the menu bar at the top.

✅ The Default Scene

Every new URP project starts with a scene called SampleScene. It contains two objects: a Main Camera (which is the player's eyes) and a Directional Light (which simulates sunlight). This is the blank canvas we'll build our game on.

Step 6: Create Your First Scene and Save It

The default "SampleScene" works, but we want to start clean with our own scene that has a meaningful name. Here's how to create and save a scene:

  1. First, let's create a folder for our scenes. In the Project window at the bottom, right-click on the "Assets" folder and choose Create → Folder. Name it Scenes.
  2. Now create a new scene: Go to File → New Scene from the top menu bar.
  3. A dialog may appear asking which template to use. Choose "Basic (URP)" or simply the default option. Click "Create."
  4. Save the scene immediately: Go to File → Save As (or press Ctrl+Shift+S on Windows, Cmd+Shift+S on Mac).
  5. Navigate to the Assets/Scenes folder you just created.
  6. Name the scene GameScene and click Save.

You should now see GameScene in your Project window under Assets/Scenes/. The scene file has a .unity extension. This is the main scene where our infinite runner will live.

⚠️ Save Early, Save Often

Unity does not auto-save your scene. If Unity crashes (rare but it happens) or you accidentally close without saving, you'll lose any unsaved changes. Get in the habit of pressing Ctrl+S (or Cmd+S) frequently. Do it every time you make a meaningful change. Your future self will thank you.

Step 7: Verify Your Project Structure

Let's take a look at what Unity created for us. In the Project window, you should see this folder structure inside Assets:

Project WindowFolder Structure
Assets/
  Scenes/
    GameScene.unity       ← Our game scene
  Settings/               ← URP rendering settings (auto-generated)
    URP-HighFidelity.asset
    URP-Balanced.asset
    URP-Performant.asset
    ...

The Settings folder was created automatically by the URP template. It contains render pipeline configuration assets that control how Unity renders graphics. We'll rarely touch these directly, but they're important — they're why our project uses URP instead of the built-in pipeline.

In the next chapter (Project Architecture), we'll create a proper folder structure with folders for Scripts, Prefabs, Materials, and more. For now, having just Scenes/ is perfect.

Step 8: Test That Everything Works

Let's do a quick sanity check to confirm Unity is running properly and your code editor is connected.

  1. In Unity, press the Play button at the top center of the editor (the triangle icon). The Game View will appear showing what the camera sees. Right now that's just a blank sky and ground. Press Play again to stop.
  2. Now let's test the code editor connection. In the Project window, right-click on the Assets folder and choose Create → C# Script. Name it TestScript.
  3. Double-click the TestScript file. Your code editor (Visual Studio or VS Code) should open automatically with the script file.
  4. You should see this default code:
TestScript.csC#
using UnityEngine;

public class TestScript : MonoBehaviour
{
    // Start is called once before the first execution
    // of Update after the MonoBehaviour is created
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {

    }
}

If your code editor opened and you can see this code, everything is connected correctly. Let's add one line to confirm that scripts can actually run in our game. Modify the Start method like this:

TestScript.csC#
void Start()
{
    Debug.Log("Hello from Infinite Runner! Unity is working.");
}

Debug.Log() prints a message to Unity's Console panel. It's the game developer's equivalent of print() — you'll use it constantly for debugging.

  1. Save the script in your code editor (Ctrl+S).
  2. Switch back to Unity. You'll notice Unity briefly "compiles" — a small spinner appears in the bottom-right corner. This happens every time you save a script. Unity is compiling your C# code.
  3. Now we need to attach the script to a GameObject. In the Hierarchy, click on "Main Camera" to select it.
  4. In the Inspector panel on the right, scroll down and click "Add Component."
  5. Type TestScript in the search box and click on it to add it.
  6. Press Play. Look at the Console panel at the bottom of the editor (if you don't see it, go to Window → General → Console).
  7. You should see the message: "Hello from Infinite Runner! Unity is working."

If you see that message, congratulations — your development environment is fully set up and working. You can now write code, attach it to objects, and run it in the game.

✅ Clean Up the Test Script

Now that we've confirmed everything works, delete the test script. In the Project window, right-click TestScript and choose Delete. Unity will also automatically remove it from the Main Camera's components. We'll create our real scripts starting in the C# chapter. Always keep your project clean — don't leave test files lying around.

Chapter Summary

Here's what we accomplished in this chapter:

Your development environment is ready. In the next chapter, we'll take a thorough tour of the Unity editor so you understand exactly what every panel, button, and menu does before we start building.