From 75bbc0131e1cf1de2720b576f3b218f79d904acb Mon Sep 17 00:00:00 2001 From: wuwenbo Date: Thu, 11 Jun 2026 02:46:07 +0800 Subject: [PATCH] Fix AOT metadata loading for smoke builds --- .../Assets/Scripts/TH1_AOT/HotfixBootstrap.cs | 23 ++----------------- .../Editor/TH1MigrationCommandLine.cs | 4 ++-- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/Unity/Assets/Scripts/TH1_AOT/HotfixBootstrap.cs b/Unity/Assets/Scripts/TH1_AOT/HotfixBootstrap.cs index e5ba02b9c..d34b8a3c5 100644 --- a/Unity/Assets/Scripts/TH1_AOT/HotfixBootstrap.cs +++ b/Unity/Assets/Scripts/TH1_AOT/HotfixBootstrap.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Reflection; +using HybridCLR; using UnityEngine; namespace TH1_Logic.Hotfix @@ -85,26 +86,6 @@ namespace TH1_Logic.Hotfix { 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 allLoaded = true; @@ -118,7 +99,7 @@ namespace TH1_Logic.Hotfix 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}"); } diff --git a/Unity/Assets/Scripts/TH1_Logic/Editor/TH1MigrationCommandLine.cs b/Unity/Assets/Scripts/TH1_Logic/Editor/TH1MigrationCommandLine.cs index 69afe6140..1efed6731 100644 --- a/Unity/Assets/Scripts/TH1_Logic/Editor/TH1MigrationCommandLine.cs +++ b/Unity/Assets/Scripts/TH1_Logic/Editor/TH1MigrationCommandLine.cs @@ -77,7 +77,7 @@ namespace TH1_Logic.Editor PlayerSettings.SetScriptingBackend(group, ScriptingImplementation.IL2CPP); EditorUserBuildSettings.development = true; - EditorUserBuildSettings.allowDebugging = true; + EditorUserBuildSettings.allowDebugging = false; PlayerSettings.usePlayerLog = true; PlayerSettings.SetStackTraceLogType(LogType.Log, StackTraceLogType.ScriptOnly); PlayerSettings.SetStackTraceLogType(LogType.Warning, StackTraceLogType.ScriptOnly); @@ -110,7 +110,7 @@ namespace TH1_Logic.Editor locationPathName = outputExe, target = BuildTarget.StandaloneWindows64, targetGroup = BuildTargetGroup.Standalone, - options = BuildOptions.Development | BuildOptions.AllowDebugging + options = BuildOptions.Development }; var report = BuildPipeline.BuildPlayer(options);