Fix GameDataPath exception in non-Unity3D games (#1416)

When `GameDataPath` is invalid, do not throw an exception; instead, set
both `GameDataPath` and `ManagedPath` to `null`.
This commit is contained in:
MenShiyun authored and GitHub committed 2026-10-16 12:41:59 +02:00
1 parent 5b766a3b7f
commit 6cea286d20
1 file changed
+3 -3
+3 -3
View File
@@ -127,9 +127,9 @@ public static class Paths
}
if (string.IsNullOrEmpty(GameDataPath) || !Directory.Exists(GameDataPath))
throw new DirectoryNotFoundException("Failed to extract valid GameDataPath from executablePath: " + executablePath);
GameDataPath = null;
ManagedPath = managedPath ?? Path.Combine(GameDataPath, "Managed");
ManagedPath = managedPath ?? (GameDataPath != null ? Path.Combine(GameDataPath, "Managed") : null);
BepInExRootPath = bepinRootPath ?? Path.Combine(GameRootPath, "BepInEx");
ConfigPath = Path.Combine(BepInExRootPath, "config");
BepInExConfigPath = Path.Combine(ConfigPath, "BepInEx.cfg");
@@ -139,7 +139,7 @@ public static class Paths
BepInExAssemblyPath = Path.Combine(BepInExAssemblyDirectory,
$"{Assembly.GetExecutingAssembly().GetName().Name}.dll");
CachePath = Path.Combine(BepInExRootPath, "cache");
DllSearchPaths = (dllSearchPath ?? new string[0]).Concat(new[] { ManagedPath }).Distinct().ToArray();
DllSearchPaths = (dllSearchPath ?? new string[0]).Concat(new[] { ManagedPath }).Where(p => p != null).Distinct().ToArray();
}
internal static void SetPluginPath(string pluginPath) =>