Book Image

Unity Certified Programmer: Exam Guide

By : Philip Walker
Book Image

Unity Certified Programmer: Exam Guide

By: Philip Walker

Overview of this book

Unity Certified Programmer is a global certification program by Unity for anyone looking to become a professional Unity developer. The official Unity programmer exam will not only validate your Unity knowledge and skills, but also enable you to be part of the Unity community. This study guide will start by building on your understanding of C# programming and take you through the process of downloading and installing Unity. You’ll understand how Unity works and get to grips with the core objectives of the Unity exam. As you advance, you’ll enhance your skills by creating an enjoyable side-scrolling shooter game that can be played within the Unity Editor or any recent Android mobile device. This Unity book will test your knowledge with self-assessment questions and help you take your skills to an advanced level by working with Unity tools such as the Animator, Particle Effects, Lighting, UI/UX, Scriptable Objects, and debugging. By the end of this book, you’ll have developed a solid understanding of the different tools in Unity and understand how to create impressive Unity applications by making the most of its toolset.
Table of Contents (17 chapters)
14
Full Unity Programmer Mock Exam

Introducing our interface – IActorTemplate

The IActorTemplate interface is what we are using to prompt damage control, death, and scriptable object assets. The reason for using an interface such as this is that it ties general uses together between classes that inherit it.

A total of six classes will be using the IActorTemplate interface, which is as follows:

  • Player
  • PlayerBullet
  • PlayerSpawner
  • Enemy
  • EnemyBullet
  • EnemySpawner

The following diagram shows theIActorTemplateinterface with a partial overview of our game framework:

Let's create our interface and explain its content along the way:

  1. Create a script in theAssets/Resources/Scripts folder with the filename IActorTemplate.

  2. Open the script and enter the following code:

public interface IActorTemplate
{
int SendDamage();
void TakeDamage(int incomingDamage);
void Die();
void ActorStats(SOActorModel actorModel);
}
  1. Make sure to save the script.

The code we just entered looks like we have declared a class, but it acts fundamentally differently. Instead of using the class keyword, we enter interface followed by the name of the interface,IActorTemplate. It's not a requirement to start any interface name with an I but it makes the script easily identifiable.

Within the interface, we make a list of methods that act like contracts to whichever class inherits the interface. For example, thePlayerscript that we'll create later on in the chapter inherits theIActorTemplate interface. The Player script must declare the function names from IActorTemplate or the Player script will throw an error.

Inside the scope of the interface, we declare methods without accessors (it doesn't require private or public at the beginning of each method). Methods also don't require any content in them (that is, they are empty bodies).

For more information about interfaces, check out https://learn.unity.com/tutorial/interfaces.

The last method in our interface is ActorStats, which takes a type ofSOActorModel.SOActorModelis a scriptable object that we are going to explain and create in the next section.