Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 1e68529

Browse files
committed
Don't patch stripped UnloadAllAssetBundles
1 parent e84e96a commit 1e68529

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/UI/UIManager.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,17 @@ private static void LoadBundle()
446446

447447
AssetBundle LoadBundle(string id)
448448
{
449-
ExplorerCore.Log($"Loading {id} bundle for Unity {Application.unityVersion}");
450-
451-
return AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
449+
var bundle = AssetBundle.LoadFromMemory(ReadFully(typeof(ExplorerCore)
452450
.Assembly
453451
.GetManifestResourceStream($"UnityExplorer.Resources.{id}.bundle")));
452+
if (bundle)
453+
ExplorerCore.Log($"Loaded {id} bundle for Unity {Application.unityVersion}");
454+
return bundle;
454455
}
455456

456457
if (ExplorerBundle == null)
457458
{
458-
ExplorerCore.LogWarning("Could not load the ExplorerUI Bundle!");
459+
ExplorerCore.LogWarning("Could not load the UnityExplorer UI Bundle!");
459460
DefaultFont = ConsoleFont = Resources.GetBuiltinResource<Font>("Arial.ttf");
460461
return;
461462
}
@@ -505,6 +506,11 @@ private static void SetupAssetBundlePatches()
505506
{
506507
if (TypeofAssetBundle.GetMethod("UnloadAllAssetBundles", AccessTools.all) is MethodInfo unloadAllBundles)
507508
{
509+
#if CPP
510+
// if IL2CPP, ensure method wasn't stripped
511+
if (UnhollowerBaseLib.UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(unloadAllBundles) == null)
512+
return;
513+
#endif
508514
var processor = ExplorerCore.Harmony.CreateProcessor(unloadAllBundles);
509515
var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all));
510516
processor.AddPrefix(prefix);

0 commit comments

Comments
 (0)