Singleton

Warning
While Singletons are great, they're also highly controversial thanks to their abused use along the years. Consider using the Toolbox instead!

Introduction
"Why Singleton?", you may ask. First, then, what's a singleton? It is a design pattern that restricts the Instantiation of a class to one object. And, if you're here, you probably want to use that basically for implementing Global Variables. For any other usage, just take this as a starting place.

The advantage of using singletons, in Unity, rather than static parameters and methods, are basically:

(1) Static classes are lazy-loaded when they are first referenced, but must have an empty static constructor (or one is generated for you). This means it's easier to mess up and break code if you're not careful and know what you're doing. As for using the Singleton Pattern, you automatically already do lots of neat stuff, such as creating them with a static initialization method and making them immutable.

(2) Singleton can implement an interface (Static cannot). This allows you to build contracts that you can use for other Singleton objects or just any other class you want to throw around. In other words, you can have a game object with other components on it for better organization!

(3) You can also inherit from base classes which you can't do with Static classes.

P.S.: Unfortunately there is no good way to remove the need of a "Instance keyword" right there, calling the singleton.

P.S.(2): This is made as MonoBehaviour because we need Coroutines. A lot of times it makes sense to leave one in a singleton, so it will persist between scenes.

Usage Example
MyClass.cs

Manager.cs

Implementation
Singleton.cs

Requirement
MonoBehaviourExtended.cs (from GetOrAddComponent)