mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-07 08:49:15 +00:00
[WindowFocusCheckFix] iniyial push
This commit is contained in:
parent
a6fa59d24c
commit
1f99312c22
5 changed files with 114 additions and 0 deletions
39
WindowFocusCheckFix/Main.cs
Normal file
39
WindowFocusCheckFix/Main.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
using System.Reflection;
|
||||
using ABI_RC.Core;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.WindowFocusCheckFix;
|
||||
|
||||
public class WindowFocusCheckFixMod : MelonMod
|
||||
{
|
||||
#region Melon Events
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
#region WindowFocusManager Patches
|
||||
|
||||
HarmonyInstance.Patch(
|
||||
typeof(WindowFocusManager).GetMethod(nameof(WindowFocusManager.IsWindowFocused),
|
||||
BindingFlags.NonPublic | BindingFlags.Static),
|
||||
prefix: new HarmonyMethod(typeof(WindowFocusCheckFixMod).GetMethod(nameof(OnPreWindowFocusManagerIsWindowFocused),
|
||||
BindingFlags.NonPublic | BindingFlags.Static))
|
||||
);
|
||||
|
||||
#endregion WindowFocusManager Patches
|
||||
}
|
||||
|
||||
#endregion Melon Events
|
||||
|
||||
#region Harmony Patches
|
||||
|
||||
// ReSharper disable once RedundantAssignment
|
||||
private static bool OnPreWindowFocusManagerIsWindowFocused(ref bool __result)
|
||||
{
|
||||
__result = Application.isFocused; // use Unity method instead
|
||||
return false;
|
||||
}
|
||||
|
||||
#endregion Harmony Patches
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue