浏览代码

修改配置文件(Hybrid AOT dll列表)加入热更新套餐

大爷 2 年之前
父节点
当前提交
7f29b3d9a7

+ 2 - 2
Unity/Assets/AssetBundleCollectorSetting.asset

@@ -32,9 +32,9 @@ MonoBehaviour:
     AssetTags: 
     ActiveRuleName: EnableGroup
     Collectors:
-    - CollectPath: Assets/Res/Config
+    - CollectPath: Assets/Res/Config/HotUpdateAssemblyManifest.asset
       CollectorType: 0
-      AddressRuleName: AddressByGroupAndFileName
+      AddressRuleName: AddressByFileName
       PackRuleName: PackDirectory
       FilterRuleName: CollectAll
       AssetTags: 

+ 1 - 9
Unity/Assets/Resources/HotUpdateAssemblyManifest.asset → Unity/Assets/Res/Config/HotUpdateAssemblyManifest.asset

@@ -10,7 +10,7 @@ MonoBehaviour:
   m_Enabled: 1
   m_EditorHideFlags: 0
   m_Script: {fileID: 11500000, guid: 59f9ce34f47e4ed4827c54fe59e948d5, type: 3}
-  m_Name: HotUpdateAssemblyManifest
+  m_Name: Assets/Res/Config/HotUpdateAssemblyManifest.asset
   m_EditorClassIdentifier: 
   AOTMetadataDlls:
   - System.dll
@@ -20,11 +20,3 @@ MonoBehaviour:
   - System.Core.dll
   - Sirenix.Serialization.dll
   - UniTask.dll
-  DLLNameList_ForABLoad:
-  - System.dll.bytes
-  - Unity.Core.dll.bytes
-  - Unity.ThirdParty.dll.bytes
-  - mscorlib.dll.bytes
-  - System.Core.dll.bytes
-  - Sirenix.Serialization.dll.bytes
-  - UniTask.dll.bytes

+ 0 - 0
Unity/Assets/Resources/HotUpdateAssemblyManifest.asset.meta → Unity/Assets/Res/Config/HotUpdateAssemblyManifest.asset.meta


+ 2 - 3
Unity/Assets/Scripts/Editor/HybridCLR/AssetBundleBuildCommand.cs

@@ -20,8 +20,6 @@ namespace HybridCLR.Editor
 
         public static string AssetBundleSourceDataTempDir => $"{HybridCLRBuildCacheDir}/AssetBundleSourceData";
 
-        public static HotUpdateAssemblyManifest HotUpdateManifest => Resources.Load<HotUpdateAssemblyManifest>("HotUpdateAssemblyManifest");
-
         public static string GetAssetBundleOutputDirByTarget(BuildTarget target)
         {
             return $"{AssetBundleOutputDir}/{target}";
@@ -79,7 +77,8 @@ namespace HybridCLR.Editor
 
             //step 4
             string aotDllDir = SettingsUtil.GetAssembliesPostIl2CppStripDir(target);
-            HotUpdateAssemblyManifest manifest = HotUpdateManifest;
+
+            HotUpdateAssemblyManifest manifest = AssetDatabase.LoadAssetAtPath("Assets/Res/Config/HotUpdateAssemblyManifest.asset", typeof(HotUpdateAssemblyManifest)) as HotUpdateAssemblyManifest;
             if (manifest == null)
             {
                 throw new Exception($"resource asset:{nameof(HotUpdateAssemblyManifest)} 配置不存在,请在Resources目录下创建");

+ 9 - 4
Unity/Assets/Scripts/Loader/CodeLoader.cs

@@ -59,8 +59,11 @@ namespace ET
 
         private async UniTaskVoid AsyncLoadHotfix()
         {
+            GlobalConfig globalConfig = Resources.Load<GlobalConfig>("GlobalConfig");
+            Log.Info($"start mode: {globalConfig.PlayMode}");
+
             // 启动YooAsset引擎,并在初始化完毕后进行热更代码加载
-            await YooAssetProxy.StartYooAssetEngine(YooAssets.EPlayMode.HostPlayMode);
+            await YooAssetProxy.StartYooAssetEngine(globalConfig.PlayMode);
 
             // Shader Warm Up
             ShaderVariantCollection shaderVariantCollection =
@@ -78,12 +81,14 @@ namespace ET
             await LoadHotfixCode();
         }
 
-        //TODO: AOT dll列表的配置也可以通过热更新下下来,这样增加了新的泛型就不怕了
 		// 加载assembly对应的dll,会自动为它hook。一旦aot泛型函数的native函数不存在,用解释器版本代码
 		private async UniTask LoadMetadataForAOT()
 		{
-            HotUpdateAssemblyManifest aotlist = Resources.Load<HotUpdateAssemblyManifest>("HotUpdateAssemblyManifest");
-            var DLLNameList_ForABLoad = aotlist.AOTMetadataDlls;
+            //AOT dll列表的配置也可以通过热更新下下来,这样增加了新的泛型就不怕了
+            HotUpdateAssemblyManifest mainfest =
+                (await YooAssetProxy.LoadAssetAsync<HotUpdateAssemblyManifest>("HotUpdateAssemblyManifest"))
+                .GetAssetObject<HotUpdateAssemblyManifest>();
+            var DLLNameList_ForABLoad = mainfest.AOTMetadataDlls;
 
 			List<UniTask<RawFileOperation>> tasks = new List<UniTask<RawFileOperation>>();
             foreach (var aotDll in DLLNameList_ForABLoad)

+ 0 - 6
Unity/Assets/Scripts/Loader/MonoBehaviour/HotUpdateAssemblyManifest.cs

@@ -14,10 +14,4 @@ public class HotUpdateAssemblyManifest : ScriptableObject
         "System.Core.dll",
         "Sirenix.Serialization.dll",
         "UniTask.dll"};
-
-
-    [Header("通过YooAsset处理过后的列表名称")]
-    public string[] DLLNameList_ForABLoad = new string[]
-    {
-    };
 }