public static ISys Sys() { if (dalSys == null) { lock (lockSys)//考虑多线程安全 { if (dalSys == null) { dalSys = new Sys(); } } } return(dalSys); }
public T Sys <T>() where T : class, ISys { var type = typeof(T); ISys sys = default; if (!m_sysTab.ContainsKey(type)) { sys = Activator.CreateInstance <T>(); if (!m_sysTab.TryAdd(type, sys)) { Debug.LogError("[Main.Sys]添加失败"); } } else { if (!m_sysTab.TryGetValue(type, out sys)) { Debug.LogError("[Main.Sys]获取失败"); } } return(sys as T); }