lcy
6 天以前 3b2a6bb9047cfce9f501593b3669a9c1af6c5df4
Main/Config/ConfigBase.cs
@@ -7,12 +7,18 @@
public class ConfigBase<U, T> where T : ConfigBase<U, T>, new()
{
    /// <summary>
    /// 是否访问过静态构造函数
    /// </summary>
    public static bool visit = false;
    static ConfigBase()
    {
        if (isInit)
        {
            return;
        }
        LazyInit();
    }
@@ -38,11 +44,11 @@
        return null;
    }
    public static void ForceRelease()
    {
        m_dic.Clear();
        isInit = false;
    }
    // public static void ForceRelease()
    // {
    //     m_dic.Clear();
    //     isInit = false;
    // }
    public static List<U> GetKeys()
    {
@@ -81,38 +87,39 @@
        }
        for (int i = 3; i < lines.Length; i++)
        {
            string line = lines[i];
            var index = line.IndexOf("\t");
            if (index == -1)
            {
                string line = lines[i];
                var index = line.IndexOf("\t");
                if (index == -1)
                {
                    continue;
                }
                string strKey = line.Substring(0, index);
                T config = new T();
                U key = config.LoadKey(strKey);
                config.LoadConfig(line);
                config.OnConfigParseCompleted();
#if UNITY_EDITOR
                try
                {
#endif
                    m_dic.Add(key, config);
#if UNITY_EDITOR
                }
                catch (ArgumentException exception)
                {
                    Debug.LogError(typeof(T).Name + " 重复的key " + key + " " + exception.Message);
                }
#endif
                continue;
            }
        foreach (var cfg in m_dic.Values)
        {
            cfg.AllConfigLoadFinish();
            string strKey = line.Substring(0, index);
            T config = new T();
            U key = config.LoadKey(strKey);
            config.LoadConfig(line);
            config.OnConfigParseCompleted();
#if UNITY_EDITOR
            try
            {
#endif
                m_dic.Add(key, config);
#if UNITY_EDITOR
            }
            catch (ArgumentException exception)
            {
                Debug.LogError(typeof(T).Name + " 重复的key " + key + " " + exception.Message);
            }
#endif
        }
        // foreach (var cfg in m_dic.Values)
        // {
        //     cfg.AllConfigLoadFinish();
        // }
        isInit = true;
    }