using System.Collections; using System.Collections.Generic; using UnityEngine; using System; public class Singleton where T : class, new() { private static readonly Lazy instance = new Lazy(() => new T(), true); public static T Instance => instance.Value; protected Singleton() { if (instance.IsValueCreated) { throw new InvalidOperationException("Singleton instance already created."); } } }