| | |
| | | /// </summary>
|
| | | public static bool visit = false;
|
| | |
|
| | | static ConfigBase()
|
| | | {
|
| | | if (isInit)
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | LazyInit();
|
| | | }
|
| | | // 移除静态构造函数中的同步懒加载,禁止同步阻塞
|
| | | // static构造函数不再触发LazyInit
|
| | |
|
| | | private static Dictionary<U, T> m_dic = new Dictionary<U, T>();
|
| | |
|
| | |
| | | return m_dic.ContainsKey(key);
|
| | | }
|
| | |
|
| | | public static void LazyInit()
|
| | | // 异步懒加载入口
|
| | | public static async UniTask LazyInitAsync()
|
| | | {
|
| | | if (!isInit)
|
| | | {
|
| | | // 实际上是同步的
|
| | | ConfigManager.Instance.LoadConfigByType(typeof(T));
|
| | | await ConfigManager.Instance.LoadConfigByTypeAsync(typeof(T));
|
| | | }
|
| | | }
|
| | |
|
| | | // 同步初始化
|
| | | public static void Init(string[] lines)
|
| | | {
|
| | | if (isInit)
|
| | |
| | | #endif
|
| | | }
|
| | |
|
| | | |
| | | // foreach (var cfg in m_dic.Values)
|
| | | // {
|
| | | // cfg.AllConfigLoadFinish();
|
| | | // }
|
| | | // Debug.LogError("config " + typeof(T).Name + " load finish! total count:" + m_dic.Count);
|
| | |
|
| | | isInit = true;
|
| | | }
|