From f800cbcc43f774d3adb0b1a9c264f0326a5d9f38 Mon Sep 17 00:00:00 2001 From: ManlyMarco <39247311+ManlyMarco@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:09:44 +0200 Subject: [PATCH] Add GlobalMetadataPath setting (#978) --- .../Il2CppInteropManager.cs | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs index 61aa583..1ebf4c9 100644 --- a/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs +++ b/Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs @@ -99,6 +99,17 @@ internal static partial class Il2CppInteropManager .AppendLine("Some plugins may not work properly without this, but it may cause issues in some games.") .ToString()); + private static readonly ConfigEntry GlobalMetadataPath = ConfigFile.CoreConfig.Bind( + "IL2CPP", "GlobalMetadataPath", + "{GameDataPath}/il2cpp_data/Metadata/global-metadata.dat", + new StringBuilder() + .AppendLine("The path to the IL2CPP metadata file.") + .AppendLine("Supports the following placeholders:") + .AppendLine("{BepInEx} - Path to the BepInEx folder.") + .AppendLine("{ProcessName} - Name of the current process") + .AppendLine("{GameDataPath} - Path to the game's Data folder.") + .ToString()); + private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("InteropManager"); private static string il2cppInteropBasePath; @@ -289,12 +300,13 @@ internal static partial class Il2CppInteropManager private static List RunCpp2Il() { - Logger.LogMessage("Running Cpp2IL to generate dummy assemblies"); - - var metadataPath = Path.Combine(Paths.GameDataPath, - "il2cpp_data", - "Metadata", - "global-metadata.dat"); + var metadataPath = Path.Combine(Paths.GameRootPath, + GlobalMetadataPath.Value + .Replace("{BepInEx}", Paths.BepInExRootPath) + .Replace("{ProcessName}", Paths.ProcessName) + .Replace("{GameDataPath}", Paths.GameDataPath)); + + Logger.LogMessage("Running Cpp2IL to generate dummy assemblies from " + metadataPath); var stopwatch = new Stopwatch(); stopwatch.Start();