using Luban; using GameConfig; using TEngine; using UnityEngine; /// /// 配置加载器。 /// public class ConfigSystem { private static ConfigSystem _instance; public static ConfigSystem Instance => _instance ??= new ConfigSystem(); private bool _init = false; private Tables _tables; public Tables Tables { get { if (!_init) { Load(); } return _tables; } } private IResourceModule _resourceModule; /// /// 加载配置。 /// public void Load() { _tables = new Tables(LoadByteBuf); _init = true; } /// /// 加载二进制配置。 /// /// FileName /// ByteBuf private ByteBuf LoadByteBuf(string file) { if (_resourceModule == null) { _resourceModule = ModuleSystem.GetModule(); } TextAsset textAsset = _resourceModule.LoadAsset(file); byte[] bytes = textAsset.bytes; return new ByteBuf(bytes); } }