Skip to content

Commit a1cd9be

Browse files
committed
Add IL2CPP.UpdateUnhollowedAssemblies configuration option
Allows to supply custom unhollowed assemblies
1 parent 8e9f1f3 commit a1cd9be

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

BepInEx.IL2CPP/ProxyAssemblyGenerator.cs

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ namespace BepInEx.IL2CPP
2020
{
2121
internal static class ProxyAssemblyGenerator
2222
{
23+
private static readonly ConfigEntry<bool> ConfigUpdateUnhollowedAssemblies =
24+
ConfigFile.CoreConfig.Bind("IL2CPP",
25+
"UpdateUnhollowedAssemblies",
26+
true,
27+
new StringBuilder()
28+
.AppendLine("Whether to run Il2CppAssemblyUnhollower automatically to generate Il2Cpp support assemblies when they are outdated.")
29+
.AppendLine("If disabled assemblies in `BepInEx/unhollowed` won't be updated between game or BepInEx updates!")
30+
.ToString());
31+
2332
private static readonly ConfigEntry<string> ConfigUnityBaseLibrariesSource = ConfigFile.CoreConfig.Bind(
2433
"IL2CPP", "UnityBaseLibrariesSource",
2534
"http://unity.bepinex.dev/libraries/{VERSION}.zip",
@@ -94,13 +103,26 @@ static void HashString(ICryptoTransform hash, string str)
94103

95104
public static bool CheckIfGenerationRequired()
96105
{
106+
static bool NeedGenerationOrSkip()
107+
{
108+
if (!ConfigUpdateUnhollowedAssemblies.Value)
109+
{
110+
var hash = ComputeHash();
111+
Preloader.Log
112+
.LogWarning($"Unhollowed assemblies are possibly out of date. To disable this message, create file {HashPath} with the following contents: {hash}");
113+
return false;
114+
}
115+
116+
return true;
117+
}
118+
97119
if (!Directory.Exists(Preloader.IL2CPPUnhollowedPath))
98120
return true;
99121

100122
if (!File.Exists(HashPath))
101-
return true;
123+
return NeedGenerationOrSkip();
102124

103-
if (ComputeHash() != File.ReadAllText(HashPath))
125+
if (ComputeHash() != File.ReadAllText(HashPath) && NeedGenerationOrSkip())
104126
{
105127
Preloader.Log.LogInfo("Detected outdated proxy assemblies, will regenerate them now");
106128
return true;

0 commit comments

Comments
 (0)