/// <summary> /// 获取非mono类的单例集合 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T Get <T>() where T : ISingleton, new() { Type type = typeof(T); if (!_dict.ContainsKey(type)) { _dict[type] = SingletonUtil.GetInstance(default(T)); } return((T)_dict[type]); }
/// <summary> /// Mono类的单例集合 /// </summary> /// <typeparam name="T"></typeparam> /// <returns></returns> public T GetMono <T>() where T : MonoBehaviour, ISingleton { Type type = typeof(T); if (!monoDict.ContainsKey(type) || monoDict[type] == null) { monoDict[type] = SingletonUtil.GetInstanceMono(default(T)).gameObject; } return(monoDict[type].GetComponent <T>()); }