Skip to content

Commit f800cbc

Browse files
authored
Add GlobalMetadataPath setting (#978)
1 parent cbd70eb commit f800cbc

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Runtimes/Unity/BepInEx.Unity.IL2CPP/Il2CppInteropManager.cs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ static Il2CppInteropManager()
9999
.AppendLine("Some plugins may not work properly without this, but it may cause issues in some games.")
100100
.ToString());
101101

102+
private static readonly ConfigEntry<string> GlobalMetadataPath = ConfigFile.CoreConfig.Bind(
103+
"IL2CPP", "GlobalMetadataPath",
104+
"{GameDataPath}/il2cpp_data/Metadata/global-metadata.dat",
105+
new StringBuilder()
106+
.AppendLine("The path to the IL2CPP metadata file.")
107+
.AppendLine("Supports the following placeholders:")
108+
.AppendLine("{BepInEx} - Path to the BepInEx folder.")
109+
.AppendLine("{ProcessName} - Name of the current process")
110+
.AppendLine("{GameDataPath} - Path to the game's Data folder.")
111+
.ToString());
112+
102113
private static readonly ManualLogSource Logger = BepInEx.Logging.Logger.CreateLogSource("InteropManager");
103114

104115
private static string il2cppInteropBasePath;
@@ -289,12 +300,13 @@ private static void DownloadUnityAssemblies()
289300

290301
private static List<AsmResolver.DotNet.AssemblyDefinition> RunCpp2Il()
291302
{
292-
Logger.LogMessage("Running Cpp2IL to generate dummy assemblies");
293-
294-
var metadataPath = Path.Combine(Paths.GameDataPath,
295-
"il2cpp_data",
296-
"Metadata",
297-
"global-metadata.dat");
303+
var metadataPath = Path.Combine(Paths.GameRootPath,
304+
GlobalMetadataPath.Value
305+
.Replace("{BepInEx}", Paths.BepInExRootPath)
306+
.Replace("{ProcessName}", Paths.ProcessName)
307+
.Replace("{GameDataPath}", Paths.GameDataPath));
308+
309+
Logger.LogMessage("Running Cpp2IL to generate dummy assemblies from " + metadataPath);
298310

299311
var stopwatch = new Stopwatch();
300312
stopwatch.Start();

0 commit comments

Comments
 (0)