1111using GameFrameX . Runtime ;
1212using GameFrameX . UI . Runtime ;
1313using Hotfix . Config ;
14+ using Hotfix . Config . item ;
1415using Hotfix . UI ;
16+ #if ENABLE_BINARY_CONFIG
17+ using LuBan . Runtime ;
18+ #endif
1519
1620namespace Hotfix
1721{
@@ -33,20 +37,46 @@ private static async void LoadUI()
3337#elif ENABLE_UI_UGUI
3438 await GameApp . UI . OpenUIFormAsync < UILogin > ( Utility . Asset . Path . GetUIPath ( nameof ( UILogin ) ) , UIGroupConstants . Floor . Name ) ;
3539#endif
40+
41+ var item = GameApp . Config . GetConfig < TbSounds > ( ) . FirstOrDefault ;
42+ Log . Info ( item ) ;
3643 }
3744
3845 static async void LoadConfig ( )
3946 {
4047 var tablesComponent = new TablesComponent ( ) ;
4148 tablesComponent . Init ( GameApp . Config ) ;
49+ #if ENABLE_BINARY_CONFIG
50+ // 使用二进制配置表
51+ await tablesComponent . LoadAsync ( ConfigBufferLoader ) ;
52+ #else
53+ // 使用JSON配置表
4254 await tablesComponent . LoadAsync ( ConfigLoader ) ;
55+ #endif
4356 }
4457
58+ #if ENABLE_BINARY_CONFIG
59+ /// <summary>
60+ /// 加载二进制配置表
61+ /// </summary>
62+ /// <param name="file"></param>
63+ /// <returns></returns>
64+ private static async Task < ByteBuf > ConfigBufferLoader ( string file )
65+ {
66+ var assetHandle = await GameApp . Asset . LoadAssetAsync < TextAsset > ( Utility . Asset . Path . GetConfigPath ( file , Utility . Const . FileNameSuffix . Binary ) ) ;
67+ return ByteBuf . Wrap ( assetHandle . GetAssetObject < TextAsset > ( ) . bytes ) ;
68+ }
69+ #else
70+ /// <summary>
71+ /// 加载json配置表
72+ /// </summary>
73+ /// <param name="file"></param>
74+ /// <returns></returns>
4575 private static async Task < JSONNode > ConfigLoader ( string file )
4676 {
4777 var assetHandle = await GameApp . Asset . LoadAssetAsync < TextAsset > ( Utility . Asset . Path . GetConfigPath ( file , Utility . Const . FileNameSuffix . Json ) ) ;
48-
4978 return JSON . Parse ( assetHandle . GetAssetObject < TextAsset > ( ) . text ) ;
5079 }
80+ #endif
5181 }
5282}
0 commit comments