This commit is contained in:
2025-11-12 07:04:31 +08:00
parent 33a4742904
commit f615d8ddb0
68 changed files with 1388 additions and 1478 deletions

View File

@@ -1,22 +1,25 @@
using UnityEngine;
public class Singleton<T> where T:class,new()
namespace Tuan.GameFramework
{
static T _inst;
static readonly object _lock = new object();
public static T Inst
public class Singleton<T> where T : class, new()
{
get
static T _inst;
static readonly object _lock = new object();
public static T Inst
{
lock (_lock)
get
{
if(_inst == null)
lock (_lock)
{
_inst = new T();
Debug.Log($"[Singleton] 创建 {typeof(T).Name} 实例");
if (_inst == null)
{
_inst = new T();
Debug.Log($"[Singleton] 创建 {typeof(T).Name} 实例");
}
return _inst;
}
return _inst;
}
}
}
}
}