using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public abstract class SingletoneMonoBehaviour<T> : MonoBehaviour where T: MonoBehaviour {
    private static T instance;

    private static T Instance { get { return GetInstance(); } }

    public static T GetInstance() {
        if (instance == null) {
            instance = FindObjectOfType<T>();
            if (instance == null) {
                instance = Utils.Create<T>(typeof(T).Name);
                DontDestroyOnLoad(instance.gameObject);
            }
        }
        return instance;
    }
}