using System.Collections; using System.Collections.Generic; using UnityEngine; public class MonoSingleton : MonoBehaviour where T : MonoSingleton { protected static T _instance = null; public static T Instance { get => _instance; private set => _instance = value; } protected void Awake() { if (Instance == null) { Instance = (T)this; //DontDestroyOnLoad(gameObject); } else { Destroy(gameObject); } } }