Book Image

Learning C# by Developing Games with Unity 5.x - Second Edition

Book Image

Learning C# by Developing Games with Unity 5.x - Second Edition

Overview of this book

Unity is a cross-platform game engine that is used to develop 2D and 3D video games. Unity 5 is the latest version, released in March 2015, and adds a real-time global illumination to the games, and its powerful new features help to improve a game’s efficiency. This book will get you started with programming behaviors in C# so you can create 2D games in Unity. You will begin by installing Unity and learning about its features, followed by creating a C# script. We will then deal with topics such as unity scripting for you to understand how codes work so you can create and use C# variables and methods. Moving forward, you will find out how to create, store, and retrieve data from collection of objects. You will also develop an understanding of loops and their use, and you’ll perform object-oriented programming. This will help you to turn your idea into a ready-to-code project and set up a Unity project for production. Finally, you will discover how to create the GameManager class to manage the game play loop, generate game levels, and develop a simple UI for the game. By the end of this book, you will have mastered the art of applying C# in Unity.
Table of Contents (20 chapters)
Learning C# by Developing Games with Unity 5.x Second Edition
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Working with objects is a class act


I'm throwing the word object around like you were born with the knowledge of what an object is. Actually, you do know what it means. The coffee cup you may have in your hand is an object, a real one. That UFO flying around at night is an object, even if you can't identify it. In Unity, you may have a flying saucer in your Scene, but it's obviously not a real flying saucer—it's a virtual one.

However, in the virtual world of gaming, most people would consider things they can see on the screen as objects.

If you can expand your mind just a little bit more, perhaps you can accept that not all objects in Unity have to be something you can see in a game Scene. In fact, the vast majority of objects in Unity are not visually in the Scene.

In a computer, an object is just a small section of your computer's memory that acts like a container. The container can have some data stored in variables and some methods to work with the data.

The best example I can show you...