标签:
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()
{
}
}
标签:
原文地址:http://www.cnblogs.com/cocotang/p/5785185.html