Programming C# in Unity
Franz Lanzinger · 2020
This chapter covers the basics of programming C# in Unity. The Unity projects explore some C# programming features as well as how to use them in Unity. Color-coding the C# code in Visual Studio is a useful automatic feature to help programmers make sense of it all and to help prevent bugs. Unity is designed to create animations on the various supported target devices. Each frame is a graphic image designed to be displayed quickly. Unity renders frames at a target framerate. The chapter explores the basic math operators in C#: addition, subtraction, multiplication, division, modulus, increment, and decrement. It also explores the bitwise operators including AND, OR, XOR, Complement, and the Shifts. Booleans, characters, strings, and arrays are all used extensively in game development. The chapter discusses how to control the flow of the code using two kinds of selection statements: if and switch. The easiest is with the “if” statement.