Fix AOT metadata loading for smoke builds

This commit is contained in:
wuwenbo 2026-06-11 02:46:07 +08:00
parent ac09170856
commit 75bbc0131e
2 changed files with 4 additions and 23 deletions

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using HybridCLR;
using UnityEngine; using UnityEngine;
namespace TH1_Logic.Hotfix namespace TH1_Logic.Hotfix
@ -85,26 +86,6 @@ namespace TH1_Logic.Hotfix
{ {
if (_aotMetadataLoaded) return; if (_aotMetadataLoaded) return;
var runtimeApiType = FindType("HybridCLR.RuntimeApi");
var modeType = FindType("HybridCLR.HomologousImageMode");
if (runtimeApiType == null || modeType == null)
{
return;
}
var method = runtimeApiType.GetMethod(
"LoadMetadataForAOTAssembly",
BindingFlags.Public | BindingFlags.Static,
null,
new[] { typeof(byte[]), modeType },
null);
if (method == null)
{
Debug.LogWarning("[TH1.Hotfix] HybridCLR RuntimeApi.LoadMetadataForAOTAssembly not found.");
return;
}
var mode = Enum.Parse(modeType, "SuperSet");
var aotDir = Path.Combine(root, HotfixManifest.AotMetadataFolderName); var aotDir = Path.Combine(root, HotfixManifest.AotMetadataFolderName);
var allLoaded = true; var allLoaded = true;
@ -118,7 +99,7 @@ namespace TH1_Logic.Hotfix
continue; continue;
} }
var result = method.Invoke(null, new object[] { File.ReadAllBytes(path), mode }); var result = RuntimeApi.LoadMetadataForAOTAssembly(File.ReadAllBytes(path), HomologousImageMode.SuperSet);
Debug.Log($"[TH1.Hotfix] Load AOT metadata {fileName}: {result}"); Debug.Log($"[TH1.Hotfix] Load AOT metadata {fileName}: {result}");
} }

View File

@ -77,7 +77,7 @@ namespace TH1_Logic.Editor
PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP); PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP);
EditorUserBuildSettings.development = true; EditorUserBuildSettings.development = true;
EditorUserBuildSettings.allowDebugging = true; EditorUserBuildSettings.allowDebugging = false;
PlayerSettings.usePlayerLog = true; PlayerSettings.usePlayerLog = true;
PlayerSettings.SetStackTraceLogType(LogType.Log, StackTraceLogType.ScriptOnly); PlayerSettings.SetStackTraceLogType(LogType.Log, StackTraceLogType.ScriptOnly);
PlayerSettings.SetStackTraceLogType(LogType.Warning, StackTraceLogType.ScriptOnly); PlayerSettings.SetStackTraceLogType(LogType.Warning, StackTraceLogType.ScriptOnly);
@ -110,7 +110,7 @@ namespace TH1_Logic.Editor
locationPathName = outputExe, locationPathName = outputExe,
target = BuildTarget.StandaloneWindows64, target = BuildTarget.StandaloneWindows64,
targetGroup = BuildTargetGroup.Standalone, targetGroup = BuildTargetGroup.Standalone,
options = BuildOptions.Development | BuildOptions.AllowDebugging options = BuildOptions.Development
}; };
var report = BuildPipeline.BuildPlayer(options); var report = BuildPipeline.BuildPlayer(options);