The Unity documentation it indicates that all public variables are made available in the inspector for direct editing. While this is handy, it is also dangerous. This article will cover a few things regarding public variables, and how to avoid them in Unity.
Tag Archive for Good Practice
While class is certainly important to have in real life, it is equally important to have while programming. Taking advantage of an Object Oriented Programming method (or OOP method) may very well be one of the most important higher concepts to learn and understand. This article helps cover what OOP is, its benefits, and how to use it.
To expand on my earlier post about enumerations I'm going to look at Finite State Machines in a relatively general sense. Let's start with breaking down what exactly a Finite State Machine is. We can look at the descriptive words to see that it is a machine, or system, that consists of a finite number of states. Great, but what does that mean? In a sense it is a way to package your code so only the desired pieces run at the desired time, this makes them very useful for succinct organization. In the rest of the article we'll look at different ways to implement the system, as well as the pros and cons of each.
Fans of Doctor Who will probably shun me for that titling. What are enumerators, or, more specifically,
enums? To put it succinctly, enums are words that are actually numbers. What does this mean? It means that when you write your code you can check for words, but when it gets compiled the compiler takes those words and replaces them with numbers. You may wonder why to bother with such a thing. It's pretty simple really. Enums allow you to have readable code while keeping a small overhead. They are better than character strings because they are smaller, and they are better than just plain integers because they can be rearranged, and are much more readable. Below is an example enum use: