using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BuildSystem { public class MonoSingleton : MonoBehaviour where T : MonoSingleton { private static T _instance; public static T Instance { get { return _instance; } } protected virtual void Awake() { if (_instance != null) { Destroy(_instance.gameObject); } _instance = this as T; } protected virtual void OnDestroy() { if (_instance == this) { _instance = null; } } } }