Advanced programming techniques
As part of this chapter, we start to go in depth with some advanced programming techniques. These enable us to structure our code better and add management to our game project instead of just adding game objects to the scene.
Singletons and managers
Any project of a sufficient size and complexity is going to run into issues related to managing your game objects as and when they are added and removed from a scene. If you don't get your design right from the start, you are setting yourself up for a world of mess later. A common way to handle this is to use one of the three patterns, single instance managers, singletons, or a dependency system, to manage these controllers for you.
There are two main ways through which you can implement the singleton pattern in Unity. The first way is to use a public static parameter within a class to maintain the runtime class. This also allows any other script to access it from anywhere in the game and is useful if you want other...