Unity’s Programming Language

C# (pronounced C sharp) is a widely used object-oriented programming language developed by Microsoft, first introduced in 2000 as part of the .NET framework. C# provides a powerful and flexible platform for building a wide range of applications, including the game engine Unity.

C# is based on object-oriented programming (OOP). Objects are instances of classes that encapsulate data and behavior. C# allows you to define classes, create objects from those classes, and interact with them to build complex systems.

If you have taken Java, you will find that it is very similar to C#. An example is that both language require that variable types must be explicitly declared and enforced during compilation. They also follow similar syntax and have comparable features like classes, inheritance, and polymorphism. This means that transitioning to C# is relatively smooth. However, it's worth noting that C# has its own unique features and libraries that differentiate it from Java.

If you haven’t taken Java that is fine. You do not need to be completely fluent in C# to develop a game. We will also be presenting C# code every step of this course. This course focuses on C# for only a few days.

Now let’s review some of the topics that one may need when programming their first game.

Objects

Inheritance

If-Statements

In programming, the If-statement is a fundamental control structure that allows you to execute code based on a certain condition. It enables your program to make decisions and perform different actions depending on whether a condition is true or false.

The syntax of an If-statement in C# is as follows:

if (condition)
{
    //Code to execute if the condition is true
}

Here's a breakdown of the components: