mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-09 19:08:57 +08:00
Add aggressive mouse unlock option using WaitForEndOfFrame
This commit is contained in:
parent
a6c24f91e4
commit
23483a6108
@ -19,6 +19,7 @@ namespace UnityExplorer.Core.Config
|
|||||||
|
|
||||||
public static ConfigElement<KeyCode> Main_Menu_Toggle;
|
public static ConfigElement<KeyCode> Main_Menu_Toggle;
|
||||||
public static ConfigElement<bool> Force_Unlock_Mouse;
|
public static ConfigElement<bool> Force_Unlock_Mouse;
|
||||||
|
public static ConfigElement<bool> Aggressive_Force_Unlock;
|
||||||
public static ConfigElement<MenuPages> Default_Tab;
|
public static ConfigElement<MenuPages> Default_Tab;
|
||||||
public static ConfigElement<int> Default_Page_Limit;
|
public static ConfigElement<int> Default_Page_Limit;
|
||||||
public static ConfigElement<string> Default_Output_Path;
|
public static ConfigElement<string> Default_Output_Path;
|
||||||
@ -78,6 +79,10 @@ namespace UnityExplorer.Core.Config
|
|||||||
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
||||||
true);
|
true);
|
||||||
|
|
||||||
|
Aggressive_Force_Unlock = new ConfigElement<bool>("Aggressive Mouse Unlock",
|
||||||
|
"Use WaitForEndOfFrame to aggressively force the Mouse to be unlocked (requires game restart).",
|
||||||
|
false);
|
||||||
|
|
||||||
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
|
Default_Page_Limit = new ConfigElement<int>("Default Page Limit",
|
||||||
"The default maximum number of elements per 'page' in UnityExplorer.",
|
"The default maximum number of elements per 'page' in UnityExplorer.",
|
||||||
25);
|
25);
|
||||||
|
@ -7,6 +7,7 @@ using BF = System.Reflection.BindingFlags;
|
|||||||
using UnityExplorer.Core.Config;
|
using UnityExplorer.Core.Config;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.UI;
|
using UnityExplorer.UI;
|
||||||
|
using System.Collections;
|
||||||
#if ML
|
#if ML
|
||||||
using Harmony;
|
using Harmony;
|
||||||
#else
|
#else
|
||||||
@ -48,6 +49,36 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
Unlock = ConfigManager.Force_Unlock_Mouse.Value;
|
Unlock = ConfigManager.Force_Unlock_Mouse.Value;
|
||||||
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
|
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
|
||||||
|
|
||||||
|
if (ConfigManager.Aggressive_Force_Unlock.Value)
|
||||||
|
SetupAggressiveUnlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetupAggressiveUnlock()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RuntimeProvider.Instance.StartCoroutine(AggressiveUnlockCoroutine());
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception setting up Camera.onPostRender callback: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly WaitForEndOfFrame _waitForEndOfFrame = new WaitForEndOfFrame();
|
||||||
|
|
||||||
|
private static IEnumerator AggressiveUnlockCoroutine()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
ExplorerCore.Log("Yielding end of frame");
|
||||||
|
yield return _waitForEndOfFrame;
|
||||||
|
ExplorerCore.Log("Yielded");
|
||||||
|
|
||||||
|
if (UIManager.ShowMenu)
|
||||||
|
UpdateCursorControl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateCursorControl()
|
public static void UpdateCursorControl()
|
||||||
|
@ -14,7 +14,7 @@ namespace UnityExplorer
|
|||||||
public class ExplorerCore
|
public class ExplorerCore
|
||||||
{
|
{
|
||||||
public const string NAME = "UnityExplorer";
|
public const string NAME = "UnityExplorer";
|
||||||
public const string VERSION = "3.3.12";
|
public const string VERSION = "3.3.13";
|
||||||
public const string AUTHOR = "Sinai";
|
public const string AUTHOR = "Sinai";
|
||||||
public const string GUID = "com.sinai.unityexplorer";
|
public const string GUID = "com.sinai.unityexplorer";
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user