2024-05-01 00:28:48 +08:00
|
|
|
using System.Collections;
|
2024-04-30 17:39:50 +08:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class Singleton<T> where T : new()
|
|
|
|
{
|
|
|
|
private static T _instance;
|
|
|
|
private static readonly object objlock = new object();
|
|
|
|
public static T Instance
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
|
|
|
if (_instance == null)
|
|
|
|
{
|
|
|
|
lock (objlock)
|
|
|
|
{
|
|
|
|
if (_instance == null)
|
|
|
|
{
|
|
|
|
_instance = new T();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return _instance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|