[new] 新增对团结引擎 HMIAndroid、OpenHarmony、WeixinMiniGame平台的支持

main
walon 2024-01-04 11:48:30 +08:00
parent ef103d8351
commit 2b42376505
3 changed files with 42 additions and 2 deletions

View File

@ -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();

View File

@ -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
}

View File

@ -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)