Class Singleton<T>
- Namespace
- GrindFest
- Assembly
- GrindFest.dll
public class Singleton<T> : MonoBehaviour where T : MonoBehaviour
Type Parameters
T
- Inheritance
-
objectSingleton<T>
- Derived
Fields
Properties
- Instance
The one instance: looked up in the loaded scenes, created if it is not there.
A manager wired up in the inspector (GameManager, SaveManager, PartyController, ...) is found by the lookup and nothing else happens. A manager that owns nothing but data (BotProfileStore) has no reason to live in a scene at all, so the first read builds its object instead. Either way
X.Instanceis never null in play mode and callers just use it - no null checks, and no per-class override duplicating this logic.Outside play mode a missing singleton still answers null: creating scene objects from an editor tick is what once left hundreds of stray GameObjects in the open scene.