Add keybind for mouse unlock, and aggressive unlock mode

This commit is contained in:
Sinai
2021-04-16 18:24:31 +10:00
parent 0f69833283
commit 9bdcccaaa1
7 changed files with 62 additions and 6 deletions

View File

@ -41,6 +41,9 @@ namespace UnityExplorer.Core.Input
public static void Init()
{
if (ConfigManager.Aggressive_Force_Unlock.Value)
RuntimeProvider.Instance.SetupCameraDelegate();
SetupPatches();
UpdateCursorControl();
@ -49,6 +52,20 @@ namespace UnityExplorer.Core.Input
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
}
public static void OnCameraPostRender(Camera _)
{
if (!UIManager.ShowMenu)
return;
UpdateIfNeeded();
}
public static void UpdateIfNeeded()
{
if ((!ShouldActuallyUnlock && (Cursor.visible || Cursor.lockState == CursorLockMode.None))
|| (ShouldActuallyUnlock && (!Cursor.visible || Cursor.lockState != CursorLockMode.None)))
UpdateCursorControl();
}
public static void UpdateCursorControl()
{
try