1- using System ;
1+ using GameFrameX . Runtime ;
2+ #if ENABLE_GAME_FRAME_X_HYBRID_CLR && ! DISABLE_HYBRIDCLR
3+ using System ;
24using System . Reflection ;
3- using GameFrameX . Runtime ;
4- #if ENABLE_GAME_FRAME_X_HYBRID_CLR
55using System . Linq ;
66using HybridCLR ;
77#endif
@@ -10,10 +10,16 @@ namespace Unity.Startup.Procedure
1010{
1111 public static class HotfixHelper
1212 {
13+ #if ( ENABLE_GAME_FRAME_X_HYBRID_CLR && ! DISABLE_HYBRIDCLR )
1314 const string HotfixName = "Unity.Hotfix" ;
14-
15- public static async void StartHotfix ( )
15+ #endif
16+ public static
17+ #if ENABLE_GAME_FRAME_X_HYBRID_CLR && ! DISABLE_HYBRIDCLR
18+ async
19+ #endif
20+ void StartHotfix ( )
1621 {
22+ #if ENABLE_GAME_FRAME_X_HYBRID_CLR && ! DISABLE_HYBRIDCLR
1723 if ( ApplicationHelper . IsEditor )
1824 {
1925 var assemblies = Utility . Assembly . GetAssemblies ( ) ;
@@ -29,7 +35,6 @@ public static async void StartHotfix()
2935 return ;
3036 }
3137
32- #if ENABLE_GAME_FRAME_X_HYBRID_CLR
3338 Log . Info ( "开始加载AOT DLL" ) ;
3439 var aotDlls = AOTGenericReferences . PatchedAOTAssemblyList . ToArray ( ) ;
3540 foreach ( var aotDll in aotDlls )
@@ -39,17 +44,21 @@ public static async void StartHotfix()
3944 var aotBytes = assetHandle . GetAssetObject < UnityEngine . TextAsset > ( ) . bytes ;
4045 RuntimeApi . LoadMetadataForAOTAssembly ( aotBytes , HomologousImageMode . SuperSet ) ;
4146 }
47+
4248 Log . Info ( "结束加载AOT DLL" ) ;
43- #endif
4449 Log . Info ( "开始加载Unity.Hotfix.dll" ) ;
4550 var assetHotfixDllPath = Utility . Asset . Path . GetCodePath ( HotfixName + Utility . Const . FileNameSuffix . DLL ) ;
4651 var assetHotfixDllOperationHandle = await GameApp . Asset . LoadAssetAsync < UnityEngine . Object > ( assetHotfixDllPath ) ;
4752 var assemblyDataHotfixDll = assetHotfixDllOperationHandle . GetAssetObject < UnityEngine . TextAsset > ( ) . bytes ;
4853 Log . Info ( "开始加载程序集Hotfix" ) ;
4954 var hotfixAssembly = Assembly . Load ( assemblyDataHotfixDll , null ) ;
5055 Run ( hotfixAssembly ) ;
51- }
5256
57+ #else
58+ RunNative ( ) ;
59+ #endif
60+ }
61+ #if ENABLE_GAME_FRAME_X_HYBRID_CLR && ! DISABLE_HYBRIDCLR
5362 private static void Run ( Assembly assembly )
5463 {
5564 Log . Info ( "加载程序集Hotfix 结束 Assembly " + assembly . FullName ) ;
@@ -59,5 +68,15 @@ private static void Run(Assembly assembly)
5968 Log . Info ( "加载程序集Hotfix 结束 EntryType=>method " + method ? . Name ) ;
6069 method ? . Invoke ( null , null ) ;
6170 }
71+ #else
72+ private static void RunNative ( )
73+ {
74+ var entryType = Utility . Assembly . GetType ( "Hotfix.HotfixLauncher" ) ;
75+ Log . Info ( "加载程序集Hotfix 结束 EntryType " + entryType . FullName ) ;
76+ var method = entryType . GetMethod ( "Main" ) ;
77+ Log . Info ( "加载程序集Hotfix 结束 EntryType=>method " + method ? . Name ) ;
78+ method ? . Invoke ( null , null ) ;
79+ }
80+ #endif
6281 }
6382}
0 commit comments