1234567891011121314151617181920212223242526 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Singleton<T> where T : class , new()
- {
- private static readonly object _lock = new object();
- private static T _instance;
- public static T Instance
- {
- get
- {
- lock (_lock)
- {
- if (_instance == null)
- {
- _instance = new T();
- }
- }
- return _instance;
- }
- }
- }
|