From 2b4237650573bcddc6a98c02d7d992ce10ea08c5 Mon Sep 17 00:00:00 2001 From: walon Date: Thu, 4 Jan 2024 11:48:30 +0800 Subject: [PATCH] =?UTF-8?q?[new]=20=E6=96=B0=E5=A2=9E=E5=AF=B9=E5=9B=A2?= =?UTF-8?q?=E7=BB=93=E5=BC=95=E6=93=8E=20HMIAndroid=E3=80=81OpenHarmony?= =?UTF-8?q?=E3=80=81WeixinMiniGame=E5=B9=B3=E5=8F=B0=E7=9A=84=E6=94=AF?= =?UTF-8?q?=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PatchScriptingAssembliesJsonHook.cs | 8 ++++++- .../PatchScriptingAssemblyList.cs | 13 ++++++++++- Editor/Commands/StripAOTDllCommand.cs | 23 +++++++++++++++++++ 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Editor/3rds/UnityHook/HybridCLRHooks/PatchScriptingAssembliesJsonHook.cs b/Editor/3rds/UnityHook/HybridCLRHooks/PatchScriptingAssembliesJsonHook.cs index 169d766..4ba6b6c 100644 --- a/Editor/3rds/UnityHook/HybridCLRHooks/PatchScriptingAssembliesJsonHook.cs +++ b/Editor/3rds/UnityHook/HybridCLRHooks/PatchScriptingAssembliesJsonHook.cs @@ -12,7 +12,7 @@ using System.IO; namespace HybridCLR.MonoHook { -#if UNITY_2021_1_OR_NEWER && UNITY_WEBGL +#if (UNITY_2021_1_OR_NEWER && UNITY_WEBGL) || TUANJIE_2022 [InitializeOnLoad] public class PatchScriptingAssembliesJsonHook { @@ -36,6 +36,12 @@ namespace HybridCLR.MonoHook private static string BuildMainWindowTitle() { string tempJsonPath = $"{Application.dataPath}/../Library/PlayerDataCache/WebGL/Data/ScriptingAssemblies.json"; +#if TUANJIE_2022 + if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.WeixinMiniGame) + { + tempJsonPath = $"{Application.dataPath}/../Library/PlayerDataCache/WeixinMiniGame/Data/ScriptingAssemblies.json"; + } +#endif if (File.Exists(tempJsonPath)) { var patcher = new PatchScriptingAssemblyList(); diff --git a/Editor/BuildProcessors/PatchScriptingAssemblyList.cs b/Editor/BuildProcessors/PatchScriptingAssemblyList.cs index ee21b9b..f0f1f51 100644 --- a/Editor/BuildProcessors/PatchScriptingAssemblyList.cs +++ b/Editor/BuildProcessors/PatchScriptingAssemblyList.cs @@ -17,6 +17,8 @@ namespace HybridCLR.Editor.BuildProcessors public class PatchScriptingAssemblyList : #if UNITY_ANDROID IPostGenerateGradleAndroidProject, +#elif UNITY_OPENHARMONY + UnityEditor.OpenHarmony.IPostGenerateOpenHarmonyProject, #endif IPostprocessBuildWithReport #if !UNITY_2021_1_OR_NEWER && UNITY_WEBGL @@ -45,11 +47,20 @@ namespace HybridCLR.Editor.BuildProcessors } } +#if UNITY_OPENHARMONY + + public void OnPostGenerateOpenHarmonyProject(string path) + { + OnPostGenerateGradleAndroidProject(path); + } + +#endif + public void OnPostprocessBuild(BuildReport report) { // 如果target为Android,由于已经在OnPostGenerateGradelAndroidProject中处理过, // 这里不再重复处理 -#if !UNITY_ANDROID && !UNITY_WEBGL +#if !UNITY_ANDROID && !UNITY_WEBGL && !UNITY_OPENHARMONY PathScriptingAssembilesFile(report.summary.outputPath); #endif } diff --git a/Editor/Commands/StripAOTDllCommand.cs b/Editor/Commands/StripAOTDllCommand.cs index f340c1e..517f64a 100644 --- a/Editor/Commands/StripAOTDllCommand.cs +++ b/Editor/Commands/StripAOTDllCommand.cs @@ -80,6 +80,9 @@ namespace HybridCLR.Editor.Commands bool oldCreateSolution = UnityEditor.OSXStandalone.UserBuildSettings.createXcodeProject; #elif UNITY_EDITOR_WIN bool oldCreateSolution = UnityEditor.WindowsStandalone.UserBuildSettings.createSolution; +#endif +#if TUANJIE_2022 + bool oldOpenHarmonyProj = EditorUserBuildSettings.exportAsOpenHarmonyProject; #endif bool oldBuildScriptsOnly = EditorUserBuildSettings.buildScriptsOnly; EditorUserBuildSettings.buildScriptsOnly = true; @@ -105,11 +108,21 @@ namespace HybridCLR.Editor.Commands #endif break; } +#if TUANJIE_2022 + case BuildTarget.HMIAndroid: +#endif case BuildTarget.Android: { EditorUserBuildSettings.exportAsGoogleAndroidProject = true; break; } +#if TUANJIE_2022 + case BuildTarget.OpenHarmony: + { + EditorUserBuildSettings.exportAsOpenHarmonyProject = true; + break; + } +#endif } Debug.Log($"GenerateStripedAOTDlls build option:{buildOptions}"); @@ -145,11 +158,21 @@ namespace HybridCLR.Editor.Commands #endif break; } +#if TUANJIE_2022 + case BuildTarget.HMIAndroid: +#endif case BuildTarget.Android: { EditorUserBuildSettings.exportAsGoogleAndroidProject = oldExportAndroidProj; break; } +#if TUANJIE_2022 + case BuildTarget.OpenHarmony: + { + EditorUserBuildSettings.exportAsOpenHarmonyProject = oldOpenHarmonyProj; + break; + } +#endif } if (report.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)