Singleton.cs 320 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 using UnityEngine; public class Singleton<T> : MonoBehaviour where T : MonoBehaviour { private static T instance; public static T Instance { get { if (instance == null) instance = (T)FindObjectOfType(typeof(T)); return instance; } } }