Skip to content
This repository has been archived by the owner on Feb 3, 2024. It is now read-only.

Commit

Permalink
🐛 Fix font loading
Browse files Browse the repository at this point in the history
  • Loading branch information
Chasmical committed Aug 19, 2022
1 parent 627bb5c commit 42c46e0
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions BetterFonts/BetterFontsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public class BetterFontsPlugin : BepInEx.BaseUnityPlugin
public void Awake()
{
Harmony harmony = new Harmony(Info.Metadata.GUID);
harmony.Patch(AccessTools.Method(typeof(GameController), "Awake2"), null,
new HarmonyMethod(typeof(BetterFontsPlugin).GetMethod(nameof(GameController_Awake2))));
harmony.Patch(AccessTools.Method(typeof(GameController), "Update"), null,
new HarmonyMethod(typeof(BetterFontsPlugin).GetMethod(nameof(GameController_Update))));
harmony.Patch(AccessTools.Method(typeof(GameController), nameof(GameController.SetFont)),
Expand All @@ -34,14 +36,21 @@ public void Awake()
harmony.Patch(AccessTools.Method(typeof(TalkText), "Start"),
null, new HarmonyMethod(typeof(BetterFontsPlugin).GetMethod(nameof(TalkText_Start))));
}
public IEnumerator Start()
public static void GameController_Awake2(ref IEnumerator __result)
{
AssetBundleCreateRequest req = AssetBundle.LoadFromMemoryAsync(Properties.Resources.BetterFontsBundle);
yield return req;
MunroExtended = req.assetBundle.LoadAsset<Font>("MunroExtended");
FusionPixel = req.assetBundle.LoadAsset<Font>("FusionPixel");
EditUndoBRK = req.assetBundle.LoadAsset<Font>("EditUndoBRK");
PressStart2P = req.assetBundle.LoadAsset<Font>("PressStart2P-Regular");
__result = PassThrough(__result);
static IEnumerator PassThrough(IEnumerator original)
{
AssetBundleCreateRequest req = AssetBundle.LoadFromMemoryAsync(Properties.Resources.BetterFontsBundle);
yield return req;
MunroExtended = req.assetBundle.LoadAsset<Font>("MunroExtended");
FusionPixel = req.assetBundle.LoadAsset<Font>("FusionPixel");
EditUndoBRK = req.assetBundle.LoadAsset<Font>("EditUndoBRK");
PressStart2P = req.assetBundle.LoadAsset<Font>("PressStart2P-Regular");

while (original.MoveNext())
yield return original.Current;
}
}
public static void GameController_Update(GameController __instance)
{
Expand Down

0 comments on commit 42c46e0

Please sign in to comment.