using UnityEngine;
using System.Collections;
//单例模式
public class Singleton<T> where T : class, new()
{
protected static T _instance = null;
public static T Instance
{
get
{
if (_instance == null)
{
_instance = new T();
}
return _instance;
}
}
protected Singleton()
{
if (_instance != null)
{
Debug.Log("异常");
}
Init();
}
public virtual void Init()
{
}
}
时间: 2024-10-17 16:56:07