UnitySingleton
UnitySingleton copied to clipboard
The best way to implement singleton pattern in Unity.
```c# protected virtual void Awake() { if (_instance == null) { _instance = this as T; DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } ``` The `Awake()` function is the key...
Thanks for the code, I believe it could be further enhanced to support editor mode, like the following: ``` using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using UnityEngine; namespace Z { [PublicAPI] [ExecuteAlways]...
Add Unity Package Manager setup instructions and include package.json file.
Hi, whenever I enter play mode and any of my script is trying to call something from singletons, whole unity crashes without any error log. Is there any limitations which...