[TWLFramework] Singleton

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()
{


}


}

posted on 2016-08-18 19:59  tianjiuwan  阅读(124)  评论(0编辑  收藏  举报