Book Image

Learning C# 7 By Developing Games with Unity 2017 - Third Edition

Book Image

Learning C# 7 By Developing Games with Unity 2017 - Third Edition

Overview of this book

Do you want to learn C# programming by creating fun and interactive games using the latest Unity 2017 platform? If so, look no further; this is the right book for you. Get started with programming C# so you can create 2D and 3D games in Unity. We will walk you through the basics to get you started with C# 7 and its latest features. Then, explore the use of C# 7 and its latest functional programming capabilities to create amazing games with Unity 2017. You will create your first C# script for Unity, add objects into it, and learn how to create game elements with it. Work with the latest functional programming features of C# and leverage them for great game scripting. Throughout the book, you will learn to use the new Unity 2017 2D tool set and create an interactive 2D game with it. You will make enemies appear to challenge your player, and discover some optimization techniques for great game performance. At the end, you will learn how to transform a 2D game into 3D, and you will be able to skill up to become a pro C# programmer with Unity 2017!
Table of Contents (23 chapters)
Title Page
Credits
About the Authors
About the Authors
About the Reviewer
www.PacktPub.com
Customer Feedback
Preface

Preface

Hello and welcome to the amazing journey of game development. This book is destined for those who have always wanted to create a game, the ones who have thousands of good ideas for games and people who inspire to be professional game developers. This book is destined for you. Here, you will learn the fundamentals of how to create a game from start to finish using Unity and C#. Step by step, you will be learning how to code and how to use the game engine to turn your ideas into real projects. At the end of the book, you'll have created a 2D platform game, and you will know how to create different games using the same principles that you have learned.

What this book covers

Chapter 1, Discovering Your Hidden Scripting Skills and Getting Your Environment Ready, puts you at ease with writing scripts for Unity.

Chapter 2, Introducing the Building Blocks for Unity Scripts, helps you develop the skill of writing your first executable code.

Chapter 3, Getting into the Details of Variables, teaches you about creating and using C# variables, followed editing them in Unity Inspector.

Chapter 4, Getting into the Details of Methods, helps you learn more in detail about methods and how to use them to understand the importance of code blocks and the variables used in them.

Chapter 5, Lists, Arrays, and Dictionaries, introduces slightly more complex ideas of handling, lists, arrays, and dictionaries, which allow you to store many values at once.

Chapter 6, Loops, focuses on learn how to "ask" Unity to loop through a section of code and do something useful.

Chapter 7,Objects, a Container with Variables and Methods, dives into the subjects of organizing your code and object-oriented programming.

Chapter 8, Let's Make a Game! – from Idea to Development, explains how to turn an idea into a ready-to-code project and how to break down complex mechanics into pieces.

Chapter 9, Starting Your First Game, outlines transforming an idea into a real Unity project.

Chapter 10, Writing GameManager, gets you acquainted with the basics of the singleton approach and also helps you work through the gameplay loop.

Chapter 11, The Game Level, teaches how to create reusable pieces of a level and also how to populate them to create the illusion of an endlessly running game.

Chapter 12, The User Interface, showcases how to construct and implement the user interface in our game.

Chapter 13, Collectables, outlines collectables and storing some data between Unity sessions.

Chapter 14, Enemies, assists in how to create enemies and obstacles, how to animate them and how to turn simple Game Objects into deadly objects.

Chapter 15, Audio, 3D Games, and Export, assists in implementing audio effects and music, introduces you to the fundamentals of how to create a 3D game, and finally, how we can export the game to multiple platforms.

What you need for this book

You will definitely need a computer–PC, Mac, or any machine that supports Unity editor installation. The complete Unity system requirements can be found at https://unity3d.com/unity.

Who this book is for

The book is targeted at beginner-level Unity developers with no prior programming experience. If you are a Unity developer and wish to create games by learning how to write C# scripts or code, then this book is for you.

Conventions

In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "This is the part where you have to write down instructions so that your GameObjects can be smarter."

A block of code is set as follows:

void AddTwoNumbers () 
{ 
  // Code goes here 
} 

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Go ahead and click Play."

Note

Warnings or important notes appear in a box like this.

Note

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book-what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail [email protected], and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for this book from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

You can download the code files by following these steps:

  1. Log in or register to our website using your e-mail address and password.
  2. Hover the mouse pointer on the SUPPORT tab at the top.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box.
  5. Select the book for which you're looking to download the code files.
  6. Choose from the drop-down menu where you purchased this book from.
  7. Click on Code Download.

You can also download the code files by clicking on the Code Files button on the book's webpage at the Packt Publishing website. This page can be accessed by entering the book's name in the Search box. Please note that you need to be logged in to your Packt account.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR / 7-Zip for Windows
  • Zipeg / iZip / UnRarX for Mac
  • 7-Zip / PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Learning-C-7-By-Developing-Games-with-Unity-2017-Third-Edition. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books-maybe a mistake in the text or the code-we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to https://www.packtpub.com/books/content/support and enter the name of the book in the search field. The required information will appear under the Errata section.

Piracy

Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at [email protected] with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.

Questions

If you have a problem with any aspect of this book, you can contact us at [email protected], and we will do our best to address the problem.