2 Installing & Using the Unity Editor¶
Introduction¶
It’s time to develop your first Unity game! The Unity Hub is your gateway to install the Unity Editor, manage all your projects and find tutorial resources.
Be aware there are different versions of the Unity Editor as updates and improvements are continually released. However, the Unity Hub will help you install and manage editor versions. It acts as a single overall manager for downloading the latest Unity Editors, keeping track of your projects and launching the Unity Editor.
Installing the Unity Hub¶
Start by downloading the Unity Hub installer for either Windows or Mac from https://unity.com/download:
You should install the latest version of the Unity Hub (3.0.0 at the time of writing) to have an up-to-date listing of sample starter content. After installation, start the Unity Hub and you’ll see this:
On the left side of the Unity Hub, select Installs, then click Install Editor in the top right of the hub.
Choose to install the latest 2020.3.x LTS release. For reference, all of this book’s sample projects were built with 2020.3.26f1, but any 2020.3 release should be compatible.
Start a new project¶
Once the install has finished, switch back to the Projects tab and click New project.
With the 2020.3 LTS Unity Editor as the default, the Unity Hub will provide a variety of templates. Find the Third Person Template under the Core tab on the left.
Click Download template to download the required assets for this template.
When this has downloaded, look under Project Settings and set Project name to ThirdPerson, then specify a location on your local disk drive. Finally, click Create project.
This template provides an over-the-shoulder view of the player’s character — called a third-person view — which can often be a great starting place to develop a variety of games. And, this example project already has simple controls to move the character and generated level content. You’ll use this simple game to tour some of the main features of the Unity Editor.
Unity Editor¶
After creating the third-person template project, the Unity Editor will open.
Initially, you’ll see several panes within the Unity Editor:
- The Hierarchy Window: Provides a listing of the components that make up a scene.
- The Project Window: Lists the assets in your project that you can add to a scene.
- The Scene View: Shows the level of the scene.
- The Inspector Window: Shows the details about a selected object.
Note: If your layout is different, you can reset the panel layout as shown above by choosing the Layout menu in the upper-right of the window and selecting the Default option.
Scene View¶
The most visually striking of the set of panes is the Scene View that shows the current level of the game.
Look to the upper-right in the view and find the Scene Gizmo — the axis showing the X
, Y
and Z
directions in the 3D world. This shows your current orientation in the environment. You can change this at any time by interacting with it, together with the move, orbit and zoom tools as described in Scene view navigation.
The top toolbar of the Scene View includes different tools that control how the environment of the level is displayed.
The Draw Mode drop-down is set as Shaded, but it can be changed to different rendering modes in the Scene View. Next, notice the toggles for a 2D camera, lighting and sound. Then, there’s a drop-down menu with controls enabling various effects like fog and particle systems. Finally, the last category worth mentioning is Gizmos, which are visual aids that show in the Scene View and can help annotate a scene.
Game View¶
Choose the tab next to the Scene View to switch to show the Game View. Now the camera is behind a robotic character in the game.
The toolbar of the Game View controls the behavior of the view and what happens when you begin playing the game. The Maximize On Play toolbar item can be enabled to make the Game View take up the entire Unity Editor view when playing a scene.
Running the game¶
Look at the top of the editor and find the game controls.
Press the Play button on the left to activate the game view. The mouse now controls the in-game camera, and the keyboard’s a
, s
, d
and w
keys move the character around the scene. You can press the Escape key at any time to release the mouse from the focus of the Game View, and click the Play button again to end gameplay. The Pause button in the middle halts execution of the game, and the button on the right allows you to step forward a single frame at a time - great for carefully inspecting small details.
Hierarchy window¶
The Hierarchy window shows a list of items that are within the scene. In Unity, these are called GameObjects, which are essential units for building a game. Chapter 3 will provide a more detailed description of GameObjects and how you can use them to build your first game.
Project window¶
The Project window is in the lower left of the default layout. What you see in this view is a listing of the Assets of the game. These include all the 3D models, images, sounds, animations and other generated artwork that can be used to assemble and define your game.
Expand the Character folder in the Project window and select the subfolder called Models. Click the Armature item to select it.
Inspector window¶
Upon selecting a different item in the Project, the Inspector window updates to display new details. It’s also where you can see the details of any GameObject or asset in your project or scene. Additionally, this is the primary location to make changes to parameters that configure how the GameObject or asset will behave in the game.
In this instance you can see details about the 3D model that’s the main character shown in the Game view. This is the character controlled by the player in the third-person game template.
Other windows¶
Additional Unity windows will be covered later in the book, including:
- The Navigation Window. This is covered in depth in Chapter 9 as you build a project using the Unity NavMesh Agents.
- The Animator Window. This is introduced during Chapter 12 when different mechanisms of animating content in Unity will be integrated into a game.
Publishing a game¶
You now have a simple game that’s playable in the Unity editor. But what if you wanted other people to play it as well? You can’t ask everyone to install Unity and open your project.
This is where building comes in — which compiles all of the game assets into a single folder with an executable and data files. This folder can then be archived and sent to your family and friends — or even shared over the internet with the whole world.
Adding platforms¶
Unity supports a lot of platforms for building your game — including Windows, macOS, Linux, Android and iOS. The default Unity installation only includes the platform you installed the editor on, but you can easily add more platforms. To check out what platforms you have installed, open the Unity Hub application and click Installs.
Open the Add Modules screen for your version of Unity by clicking the gear menu for an installed editor version and selecting Add Modules.
Check all the platforms you want to add to your Unity installation and click Continue.
Now return to the Unity editor. It’s time to set up everything and create a build.
Creating a build¶
Open the Build Settings window by clicking File ▸ Build Settings… or by pressing Control-Shift-B on Windows or Command-Shift-B on Mac.
The Build Settings window consists of three main parts:
- At the top is a list with included scenes. This is empty at the moment.
- On the left is the list with all available platforms, even those you haven’t installed.
- On the right are the build settings for the selected platform.
To start, you’ll want to add the Playground scene that’s open in the editor, so click the Add Open Scenes button below the scene list to quickly add it. Another way to add a scene to this list is dragging the scene asset from the Project view into the scene list.
In the end, the scene should be visible in the scene list:
Any scenes in the list will be added to the final build in the same order. This means the first scene will be shown first, so it’s a good idea to make this your title screen.
Now, select the very first platform in the list on the left: PC, Mac & Linux Standalone. Next, select your preferred platform on the right in the Target Platform drop-down. Selecting a different platform in this drop-down will trigger Unity to reload all assets and optimize them for the target platform. You can leave the rest of the parameters as-is.
Finally, click the Build button at the bottom right and select a name and location for the build. Unity will now build the player executable. After a short while, the folder will be opened in your system’s file explorer.
While it builds, as an aside, should you prefer customizing certain properties for the build, Unity’s Player Settings and the more general Project Settings will come in really handy.
Congratulations on making your first build! At this point, you have all the tools ready to start working on the projects of this book. The next chapter will introduce you to the building blocks of Unity, the GameObjects and how to create your own playable projects.
Key points¶
- The Unity Hub is a one-stop gateway to Unity Editor versions, projects and learning resources.
- Everything happens within the Unity Editor, where you can build levels, script your gameplay and test your game.
- The Scene View is where you’ll build your game levels and organize your 3D content.
- The Game View shows a preview of the camera view. After pressing play, it becomes the active gameplay of your scene.
- A scene is composed of GameObjects. All of the GameObjects of your scene are shown in the Hierarchy Window.
- All the assets of your game are shown in the Project Window and the details of an individual asset can be viewed in the Inspector Window.