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

Specifying a method's parameters


If you look up the word "parameters" in the dictionary, your brain will probably seize up. All it means is that the method has to be able to use the information you send it, so you simply have to specify the type of data that the method is allowed to use. That's it! It's very simple.

In the earlier screenshot, on line 23, we declared the firstNumber and secondNumber variables. The type is int. Now notice our member variables: number1, number2, and number3. They are also of the int type. These variables have to be of the int type since they store the numbers that will be added to the method, which the parameters specify will be of the int type.

So now, go look in the dictionary again. You will probably see the word limit in there somewhere. That's what you did when you specified the type of data that the method will use, an integer in this case. You set some limits on what is allowed.

Okay, so you're setting parameters, or limits, on the type of data the method...