using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class SingletonMB : MonoBehaviour where T : class { protected static T s_Instance; public static T Instance { get { return s_Instance; } } protected virtual void Awake() { s_Instance = gameObject.GetComponent(typeof(T)) as T; } } public class Singleton where T : class, new() { private static T _instance; public static T Instance { get { if (_instance == null) _instance = Activator.CreateInstance(); return _instance; } } }