using UnityEngine; public class SingletonBehaviour : MonoBehaviour where T : SingletonBehaviour { public static T Instance { get; private set; } protected virtual void Awake() { if (!Instance) Instance = this as T; else Destroy(gameObject); } }