Constants are "constantly" used in the Unity projects, they are working like the global config settings. Some features of the constants:
- Define only once
- Can't be changed
// define a constant variable in a class
public class Constants {
public const int LIVES = 3;
}
// use the constant
public class Player : MonoBehaviour
{
int lives;
void Awake()
{
lives = Constants.LIVES;
}
}