using System.Collections; using System.Collections.Generic; using UnityEngine; public abstract class MonoSingleton : MonoBehaviour where T : MonoBehaviour { private static T instance = null; public static T GetInstance() { if (null == instance) { instance = FindObjectOfType(typeof(T)) as T; if (instance == null) { instance = new GameObject(typeof(T).ToString() + "Obj", typeof(T)).GetComponent(); } } return instance; } public virtual void InitManager() { } }