11
11
using GameFrameX . Runtime ;
12
12
using GameFrameX . UI . Runtime ;
13
13
using Hotfix . Config ;
14
+ using Hotfix . Config . item ;
14
15
using Hotfix . UI ;
16
+ #if ENABLE_BINARY_CONFIG
17
+ using LuBan . Runtime ;
18
+ #endif
15
19
16
20
namespace Hotfix
17
21
{
@@ -33,20 +37,46 @@ private static async void LoadUI()
33
37
#elif ENABLE_UI_UGUI
34
38
await GameApp . UI . OpenUIFormAsync < UILogin > ( Utility . Asset . Path . GetUIPath ( nameof ( UILogin ) ) , UIGroupConstants . Floor . Name ) ;
35
39
#endif
40
+
41
+ var item = GameApp . Config . GetConfig < TbSounds > ( ) . FirstOrDefault ;
42
+ Log . Info ( item ) ;
36
43
}
37
44
38
45
static async void LoadConfig ( )
39
46
{
40
47
var tablesComponent = new TablesComponent ( ) ;
41
48
tablesComponent . Init ( GameApp . Config ) ;
49
+ #if ENABLE_BINARY_CONFIG
50
+ // 使用二进制配置表
51
+ await tablesComponent . LoadAsync ( ConfigBufferLoader ) ;
52
+ #else
53
+ // 使用JSON配置表
42
54
await tablesComponent . LoadAsync ( ConfigLoader ) ;
55
+ #endif
43
56
}
44
57
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>
45
75
private static async Task < JSONNode > ConfigLoader ( string file )
46
76
{
47
77
var assetHandle = await GameApp . Asset . LoadAssetAsync < TextAsset > ( Utility . Asset . Path . GetConfigPath ( file , Utility . Const . FileNameSuffix . Json ) ) ;
48
-
49
78
return JSON . Parse ( assetHandle . GetAssetObject < TextAsset > ( ) . text ) ;
50
79
}
80
+ #endif
51
81
}
52
82
}
0 commit comments