Main/Config/ConfigBase.cs
@@ -13,11 +13,7 @@
    public static T Get(U id)
    {
        if (!isInit)
        {
            Debug.LogError("ConfigBase 没有初始化");
            return null; // 或者抛出异常,视情况而定
        }
        LazyInit();
        if (dic.ContainsKey(id))
        {
@@ -34,11 +30,7 @@
    public static List<U> GetKeys()
    {
        if (!isInit)
        {
            Debug.LogError(typeof(U).Name + " 没有初始化 GetKeys");
            return null; // 或者抛出异常,视情况而定
        }
        LazyInit();
        List<U> result = new List<U>();
        result.AddRange(dic.Keys);
        return result;
@@ -47,11 +39,7 @@
    public static List<T> GetValues()
    {
        if (!isInit)
        {
            Debug.LogError(typeof(T).Name + " 没有初始化 GetValues");
            return null; // 或者抛出异常,视情况而定
        }
        LazyInit();
        List<T> result = new List<T>();
        result.AddRange(dic.Values);
        return result;
@@ -59,19 +47,24 @@
    public static bool HasKey(U key)
    {
        if (!isInit)
        {
            Debug.LogError(typeof(T).Name + " 没有初始化 HasKey");
            return false; // 或者抛出异常,视情况而定
        }
        LazyInit();
        return dic.ContainsKey(key);
    }
    public static void LazyInit()
    {
        if (!isInit)
        {
            //  实际上是同步的
            ConfigManager.Instance.LoadConfigByType(typeof(T));
        }
    }
    public static void Init(string[] lines)
    {
        dic.Clear();
        for (int i = 3; i < lines.Length; i++)
        {
            string line = lines[i];
@@ -86,18 +79,18 @@
            U key = config.LoadKey(strKey);
            config.LoadConfig(line);
            config.OnConfigParseCompleted();
            #if UNITY_EDITOR
#if UNITY_EDITOR
            try
            {
            #endif
            dic.Add(key, config);
            #if UNITY_EDITOR
#endif
                dic.Add(key, config);
#if UNITY_EDITOR
            }
            catch (ArgumentException exception)
            {
                Debug.LogError(typeof(T).Name  + " 重复的key " + key + " " + exception.Message);
                Debug.LogError(typeof(T).Name + " 重复的key " + key + " " + exception.Message);
            }
            #endif
#endif
        }
        foreach (var cfg in dic.Values)