using UnityEngine; public class Singleton : MonoBehaviour where T : MonoBehaviour { private static T _inst; public static T Inst { get { return _inst; } } private void Awake() { _inst = this as T; } private void OnDisable() { _inst = null; } }