Example #1
0
    public void LoadConfig(System.Action onCompalte)
    {
        num = 0;
        string[] keyList = new string[configDic.Keys.Count];
        configDic.Keys.CopyTo(keyList, 0);
        foreach (string key in keyList)
        {
            AssetBundleLoadManager.Instance.LoadAsset <Object>(FilePathTools.getConfigPath(key), (data) =>
            {
                string k    = keyList[num];
                Type type   = configDic[k];
                string json = data.ToString();

                MethodInfo mi            = GetGenericMethod(typeof(JsonMapper), "ToObject", BindingFlags.Public | BindingFlags.Static, typeof(string));
                MethodInfo miConstructed = mi.MakeGenericMethod(type);
                object obj = miConstructed.Invoke(null, new object[] { json });

                this.GetType().GetField(key).SetValue(this, obj);

                num++;
                if (num >= keyList.Length)
                {
                    onCompalte();
                }
            });
        }
    }