using System.IO;
using System.Net.Mime;
using Luban;
using UnityEngine;
namespace CreatGame
{
///
/// 表格
///
public class ConfigManager : Singleton
{
///
///
///
private readonly cfg.Tables tables;
///
///
///
public cfg.Tables Tables => tables;
public ConfigManager()
{
var tablesCtor = typeof(cfg.Tables).GetConstructors()[0];
// 根据cfg.Tables的构造函数的Loader的返回值类型决定使用json还是ByteBuf Loader
System.Delegate loader = new System.Func(LoadByteBuf);
tables = (cfg.Tables)tablesCtor.Invoke(new object[] {loader});
}
private static ByteBuf LoadByteBuf(string file)
{
return new ByteBuf(File.ReadAllBytes($"{Application.dataPath}/AssetBundle/Config/{file}.bytes"));
}
}
}