[fix] 修复不正确地从EditorUserBuildSettings.selectedBuildTargetGroup获得BuildGroupTarget的bug

main
walon 2023-09-05 16:47:28 +08:00
parent 9cf8f19517
commit 1eaaf44c97
3 changed files with 7 additions and 6 deletions

View File

@ -7,6 +7,7 @@ using UnityEditor;
using UnityEditor.Build; using UnityEditor.Build;
using UnityEditor.Build.Reporting; using UnityEditor.Build.Reporting;
using UnityEngine; using UnityEngine;
using static UnityEngine.GraphicsBuffer;
namespace HybridCLR.Editor.BuildProcessors namespace HybridCLR.Editor.BuildProcessors
{ {
@ -39,7 +40,7 @@ namespace HybridCLR.Editor.BuildProcessors
{ {
return; return;
} }
BuildTargetGroup buildTargetGroup = EditorUserBuildSettings.selectedBuildTargetGroup; BuildTargetGroup buildTargetGroup = BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget);
ScriptingImplementation curScriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup); ScriptingImplementation curScriptingImplementation = PlayerSettings.GetScriptingBackend(buildTargetGroup);
ScriptingImplementation targetScriptingImplementation = ScriptingImplementation.IL2CPP; ScriptingImplementation targetScriptingImplementation = ScriptingImplementation.IL2CPP;
if (curScriptingImplementation != targetScriptingImplementation) if (curScriptingImplementation != targetScriptingImplementation)

View File

@ -23,7 +23,7 @@ namespace HybridCLR.Editor.Commands
LinkGeneratorCommand.GenerateLinkXml(target); LinkGeneratorCommand.GenerateLinkXml(target);
// 生成裁剪后的aot dll // 生成裁剪后的aot dll
StripAOTDllCommand.GenerateStripedAOTDlls(target, EditorUserBuildSettings.selectedBuildTargetGroup); StripAOTDllCommand.GenerateStripedAOTDlls(target);
// 桥接函数生成依赖于AOT dll必须保证已经build过生成AOT dll // 桥接函数生成依赖于AOT dll必须保证已经build过生成AOT dll
MethodBridgeGeneratorCommand.GenerateMethodBridge(target); MethodBridgeGeneratorCommand.GenerateMethodBridge(target);

View File

@ -15,7 +15,7 @@ namespace HybridCLR.Editor.Commands
[MenuItem("HybridCLR/Generate/AOTDlls", priority = 105)] [MenuItem("HybridCLR/Generate/AOTDlls", priority = 105)]
public static void GenerateStripedAOTDlls() public static void GenerateStripedAOTDlls()
{ {
GenerateStripedAOTDlls(EditorUserBuildSettings.activeBuildTarget, EditorUserBuildSettings.selectedBuildTargetGroup); GenerateStripedAOTDlls(EditorUserBuildSettings.activeBuildTarget);
} }
private static string GetLocationPathName(string buildDir, BuildTarget target) private static string GetLocationPathName(string buildDir, BuildTarget target)
@ -32,7 +32,7 @@ namespace HybridCLR.Editor.Commands
} }
} }
public static void GenerateStripedAOTDlls(BuildTarget target, BuildTargetGroup group) public static void GenerateStripedAOTDlls(BuildTarget target)
{ {
string outputPath = $"{SettingsUtil.HybridCLRDataDir}/StrippedAOTDllsTempProj/{target}"; string outputPath = $"{SettingsUtil.HybridCLRDataDir}/StrippedAOTDllsTempProj/{target}";
BashUtil.RemoveDir(outputPath); BashUtil.RemoveDir(outputPath);
@ -81,7 +81,7 @@ namespace HybridCLR.Editor.Commands
locationPathName = GetLocationPathName(outputPath, target), locationPathName = GetLocationPathName(outputPath, target),
options = buildOptions, options = buildOptions,
target = target, target = target,
targetGroup = group, targetGroup = BuildPipeline.GetBuildTargetGroup(target),
}; };
var report = BuildPipeline.BuildPlayer(buildPlayerOptions); var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
@ -115,7 +115,7 @@ namespace HybridCLR.Editor.Commands
{ {
throw new Exception("GenerateStripedAOTDlls failed"); throw new Exception("GenerateStripedAOTDlls failed");
} }
Debug.Log($"GenerateStripedAOTDlls target:{target} group:{group} path:{outputPath}"); Debug.Log($"GenerateStripedAOTDlls target:{target} path:{outputPath}");
} }
} }
} }