Book Image

Unity 2D Game Development Cookbook

By : Claudio Scolastici
Book Image

Unity 2D Game Development Cookbook

By: Claudio Scolastici

Overview of this book

<p>Unity is a powerful game development engine that provides rich functionalities to create 2D and 3D games.</p> <p>Unity 2D Game Development Cookbook is a practical guide to creating games with Unity. The book aims to serve the purpose of exploring problematic concepts in Unity for 2D game development, offering over 50 recipes that are easy to understand and to implement, thanks to the step-by-step explanations and the custom assets provided. The practical recipes provided in the book show clearly and concisely how to do things right in Unity. By the end of this book, you'll be near "experts" when dealing with Unity. You will also understand how to resolve issues and be able to comfortably offer solutions for 2D game development.</p>
Table of Contents (15 chapters)
Unity 2D Game Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Introduction


Projects in Unity can be structured as collections of scenes, and scenes can be thought of as the different screens that are displayed while the game runs.

Upon launching, a game generally starts with a so-called main screen or home screen. This screen displays the relevant options to interact with the game. There is usually a Play button to launch the game, a button to edit game options such as audio and graphics, another button to launch a multiplayer session, and so on.

In this example, the home screen will be a scene in the Unity project, and each stage of the actual game will be a scene of its own, such as the Game Won and Game Lost screens. The following diagram shows the screen flow of our prototype:

Scenes and their contents are loaded when required at runtime through scripting. When a scene is loaded, all the game objects and components that were saved in that scene when creating the game are loaded as well.

On the other hand, when the scene is unloaded, all game objects...