using System; using UnityEngine; namespace _test.Singleton.MonoSingleton { public abstract class MonoSingleton : MonoBehaviour where T : MonoSingleton { public static T Instance { get; private set; } protected virtual void Awake() { if (Instance != null && Instance != this) { Destroy(gameObject); return; } Instance = (T)this; DontDestroyOnLoad(gameObject); } } }