From 039569b2d4e9da11de0434f7b4b338c051ee5e15 Mon Sep 17 00:00:00 2001 From: ALEXTANG <574809918@qq.com> Date: Mon, 23 Oct 2023 10:15:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=85=8D=E7=BD=AE=E8=A1=A8?= =?UTF-8?q?=E5=8A=A0=E8=BD=BD=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 提交配置表加载模板 --- .../GameConfig/CustomTemplate/ConfigSystem.cs | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Configs/GameConfig/CustomTemplate/ConfigSystem.cs diff --git a/Configs/GameConfig/CustomTemplate/ConfigSystem.cs b/Configs/GameConfig/CustomTemplate/ConfigSystem.cs new file mode 100644 index 00000000..ebf1ba6f --- /dev/null +++ b/Configs/GameConfig/CustomTemplate/ConfigSystem.cs @@ -0,0 +1,49 @@ +using Luban; +using GameBase; +using GameConfig; +using TEngine; +using UnityEngine; + +/// +/// 配置加载器。 +/// +public class ConfigSystem : Singleton +{ + private bool _init = false; + + private Tables _tables; + + public Tables Tables + { + get + { + if (!_init) + { + Load(); + } + + return _tables; + } + } + + /// + /// 加载配置。 + /// + public void Load() + { + _tables = new Tables(LoadByteBuf); + _init = true; + } + + /// + /// 加载二进制配置。 + /// + /// FileName + /// ByteBuf + private ByteBuf LoadByteBuf(string file) + { + var textAssets = GameModule.Resource.LoadAsset(file); + byte[] ret = textAssets.bytes; + return new ByteBuf(ret); + } +} \ No newline at end of file