Rawrshak_Unity-Asset-Viewer-Project/Assets/Rawrshak/Src/Utils/Singleton.cs
using UnityEngine;

/// <summary>
/// Abstract class for making reload-proof singletons out of ScriptableObjects
/// Returns the asset created on the editor, or null if there is none
/// Based on https://www.youtube.com/watch?v=VBA1QCoEAX4
/// </summary>
/// <typeparam name="T">Singleton type</typeparam>

public abstract class SingletonScriptableObject<T> : ScriptableObject where T : ScriptableObject {
    static T _instance = null;
    public static T Instance
    {
        get
        {
            if (!_instance)
                _instance = FindObjectOfType<T>();
            if (!_instance)
                _instance = ScriptableObject.CreateInstance<T>();
            return _instance;
        }
    }
}