Book Image

Learning Unity 2D Game Development by Example

By : Venita Pereira
Book Image

Learning Unity 2D Game Development by Example

By: Venita Pereira

Overview of this book

<p>If you are looking for a guide to create 2D games using Unity, look no further. With this book, you will learn all the essentials of 2D game development by creating five real-world games in a step-by-step manner throughout the course of this book.</p> <p>Starting with a blank scene, you will learn all about the new Unity 2D toolset, which will enable you to bring your scene to life. You will create characters, make them move, create some enemies, and then write code to destroy them. After figuring out all the necessities of creating a game, this book will then assist you in making several different games: games with collision, parallax scrolling, Box2D, and more.</p> <p>By the end of this book, you will not only have created several small games, but you will also have the opportunity to put all your new-found knowledge into creating and deploying a larger, full game.</p>
Table of Contents (17 chapters)
Learning Unity 2D Game Development by Example
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Unity Editor interface


We are now going to familiarize ourselves with the Unity Editor interface so that we know our way around Unity.

The main editor window is made up of Views. Views are all the tabbed windows that you see, namely:

  • Toolbar

  • Scene

  • Game

  • Project Browser

  • Hierarchy

  • Inspector

  • Other Views that are not shown by default

We can see the main editor with all of its Views, which were just mentioned, in the following screenshot:

Toolbar

At the very top of the editor interface, we have all the controls.

The Transform tools are used with Scene View to drag the camera, move the position of objects, and rotate and scale objects in the scene respectively, as shown in the following screenshot:

When we add an object to our scene and select it, we can see arrows protruding along the x and y axes from our object. These arrows are called Transform Gizmos, and we use them to move, rotate, and size our objects.

Selecting each of the following Transform tools changes the gizmo (the bounding box on your selected object) in Scene View, as shown in the screenshot that follows the description of the tools:

  • Translate (the shortcut key is W): This is used to move the selected object in our scene

  • Rotate (the shortcut key is E): This is used to rotate our selected object

  • Scale (the shortcut key is R): This is used to increase or decrease the size of our object

    Note

    The screenshot is in 3D because even in 2D, we can still move objects along the z axis.

The Transform Gizmo toggles are used to toggle the position of the Transform Gizmos. Center will position them at the center of the object, whereas Local will position them relative to the object's rotation. The toggles are displayed in the following screenshot:

The following screenshot shows the control that is used with Game View to play, pause, and step through the game in the editor:

The Layers drop-down box is used with Scene View to choose which objects we want to see in the editor's Scene View according to the layer. It is useful when we are editing a complicated level or scene. We select it by clicking on the drop-down menu displayed in the following screenshot:

The Layout drop-down menu enables us to set up the positioning of the interface to our own liking. Depending on our screen's resolution and size, we may prefer one layout over another and should therefore try each one out by clicking on the drop-down menu shown in the following screenshot:

Scene View

Scene View is the area where we will interact with our GameObjects such as cameras, backgrounds, the player, enemies, and so on. It is within this view that we can position and transform our GameObjects.

The following screenshot displays our Scene View:

Game View

Game View displays the final published game rendered from the camera view. This is where we test out our game.

To achieve this, we simply press the play button and see our game as in the following screenshot, where an example game has been loaded: