using UnityEngine; namespace Utils { public class MonoSingleton : MonoBehaviour where T : MonoSingleton { private static T _instance; public static T Instance { get { if (_instance == null) { var gobj = new GameObject(typeof(T).ToString()); _instance = gobj.AddComponent(); _instance.Init(); } return _instance; } } protected virtual void Init() { } } }