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

Commit 9fe998a

Browse files
committed
Cleanup
1 parent 28b6db8 commit 9fe998a

File tree

1 file changed

+11
-17
lines changed

1 file changed

+11
-17
lines changed

src/UI/UIManager.cs

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,30 +497,24 @@ private static byte[] ReadFully(Stream input)
497497

498498
// AssetBundle patch
499499

500-
static bool donePatch;
501-
private static Type T_AssetBundle => ReflectionUtility.GetTypeByName("UnityEngine.AssetBundle");
500+
private static Type TypeofAssetBundle => ReflectionUtility.GetTypeByName("UnityEngine.AssetBundle");
502501

503502
private static void SetupAssetBundlePatches()
504503
{
505-
if (!donePatch)
504+
try
506505
{
507-
try
508-
{
509-
if (T_AssetBundle.GetMethod("UnloadAllAssetBundles", AccessTools.all) is MethodInfo unloadAllBundles)
510-
{
511-
var processor = ExplorerCore.Harmony.CreateProcessor(unloadAllBundles);
512-
var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all));
513-
processor.AddPrefix(prefix);
514-
processor.Patch();
515-
516-
donePatch = true;
517-
}
518-
}
519-
catch (Exception ex)
506+
if (TypeofAssetBundle.GetMethod("UnloadAllAssetBundles", AccessTools.all) is MethodInfo unloadAllBundles)
520507
{
521-
ExplorerCore.LogWarning($"Exception setting up AssetBundle.UnloadAllAssetBundles patch: {ex}");
508+
var processor = ExplorerCore.Harmony.CreateProcessor(unloadAllBundles);
509+
var prefix = new HarmonyMethod(typeof(UIManager).GetMethod(nameof(Prefix_UnloadAllAssetBundles), AccessTools.all));
510+
processor.AddPrefix(prefix);
511+
processor.Patch();
522512
}
523513
}
514+
catch (Exception ex)
515+
{
516+
ExplorerCore.LogWarning($"Exception setting up AssetBundle.UnloadAllAssetBundles patch: {ex}");
517+
}
524518
}
525519

526520

0 commit comments

Comments
 (0)