using System.Collections; using System.Collections.Generic; using UnityEngine; public class MonoSingleton : MonoBehaviour where T : MonoBehaviour { private static T instance; public static T Instance { get { if (instance == null) { instance = FindObjectOfType(); } return instance; } } private void Awake() { if (instance != null) { Destroy(gameObject); } } }