Book Image

Unity 5.x By Example

By : Alan Thorn
Book Image

Unity 5.x By Example

By: Alan Thorn

Overview of this book

Unity is an exciting and popular engine in the game industry. Throughout this book, you’ll learn how to use Unity by making four fun game projects, from shooters and platformers to exploration and adventure games. Unity 5 By Example is an easy-to-follow guide for quickly learning how to use Unity in practical context, step by step, by making real-world game projects. Even if you have no previous experience of Unity, this book will help you understand the toolset in depth. You'll learn how to create a time-critical collection game, a twin-stick space shooter, a platformer, and an action-fest game with intelligent enemies. In clear and accessible prose, this book will present you with step-by-step tutorials for making four interesting games in Unity 5 and explain all the fundamental concepts along the way. Starting from the ground up and moving toward an intermediate level, this book will help you establish a strong foundation in making games with Unity 5.
Table of Contents (15 chapters)
Unity 5.x By Example
About the Author
About the Reviewer

Importing assets

Assets are the raw materials for games—the building blocks from which they're made. Assets include meshes (or 3D models), such as characters, props, trees, houses, and more: textures, which are image files such as JPEGs and PNGs (these determine how the surface of a mesh should look); music and sound effects to enhance the realism and atmosphere of your game, and finally, scenes, which are 3D spaces or worlds where meshes, textures, sounds, and music live, exist, and work together holistically as part of a single system. Thus, games cannot exist without assets—they would otherwise look completely empty and lifeless. For this reason, we'll need assets to make the coin collection game we're working toward. After all, we'll need an environment to walk around and coins to collect!

Unity, however, is a game engine and not an asset creation program. This means that assets, such as characters and props, are typically made first by artists in external, third-party software. From here, they are exported and transferred ready-made to Unity, and Unity is responsible only for bringing these assets to life in a coherent game that can be played. Third-party asset creation programs include Blender (which is free of charge), Maya or 3DS Max to make 3D models, Photoshop or GIMP (which is free of charge) to create textures, and Audacity (which is free of cost) to generate audio. There are plenty of other options too. The details of these programs are beyond the scope of this book. In any case, Unity assumes that you already have assets ready to import to build a game. For the coin collection game, we'll use assets that ship with Unity. So let's import these to our project. To do this, select Assets | Import Package from the application menu. Then select Characters, ParticleSystems, Environment, and Prototyping. See Figure 1.9:

Figure 1.9: Importing assets via the Import Package menu

Each time you import a package from the menu, you'll be presented with an Import dialog. Simply leave all settings at their defaults, and click on Import. See Figure 1.10:

Figure 1.10: Choosing Assets to import

By default, Unity decompresses all files from the package (a library of assets) into the current project. After importing, lots of different assets and data will have been added to the Project, ready for use. These files are copies of the originals. So any changes made to the imported files will not affect or invalidate the originals, which Unity maintains internally. The files include models, sounds, textures, and more. These are listed in the Unity Editor from the Project panel. See the following screenshot:

Figure 1.11: Browsing imported assets from the Project panel


When selecting Assets | Import from the application menu, if you don't see all, or any, asset packages listed, you can download and install them separately from the Unity website at From the downloads page, choose the Additional Downloads option, and then select the Standard Assets package. See Figure 1.12.

Figure 1.12: Downloading the Standard Assets package

The imported assets don't exist yet in our game. They don't appear on screen, and they won't do anything yet! Rather, they're simply added to the Project panel, which behaves as a library or repository of assets, from which we can pick and choose to build up a game. The assets imported thus far are built-in into Unity and we'll be continually using them in subsequent sections to make a functional coin collection game. To get more information about each asset, you can select the asset by clicking on it with the mouse, and asset-specific details will be shown on the right-hand side of the Unity Editor in the Inspector. The Inspector is a property sheet editor that appears on the right-hand side of the interface. It is context-sensitive and always changes to display properties for the selected object. See Figure 1.13.

Figure 1.13: The Inspector displays all the properties for the currently selected object