It’s hard to believe that in only a little more than ten years, Unity has gone from a scrappy graphics engine available only on the Mac, to the current graphics powerhouse available on almost thirty platforms.
Unity has often been compared to a Lego set – a singular tool that can solve a multitude of problems. While this is true, I like to think of Unity as an ocean instead.
Why? Well, you can stay near the beach and dip your toes in the water while building some awesome creations. But Unity lets you go as deep as you want and gives you the ability to customize the environment, write your shaders, and now with with Unity 5.1, even rewrite the networking stack 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 shoreline while you build a killer sand castle. As the introductory tutorial, this will give you an eagle-eyed view of the engine environment and tools, while subsequent tutorials will focus on the details of each subsystem.
In in this Unity tutorial, you’ll learn the following:
- How to install Unity and what the differences are between the Personal and Professional versions.
- What the different views are that make up the Unity interface.
- How to navigate within the Scene view.
- How to add and manipulate GameObjects and their Components
The first part of the tutorial is all about familiarizing yourself with the Unity User Interface.
In the second part you will apply this knowledge to create your first game, a small space shooter. You will do so with the help of a fairy god mother that provides all the scripts and some models, so you can focus on the Unity Interface some more.
This tutorial is geared for those with little to 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 here. But wait – there are two different versions: the Personal version and the Professional version. Which should you choose?
Unlike previous versions, both versions of Unity make the same engine features available to you. Personal is free (as in beer), whereas Professional can be purchased for $1,500 or can be subscribed to for $75 per month. The most noticeable difference is that games created with the Personal version start with a Unity splash screen, whereas the Professional version does away with the splash screen and provides additional services to your game such as analytics and team asset sharing.
Unity has some pretty 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 push the Free Download button. This will lead to a download page. Simply click on the huge Download installer button.
Run the installer and follow the instructions on screen, which means push Continue and accept the license agreement. Wait for the installation to complete 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 following form:
You’ll have to log in every time you use Unity, but it does offer an offline mode in case you need it.
Once you’ve created an account, logged into Unity, and confirmed all of your license details, the projects dialog will automatically appear. It allows you to create a new project and will look something like the following:
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 two options: 3D or 2D. These two options determine the initial configuration of the editor; you can change these settings later if you decide to change your game type. 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 do not need any of the standard assets. Click on Create project and Unity will open with 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 three buttons. Select the middle button, and from the list of options, select the 2 by 3 option:
Your editor should now look like the image below and have the following sections:
Here’s the breakdown of the various pieces of the editor:
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 like so:
As you test your game in Unity, the scene view will update itself with the current game’s state, and you can even add new elements on-the-fly to the scene. When you stop the game, the scene view will revert 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 where you can play your game and see how all its various mechanics work with one another:
The Game View has a aspect ratio selector, which lets you change the perspective of the view to match that of a specific screen aspect ratio (e. g. 4:3, 16:9, 16:10 …) or a device screen such as that of an iPhone or iPad. This allows you to make sure it looks good on all aspect ratios you want to support and that no important content is cut off.
The Hierarchy contains a list of all the current GameObjects being 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 them than that! :] In essence, GameObjects represent points in space you customize through adding Components. Components permit GameObjects to project geometry, from a simple cube up to more complex 3d models of towers or monsters, emit light, act as camera or even create complex behavior via scripts.
GameObjects can also contain other GameObjects, which makes them quite useful for organizing your Scene. You’ll see GameObjects in action in the second part of this tutorial. Here a tiny preview into the fun you will have :]
A Scene typically represents a single level of your game, although you could theoretically put the entire game inside one scene. Any GameObjects actively being used in your game in the current scene will appear in the Hierarchy:
Every new scene starts with a Main Camera and a Directional Light, which are both GameObjects.
When you delete a GameObject from the Hierarchy, you’re effectively removing it from the scene.
4. Project Browser
The Project Browser contains all assets used by your game; it’s like a mini-filesystem. You can organize your assets by folders, and when you wish to use them, you can simply drag those assets from the Project Browser to the Hierarchy. Alternatively, you can drag them from the Project Browser to the Scene View. If you drag files from your computer into the Project Browser then Unity will automatically import those as assets for you.
Unity organizes the assets in the OS file system to mimic the Project Browser. You may be tempted to make changes directly in the file system instead of in the Project Browser, 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 on the filesystem breaks the metadata. If you need to make any organizational changes to your assets, always perform them in the Project Browser.
The Inspector view lets you configure any GameObject. When you select a GameObject in the Hierarchy, the Inspector will list all the appropriate fields on that GameObject; 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 be using the following tools a lot as you develop your game, so get familiar with them by trying out all of them on your empty project!
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 over the Scene View to pan the entire scene:
Right-click and drag to rotate the camera around your current position; notice that the hand icon transforms into an eye:
Next, hold down Ctrl and Alt, right-click and move the mouse up to zoom into the scene. Moving the mouse down zooms out. Or if you don’t feel particularly coordinated, just just use the scroll wheel:
Finally, hold down the right mouse button and use your WASD keys to move around the scene à la 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 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 first select a GameObject you’ll see 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 is known as a left-handed coordinate system. For a deeper explanation about left- and right-handed coordinate systems, check out this interesting article about coordinate systems from what-when-how.
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, 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 boxes in the center of the GameObject let you move the GameObject on two axes; the square’s color indicates the direction it will NOT move. For instance, a green square means you can move an object on the x and z axes, but not on the y-axis:
The 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 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 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 forwards or backwards to scale the GameObject up or down respectively:
The 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’ll 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 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 shortcut key? That’s right, it’s T.
The Gizmo display toggles tend to be a point of confusion; they’re more than buttons, in fact – they’re toggle switches that control how you position Gizmos in your scene.
The first switch toggles between Center and Pivot. 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. In Global mode, you’re manipulating 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. Switching to 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 press Play; First, your game will start, as expected. The button set will also turn blue to indicate the game is in motion:
The entire design interface dims as well to indicate 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 help 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. Open the Unity preferences (shortcut CMD-,) and you’ll see a list of colors in the Colors section that you can customize in your interface:
The Playmode tint field controls the dimming color of the interface.
You can choose any color; to reset to the original color simply click the Use Defaults button.
The next button is Pause:
This pauses your game and lets you make modifications to the game. Just like in play mode those modifications will be lost once you stop the game. Regard editing game objects during play and pause as a cheat and balancing system that allows you to experiment on your game without the danger of permanently breaking it.
The final button is Step:
This lets you step through your game one frame at a time; it’s 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 three controls handle miscellaneous aspects of the editor. The first is the Layers drop-down:
You can use Layers for such things as preventing the rendering of GameObjects, or excluding GameObjects from physics events like collisions.
Next up is the Layouts drop-down; this lets you create and save the layout of views in your editor and switch between them. Unity is wonderfully customizable, and 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 single time you wanted 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 Window menu item:
Unity comes with a few pre-defined layouts, such as the 2 by 3 layout and Wide layouts:
As you work on games in Unity, you’ll find yourself creating many different layouts to support your various development tasks.
The next button is the Service button. The service 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 that will allow you to add services to it.
Once you add a Project ID, you will be able to add services to your project. For instance, you can provide 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 Analytics, In-Game Ads, and Multiplayer support.
You can also add team members to the project, set age restrictions, and change some important project settings.
The final button, Account, lets you manage your Unity account. It allows you to view your account data, sign in and out, and upgrade:
That covers the majority of the views you’ll use when making games, but there are many more views beyond just these. You can get an overview over 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 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’ll need to leverage to create your very own game.
Do you have any questions about this tutorial, or the Unity editor or any of its associated views? Leave a comment below and I’ll get back to you!