Preface

Unity Certified Programmer: Exam Guide will take a basic object-oriented programmer and introduce them to Unity through a creative project that stretches across the entire book, achieving essential exam core objectives that can be put toward Unity's own Official Programmer Exam.

This book will take you (the programmer) through discussing the exam itself, breaking down each of its objectives, and what is expected of you to achieve a pass. From there, everything we'll discuss relates to supporting you with potential questions from the exam. So, we'll start straight away and refer to an overview of common design patterns and even more common SOLID principles that all programs need to know. We will go through our game design brief and custom-built framework before we even touch Unity.

After installing Unity, you will begin to take your first steps in building a side-scrolling shooter game, and at the beginning of every chapter, it will be brought to your attention which core objectives you will be covering to support you. After some chapters, you will also be tested with a mini mock exam to see how you are getting on.

By the end of the book, you will have created a game that can be played on a standalone PC and/or Android device supporting a keyboard and touch screen controls, where you will fly a spaceship to fight off oncoming enemies.

As early as Chapter 2, Adding and Manipulating Objects, you will have coded the majority of the game and the following chapters we'll progress through will introduce you to Unity's tools and components, such as the Timeline, which is specifically built for the TV/film industry and cutscenes in games. You will cover particle effects, different materials to apply to your game objects to make them react to light, fading the sound in and out by manipulating an audio mixer with your scripting, pausing the game, storing values in your own scriptable objects, and much, much more.

Even if you aren't taking the Unity Certified Programmer Exam, you will make a game that you can continue to develop, play, and learn from.

Who this book is for

This book is for any object-oriented programmer who wants to learn more about Unity and go as far as feeling ready to go even further and take the Unity Certified Programmer Exam after completing this book.

What this book covers

Chapter 1, Setting Up and Structuring Our Project, introduces what is expected of you in the exam, discusses SOLID principles, and gives an overview of design patterns. You will also see how we are going to create our game by looking at its framework and version control.

Chapter 2, Adding and Manipulating Objects, gets you started with coding and importing 3D assets to get the basics of the game functioning.

Chapter 3, Managing Scripts and Mock Tests, extends the game out into menu screens, adding sound, adding a scoring system, and ending with the first mock exam.

Chapter 4, Applying Art, Animation, and Particles, focuses on understanding materials, animating textures, and creating particle systems.

Chapter 5, Creating a Shop Scene for Our Game, introduces the shop scene and making use of Unity's raycast system, which shoots invisible rays to help identify game objects, and looks at uses of scriptable objects for filling out content.

Chapter 6, Purchasing In-Game Items and Advertisements, covers making the shop scene have a working in-game balance to buy upgrades and introduce users to watch adverts to gain extra in-game credits. By the end of the chapter, the player will be able to make use of firing a new weapon and taking extra hits from enemies with their bought shield.

Chapter 7, Creating a Game Loop and Mock Test, moves through each screen until the game loops back to the beginning to create a game loop, finishing off with a mock test that has questions on the material learned so far.

Chapter 8, Adding Custom Fonts and UI, gets more familiar with Unity's 2D Canvas, adding polish to each screen by applying image components and custom font and animating each level's title.

Chapter 9, Creating a 2D Shop Interface and In-Game HUD, takes the shop scene from looking less like a prototype to more polished and functioning to support various screen aspect ratios. This chapter also introduces an in-game life, map, and score system.

Chapter 10, Pausing the Game, Altering Sound, and a Mock Test, covers creating a pause screen for each level of the game, which will give options to alter the game's volume controls, quit and resume the game, followed by a mock test to check your knowledge of the chapter.

Chapter 11, Storing Data and Audio Mixer, makes use of Unity's own PlayerPrefs and compares it with JSON and storing data in the cloud with remote settings.

Chapter 12, NavMesh, Timeline, and Mock Test, introduces a new enemy that attempts to escape the player with the use of AI and looks at animating a boss into the scene with the use of Unity's animation tool, Timeline, and extending its functionality to animate flashing lights. There's another mock test at the end of the chapter to see how well things are going.

Chapter 13, Effects, Testing, Performance, and Alt Controls, discusses making use of colliders, rigidbody properties, visual effect post-processing, global lighting, and reflection probes. This chapter also looks at further gameplay functionality to support mobile controls, building, and testing the game on PC and mobile.

Chapter 14, Full Unity Programmer Mock Exam, includes over 90 questions to answer and to test you on what you've learned from all 13 chapters and the answers will be found in the appendix.

To get the most out of this book

Some familiarity with Unity would be helpful but is not essential. A basic understanding of C# or any other object-oriented programming knowledge is required. At the time of writing this book, the Unity exam is based on Unity version 2017.3. We'll go through the procedure of downloading and installing the software in Chapter 1, Setting Up and Structuring Our Project. If for any reason, you are using a later version of Unity, that shouldn't matter unless the book mentions where things may differ between versions.

Download the example code files

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

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the Support tab.
  3. Click on Code Downloads.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

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/Unity-Certified-Programmer-Exam-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available athttps://github.com/PacktPublishing/. Check them out!

Code in Action

Code in Action videos for this book can be viewed at https://bit.ly/3hZHeGi.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in the text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "A Unity package is a single file that contains various assets that can be used in Unity in a similar manner to a .zip file."

A block of code is set as follows:

  void Start()
{
this.transform.localPosition = Vector3.zero;
startPos = transform.position;
Distance();
}

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

          public class PlayerSpawner : MonoBehaviour
        

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "To finally bake the lights, open the Lighting window by going to Window | Lighting | Settings. Once there, select the Global Maps tab."

Warnings or important notes appear like this.
Tips and tricks appear like this.

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at customercare@packtpub.com. You can also contact the author of the book on Twitter: @retrophilion

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packtpub.com/support/errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at copyright@packt.com with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.