Variables (C# and Unity)

James West
5 min readApr 1, 2021

In a previous article, we talked about the importance of avoiding magic numbers with variables and constants. Today we will dig deeper into variables how to use them. Before we dig in, it is important to understand that a philosophical debate about variables has been waged for years between purists and practical programmers. This article will not address those topics and instead will focus on how and when I use them. Also of importance is that the use of the term Global here is referring to a class-level variable.

Global (Class) vs Local

James West

Turning my passion for video games and 11 years of software development experience into a focus on video game development using Unity3D.