/// <summary> /// Deserilize all config data ,load to memory /// You should do this once when loading the game /// </summary> public static void LoadAllConfigData() { TextAsset[] assets = Resources.LoadAll <TextAsset>("ConfigData/"); foreach (TextAsset asset in assets) { //get proto class by reflection string name = asset.name.ToUpper(); Type type = Type.GetType("com.nkm.framework.resource.data." + name + "_ARRAY"); if (type == null) { continue; } //decompress binary data byte[] zlibData = new byte[asset.bytes.Length - 8]; Array.Copy(asset.bytes, 8, zlibData, 0, zlibData.Length); byte[] deCompressedData = CompressionUtil.DecompressZLIB(zlibData); //deserialize decompressed binary object resClass = type.GetMethod("ParseFrom", BindingFlags.Static | BindingFlags.Public, null, new[] { typeof(byte[]) }, null).Invoke(null, new object[] { deCompressedData }); ParseData(name, resClass); } }