namespace Plugins.JNGame.Util
{
    public abstract class SingletonUtil<T> where T : Singleton<T>,new() {

        public static T Instance{
            get{
                if (Singleton<T>.ins == null)
                {
                    Singleton<T>.ins = new T();
                    Singleton<T>.ins.Init();
                }
                return Singleton<T>.ins;
            }
        }

        public static void Clean()
        {
            if(Singleton<T>.ins != null)
                Singleton<T>.ins.Clean();
            Singleton<T>.ins = null;
        }

    }

    public class Singleton<T> {

        public static T ins;

        public virtual void Init(){}
        public virtual void Clean(){}

    }
}