mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
27 lines
547 B
C#
27 lines
547 B
C#
using TEngine;
|
|
|
|
namespace GameBase
|
|
{
|
|
/// <summary>
|
|
/// 通用单例。
|
|
/// </summary>
|
|
/// <typeparam name="T">泛型T。</typeparam>
|
|
public class Singleton<T> where T : new()
|
|
{
|
|
private static T _instance;
|
|
|
|
public static T Instance
|
|
{
|
|
get
|
|
{
|
|
if (null == _instance)
|
|
{
|
|
_instance = new T();
|
|
Log.Assert(_instance != null);
|
|
}
|
|
|
|
return _instance;
|
|
}
|
|
}
|
|
}
|
|
} |