浏览代码

Added TryGet to Manager API

/main
Thomas ICHÉ 4 年前
当前提交
8c4b1b89
共有 2 个文件被更改,包括 18 次插入0 次删除
  1. 6
      CHANGELOG.md
  2. 12
      Runtime/Managers/Manager.cs

6
CHANGELOG.md


# Changelog
## 2020.2.2
#### Added
* Added generic `bool Manager.TryGet<T>(out T manager)`
## 2020.2.1
#### Fixed

12
Runtime/Managers/Manager.cs


{
private static Dictionary<Type, Manager> s_Managers = new Dictionary<Type, Manager>();
public static bool TryGet<T>(out T manager) where T: Manager
{
manager = null;
if(s_Managers.ContainsKey(typeof(T)))
{
manager = (T)s_Managers[typeof(T)];
return true;
}
else
return false;
}
public static T Get<T>() where T: Manager
{
if(s_Managers.ContainsKey(typeof(T)))

正在加载...
取消
保存