When I first started looking into iOS game development, Xcode (before SpriteKit) made game development look very challenging. Unity, on the other hand, had a powerful visual editor and was also capable of publishing to mobile.
Looking at it further, I found the asset store and fantastic developer community made Unity a compelling option.
Today, Unity boasts more game development than any other game technology. And with support for almost 30 platforms including mobile, virtual reality, desktop and console, Unity isn’t just a good place to start, it’s the perfect place to start!
Unity employs a fantastic modular system to build scenes and characters in your game. Even if you’re just starting out, you can still make a pretty awesome spaceship with Unity’s basic lego brick set.
Or, if you feel you’re ready for the “highly sophisticated interlocking brick system” for adults, Unity gives you the ability to customize almost any component, such as writing your own shaders or rewriting the networking stacks to suit the needs of your game!
This is the first in a series of Unity tutorials designed to get you up to speed. In it, you’ll stick to the spaceport while you familiarize yourself with the engine environment and tools. Subsequent tutorials will focus on the details inside each subsystem.
In this Unity tutorial, you’ll learn:
- How to install Unity and the differences between the three different versions
- The views that make up the Unity interface
- Navigating inside the Scene view
- Adding and manipulating GameObjects and their Components
The first part of this tutorial is all about familiarizing yourself with the Unity User Interface.
In the second part of this tutorial, you’ll apply this knowledge to create your first game, a simple spaceship flying / asteroid blasting game. You’ll do so with the help of a fairy godmother who provides all the scripts and models, so you can focus more on the Unity Interface.
This tutorial is geared toward those with little or no Unity experience. Ideally, you should have some programming experience, but if not, don’t sweat it — we’ll walk you through the whole thing! :]
The first step of this tutorial is to download Unity. But wait — there are four different versions. Which should you choose?
All versions of Unity provide you with the same engine features.
- Personal: Free (as in beer)
- Plus: Costs $35/mo per seat
- Pro: Costs $125/mo per seat
There’s also an Enterprise version where your custom needs dictate the subscription price.
The most noticeable difference between these versions is that games created with the Personal version have to start with a Unity splash screen, whereas any of the paid versions allow you to either remove the splash screen or create your own.
Additionally, there are different tiers of Unity services, such as Cloud Build and Analytics, that are unlocked at each price point.
Unity has some strict rules about how you can use the Personal edition. Before you start writing your next killer Unity app, be sure to check out the Unity FAQ to see if you’re eligible to use it.
For the purpose of following the tutorials, the Personal Edition is sufficient, so click the Try Personal button. This will take you to the download page. Click on the large Download Installer button.
Run the installer and follow the instructions on screen, which means clicking Continue and accepting the license agreement. Wait for the installation to complete and then launch Unity. You’ll be prompted to login before you can go any further.
You’ll need to create a free Unity account in order to use the software if you don’t have one already. To create a Unity account, click the create one link, and fill out the sign-up form.
You’ll have to log in every time you use Unity, but there’s an offline mode if you need it.
Once you’ve created an account, log into Unity and confirm all of your license details. The projects dialog will automatically appear. This dialog allows you to create a new project, and looks something like this:
Click the New project button. You’ll see the dialog switch to the following:
- Name your project Space Debris, and pick a location on your hard drive to save it.
- You’ll notice that you have a few options. Each template pre-configures Unity to save you time depending what you want to do. For now, select 3D.
- The Asset packages button lets you import custom packages into your project. For instance, if you’re making a first person shooter, you may want to import Unity’s first-person controller package.
This is simply a convenience feature at the time of project creation. You’re able to import packages at any point during your project’s lifecycle. For this tutorial, you don’t need any of the standard assets.
- Unity Analytics can be left Off since it isn’t covered in this tutorial.
- Finally, click on Create project, and Unity will open your first project.
Breaking Down the Interface
When Unity first opens, you’ll see a window that looks like this:
The interface can be a bit overwhelming at first. Take a deep breath and tell yourself it’s going to be all right! :]
The interface is highly customizable and can provide you with as much or as little information as you need.
In the upper right hand corner, you’ll see five buttons. Select the last one on the right. This is the Layout Dropdown. From the list of options, select the 2 by 3 option.
Your editor should now look like the image below:
Here’s the breakdown of the various sections:
1. Scene View
The Scene view is where you construct your game. It’s where you add all models, cameras, and other pieces that make up your game. This is a 3D window where you can visually place all the assets you’re using.
As you test your game in Unity, the scene view will update itself with the current game’s state. You can even add new elements on-the-fly to the scene.
When you stop the game, the scene view will revert back to its original state. Any changes you make to the Scene view while you’re playing the game will be lost when it stops.
2. Game View
The Game view represents the player’s perspective of game. This is where you can play your game and see how all the various mechanics work with one another.
The Game view has an aspect ratio selector, which lets you change the dimensions of the view to match that of a specific screen aspect ratio (e. g. 4:3, 16:9, 16:10 …), or a device screen size such as that of an iPhone or iPad.
This allows you to make sure the game looks good on all aspect ratios and resolutions you want to support, and that no important content is cut off. You can add a custom aspect ratio using the Plus button at the bottom of the dropdown.
3. Hierarchy Window
The Hierarchy window contains a list of all the current GameObjects used in your game. But what is a GameObject? That’s an easy one: A GameObject is an object in your game.
OK, there’s a bit more to it than that! :]
In essence, GameObjects are empty containers that you customize by adding components. Components permit GameObjects to project geometry (from a simple cube to more complex 3d models of towers or monsters), emit light, act as a camera or even create complex behavior via scripts.
GameObjects can also act like folders, containing other GameObjects, which makes them quite useful for organizing your scene. You’ll see GameObjects in action in the second part of this tutorial.
A scene typically represents a single level of your game, although you could theoretically put the entire game inside one scene. Any GameObjects actively used in your game in the current scene will appear in the Hierarchy window.
Every new scene starts with a Main Camera and a Directional Light, which are both GameObjects. Mind you, you don’t have to keep them. You can always delete them and add them back at later time. When you delete a GameObject from the Hierarchy, you’re effectively removing it from the scene.
As your scene grows with lots of GameObjects, the search bar will prove to be an invaluable tool.
4. Project Window
The Project window contains all assets used by your game. You can organize your assets by folders. When you wish to use them, you can simply drag those assets from the Project window to the Hierarchy window.
Alternatively, you can drag them from the Project window to the Scene view. If you drag files from your computer into the Project window, Unity will automatically import those as assets.
Unity organizes the assets in the Project window the same as the OS file system does. You may be tempted to make changes directly in the file system instead of in the Project window, but this is a big mistake that will break your assets — and possibly break your game!
Unity maintains metadata for each asset, so moving assets between folders in the file system breaks the metadata. If you need to make any organizational changes to your assets — especially prefabs — always perform those changes in the Project window.
5. Inspector Window
The Inspector window lets you configure any GameObject. When you select a GameObject in the Hierarchy, the Inspector will list all the GameObject’s components and their properties.
For instance, a light will have a color field along with an intensity field. You can also alter values on your GameObjects while the game is being played.
You use the toolbar to manipulate the various GameObjects in the Scene view. You’ll use the following tools as you develop your game, so get familiar with them by trying them in your empty project!
However, you won’t be able to see the effect very well in an empty Scene. So first, add a simple Cube to the scene.
- Open the GameObject dropdown from the Unity Menu.
- Select the 3D Object dropdown.
- Select Cube from the list of available objects.
This will give you a visual reference point while you explore the Toolbar options.
The Hand tool is a “handy” tool (don’t worry folks, the jokes get worse!) with a bunch of useful features built right in.
Select the Hand tool, then drag your mouse over the Scene view to pan the entire scene.
Right-click and drag the mouse to rotate the camera around your current position. Notice that the hand icon transforms into an eye.
Next, hold down Ctrl (or Cmd) and Alt (or Option). Right-click and move the mouse up to zoom into the scene.
Moving the mouse down zooms out. Or if you want to do it the easy way, just use the scroll wheel.
Finally, hold down the right mouse button and use your WASD keys to move around the scene like you would in a first person shooter.
Likewise, you can move up and down by pressing E or Q respectively. To move even faster, hold down the Shift key as well.
The hand tool’s default shortcut key is Q. To jump quickly to the hand tool, press the middle mouse button. Once you release it, you’ll return back to the previous tool you were using.
The Translate tool lets you select and position a GameObject in the scene.
You’ll notice when you select a GameObject while the Translate Tool is active, that there are three colored arrows growing from its center. These arrows indicate the three-dimensional axes of the object: The x-axis is the red arrow, the y-axis is the green arrow, and the z-axis is the blue arrow.
Unity’s coordinate system is left-handed. For a deeper explanation about the left- and right-handed coordinate systems, check out this interesting article about the different coordinate systems.
In this case, the gizmo indicates the direction of each axis. As you learn more about Unity, you’ll be able to add your own gizmos to indicate things such as spawn points, the location of cameras, or even the wind direction. The great thing about gizmos is they’re only displayed in the Scene view, and you can turn them off when they’re no longer needed.
There are many ways to move your GameObject with the Translate tool. You can select one of the arrows (which will turn Yellow when selected), and then move the mouse. The GameObject will only move on that one axis.
For example, if you selected the y-axis and moved an object while facing in a normal orientation, the GameObject would only move up or down.
The three colored planes in the center of the GameObject let you move the GameObject on two axes. The square’s color indicates along what plane it will move. For instance, a green square means you can move an object on the y-plane (which means it can move on the x- and z-axes).
The default shortcut key for the translate tool is W.
The rotate tool, unsurprisingly, lets you rotate objects.
You’ll notice three spherical colored lines when you select an object to rotate. These lines indicate the axis to rotate around. Simply select the line and drag your mouse to rotate the GameObject. To free rotate without being constrained to an axis, select the space between the lines and move your mouse.
The default shortcut key for the rotate tool is E.
The Scale tool lets you scale a GameObject either along a single axis, or proportionately on all axes.
To scale an object along an axis, select the GameObject and then drag the square end of an axis line. The GameObject will scale along that axis. To scale the entire GameObject, select the center point of the GameObject and drag the mouse either forward or backward to scale the GameObject up or down respectively.
The default shortcut key for the scale tool is R.
Note: Some of you may be a bit confused by the shortcut keys. You’d assume the Scale shortcut would be the S key instead of R. Believe it or not, there is a method to the madness. Do you notice a familiar pattern in the shortcut keys…perhaps one right at your fingertips?
Yep, it’s the top row of the keyboard! :]
Unity assumes you’re using the mouse with your right hand and keyboarding with your left. Your fingers, at rest on the home row, will be on the ASDF keys. You’ll note each shortcut key of the toolbar corresponds to a key above the home position. The keyboard shortcuts for the toolbar corresponds to the QWERT keys, from left to right.
Unfortunately, occasionally you may try to press the W key, but press the 2 key by mistake. This puts the editor into 2D mode and will look a lot like this:
When that happens, simply press 2 key again and the editor will revert back to 3D mode.
The Rect tool is primarily used with 2D GameObjects and User Interface (UI) GameObjects, although you can use it on 3D GameObjects as well.
The tool can resize, scale, and rotate 2D assets and also reset the pivot point, which is the center point of rotation for the object. The pivot point is represented by a large circle on the asset.
Can you guess its default shortcut key? That’s right, it’s T.
The Transform tool combines transforming, scaling, and rotating into one tool so that you do everything without switching tools.
The first switch toggles between Center and Pivot mode. When in center mode, if you select two GameObjects, the gizmo will be placed in the center of the two objects. Rotating the GameObjects rotates them around the center gizmo. In pivot mode, each GameObject rotates around its own pivot point, as illustrated below:
The second switch toggles between Global and Local space.
- Global mode: You manipulate your object from the point of view of the world around it. The x-axis goes left to right, the y-axis goes up and down, and the z-axis goes forward and backwards like usual.
- Local mode: Works from the coordinate system of the object itself, and changes the axes to match that of the actual GameObject.
7. Play Buttons
The Play Buttons let you start and stop your game. The first button is the Play button:
A few things happen when you click the Play button. First, your game will start, as expected. The button set will also turn blue to indicate that the game is in motion.
The entire design interface dims as well to indicate that the game is active.
Remember, any changes you make on-the-fly will be lost once you stop the game. It’s a common mistake for Unity beginners and regulars alike to run the game and make a pile of changes – which all disappear when the game stops!
The interface dimming is supposed to remind you of this unfortunate fact, but I find the color shade is too subtle to remind me all the time.
Thankfully, you can change this shading to suit.
- Select Edit ► Preferences to open the Unity Preferences window.
- Select the Colors tab on the left hand side and you’ll see a list of colors in the Colors section that you can customize in your interface.
- You can choose any color by clicking in the indicated area.
- To reset to the the original color, click the Use Defaults button.
The Playmode tint field controls the dimming color of the interface.
Next up is the Pause button:
This pauses and lets you make modifications to the game.
Just like in play mode, those modifications will be lost once you stop the game. Editing GameObjects during play and pausing is a cheat and balancing system that allows you to experiment on your game without the danger of permanently breaking it.
Finally, there’s the Step button:
This lets you step through your game one frame at a time. This is handy when you want to observe animations on a frame-by-frame basis, or when you want to check the state of particular GameObjects during gameplay.
8. Miscellaneous Editor Settings
The final controls handle miscellaneous aspects of the editor. The first is the Collab drop-down, found on the right hand side of the toolbar.
This is one of Unity’s latest services that helps big teams collaborate on a single project seamlessly.
The next button is the Services button. The services button is where you can add additional Unity services to the game. Clicking on the button will prompt you to create a Unity Project ID.
Once you add a Project ID, you will be able to add services to your project.
For instance, you can add cloud builds to your project. This automatically builds your project for you so you don’t have to wait for each project build.
You can also add:
- In-Game Ads
- Multiplayer Support
- In-App Purchasing
- Performance Reporting
You can also add team members to the project, set age restrictions, and change some important project settings.
Next up is the Account button. This lets you manage your Unity account. It allows you to view your account data, sign in and out, and upgrade.
The fourth button is the Layers button.
You can use Layers for such things as preventing the rendering of GameObjects, or excluding GameObjects from physics events like collisions.
The final button, Layouts, lets you create and save the layout of views in your editor and switch between them. Unity is wonderfully customizable. Each of the different views in a layout can be resized, docked, moved, or even removed from the editor altogether.
Don’t worry though — you can always add views you’ve removed back to the interface. This lets you customize the editor for a specific task. For example, you may not want to have the Game view open when working with an animation, but you’d prefer to have the Animator and Animation views open side-by-side.
Rearranging the windows every time you want this specific layout would become tiresome very quickly.
Unity saves you from this tedium by letting you save your layouts, which you can switch to at any time via the Layouts button. You can easily open a new window using the Window menu item.
As you work on games in Unity, you’ll find yourself creating many different layouts to support your various development tasks.
That covers the majority of the views you’ll use when making games, but there are many more views beyond just these. You can see an overview of all of them in the Unity documentation.
Where to Go From Here?
You made it through the introduction to Unity. In Part 2 of this tutorial you’ll put these concepts into practice as you create a small space shooter. You’ll learn how to build games the “Unity” way, and gain a deeper understanding of the various tools and techniques you can leverage to create your very own game.
Do you have any questions about this tutorial, the Unity editor, or any of its associated views? Join the discussion below and I’ll get back to you!