Variables! — The building blocks of programming

Richard Morgan
Apr 25, 2021

Creating variables is easy. There are 4 attributes that need to be addressed when creating variables:

#1 Will the variable be public or private? Public variables are accessible from other classes while private variables are not. In Unity, public variables are also exposed for manual overriding in the inspector. Note that private variables can be exposed using [SerializeField]:

#2 What data type will the variable be:
Integer = whole number
Float = decimal number
Boolean = true or false (1 or 0)
String = alphanumeric

#3 What is the name of the variable. Note that private variables conventially begin with _… for easy recognition.

#4 What value will the variable start off with. Note that variables are not required to be assigned starting values.

--

--