Coding a Unity Project
Unity projects are usually about the game being created, and not the code used to control the game. The State Machine was the project for this book; not the actual game. The simple game was just a collection of examples to demonstrate coding to access some of Unity's features.
The point of this book is to teach the basics of programming using C#. The State Machine allowed me to teach you about C# classes that were not Unity scripts. As you learned, not all classes have to be a script attached to a GameObject. If a class doesn't use any of Unity's magic methods, such as Update()
and Start()
, and none of the variables need to appear in the Inspector panel, then you could just create a regular C# class instead of a Component script.
None of the State classes are Components so they don't have to inherit from MonoBehaviour
, yet they allow fine control of the game while organizing the code. Instead of having many large scripts with many if
-else
statements...