using UnityEngine;
public class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
    private static T instance = null;

    public static T Instance
    {
        get
        {
            if (instance == null)
                instance = FindFirstObjectByType(typeof(T)) as T;
            return instance;
        }
    }
}
