From be4d220529b2129d611f5ac9a63d7fb838a3b022 Mon Sep 17 00:00:00 2001 From: walon Date: Tue, 18 Oct 2022 13:48:43 +0800 Subject: [PATCH] =?UTF-8?q?[new]=20HybridCLRSettings=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=20preserveHotUpdateAssemblies=E5=AD=97=E6=AE=B5=EF=BC=8C?= =?UTF-8?q?=E7=94=A8=E4=BA=8E=E9=A2=84=E7=95=99assembly?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatchScriptingAssemblyList.cs | 6 ++--- Editor/Settings/HybridCLRSettingProvider.cs | 3 +++ Editor/Settings/HybridCLRSettings.cs | 3 +++ Editor/SettingsUtil.cs | 24 +++++++++++++++++++ package.json | 2 +- 5 files changed, 34 insertions(+), 4 deletions(-) diff --git a/Editor/BuildProcessors/PatchScriptingAssemblyList.cs b/Editor/BuildProcessors/PatchScriptingAssemblyList.cs index 107cc8d..21269db 100644 --- a/Editor/BuildProcessors/PatchScriptingAssemblyList.cs +++ b/Editor/BuildProcessors/PatchScriptingAssemblyList.cs @@ -89,7 +89,7 @@ namespace HybridCLR.Editor.BuildProcessors { var patcher = new ScriptingAssembliesJsonPatcher(); patcher.Load(file); - patcher.AddScriptingAssemblies(SettingsUtil.HotUpdateAssemblyFiles); + patcher.AddScriptingAssemblies(SettingsUtil.PatchingHotUpdateAssemblyFiles); patcher.Save(file); } } @@ -120,7 +120,7 @@ namespace HybridCLR.Editor.BuildProcessors { var binFile = new UnityBinFile(); binFile.Load(binPath); - binFile.AddScriptingAssemblies(SettingsUtil.HotUpdateAssemblyFiles); + binFile.AddScriptingAssemblies(SettingsUtil.PatchingHotUpdateAssemblyFiles); binFile.Save(binPath); Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}"); } @@ -139,7 +139,7 @@ namespace HybridCLR.Editor.BuildProcessors foreach (string binPath in binFiles) { var patcher = new Dataunity3dPatcher(); - patcher.ApplyPatch(binPath, SettingsUtil.HotUpdateAssemblyFiles); + patcher.ApplyPatch(binPath, SettingsUtil.PatchingHotUpdateAssemblyFiles); Debug.Log($"[PatchScriptingAssemblyList] patch {binPath}"); } return true; diff --git a/Editor/Settings/HybridCLRSettingProvider.cs b/Editor/Settings/HybridCLRSettingProvider.cs index 7752b9d..2d6bb7d 100644 --- a/Editor/Settings/HybridCLRSettingProvider.cs +++ b/Editor/Settings/HybridCLRSettingProvider.cs @@ -14,6 +14,7 @@ namespace HybridCLR.Editor private SerializedProperty m_CloneFromGitee; private SerializedProperty m_HotUpdateAssemblyDefinitions; private SerializedProperty m_HotUpdateAssemblies; + private SerializedProperty m_preserveHotUpdateAssemblies; private SerializedProperty m_collectAssetReferenceTypes; private SerializedProperty m_OutputLinkFile; private SerializedProperty m_OutputAOTGenericReferenceFile; @@ -32,6 +33,7 @@ namespace HybridCLR.Editor m_CloneFromGitee = m_SerializedObject.FindProperty("cloneFromGitee"); m_HotUpdateAssemblyDefinitions = m_SerializedObject.FindProperty("hotUpdateAssemblyDefinitions"); m_HotUpdateAssemblies = m_SerializedObject.FindProperty("hotUpdateAssemblies"); + m_preserveHotUpdateAssemblies = m_SerializedObject.FindProperty("preserveHotUpdateAssemblies"); m_collectAssetReferenceTypes = m_SerializedObject.FindProperty("collectAssetReferenceTypes"); m_OutputLinkFile = m_SerializedObject.FindProperty("outputLinkFile"); m_OutputAOTGenericReferenceFile = m_SerializedObject.FindProperty("outputAOTGenericReferenceFile"); @@ -104,6 +106,7 @@ namespace HybridCLR.Editor EditorGUILayout.PropertyField(m_UseGlobalIl2cpp); EditorGUILayout.PropertyField(m_HotUpdateAssemblyDefinitions); EditorGUILayout.PropertyField(m_HotUpdateAssemblies); + EditorGUILayout.PropertyField(m_preserveHotUpdateAssemblies); EditorGUILayout.PropertyField(m_collectAssetReferenceTypes); EditorGUILayout.PropertyField(m_OutputLinkFile); EditorGUILayout.PropertyField(m_OutputAOTGenericReferenceFile); diff --git a/Editor/Settings/HybridCLRSettings.cs b/Editor/Settings/HybridCLRSettings.cs index c874bb9..afd345f 100644 --- a/Editor/Settings/HybridCLRSettings.cs +++ b/Editor/Settings/HybridCLRSettings.cs @@ -20,6 +20,9 @@ namespace HybridCLR.Editor [Header("热更新dlls")] public string[] hotUpdateAssemblies; + [Header("预留的热更新dlls")] + public string[] preserveHotUpdateAssemblies; + [Header("生成link.xml时扫描asset中引用的类型")] public bool collectAssetReferenceTypes; diff --git a/Editor/SettingsUtil.cs b/Editor/SettingsUtil.cs index c1869f1..38c18fd 100644 --- a/Editor/SettingsUtil.cs +++ b/Editor/SettingsUtil.cs @@ -75,8 +75,32 @@ namespace HybridCLR.Editor return hotfixAssembles.ToList(); } } + public static List HotUpdateAssemblyFiles => HotUpdateAssemblyNames.Select(dll => dll + ".dll").ToList(); + public static List PatchingHotUpdateAssemblyFiles + { + get + { + List patchingList = HotUpdateAssemblyFiles; + string[] preserveAssemblyNames = HybridCLRSettings.Instance.preserveHotUpdateAssemblies; + if (preserveAssemblyNames != null && preserveAssemblyNames.Length > 0) + { + foreach(var assemblyName in preserveAssemblyNames) + { + string dllFileName = assemblyName + ".dll"; + if (patchingList.Contains(dllFileName)) + { + throw new Exception($"[PatchingHotUpdateAssemblyFiles] assembly:'{assemblyName}' 重复"); + } + patchingList.Add(dllFileName); + } + } + + return patchingList; + } + } + public static HybridCLRSettings HybridCLRSettings => HybridCLRSettings.Instance; } } diff --git a/package.json b/package.json index 8e10f98..9df3082 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.focus-creative-games.hybridclr_unity", - "version": "0.5.2", + "version": "0.6.0", "displayName": "HybridCLR", "description": "Unity package for HybridCLR. It includes editor and runtime scripts and assets for HybridCLR", "category": "Runtime",