mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-07 18:13:35 +08:00
Add keybind for mouse unlock, and aggressive unlock mode
This commit is contained in:
parent
0f69833283
commit
9bdcccaaa1
@ -18,6 +18,8 @@ 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<KeyCode> Force_Unlock_Keybind;
|
||||||
|
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;
|
||||||
@ -76,6 +78,18 @@ namespace UnityExplorer.Core.Config
|
|||||||
"Should UnityExplorer be hidden on startup?",
|
"Should UnityExplorer be hidden on startup?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
|
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
||||||
|
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
||||||
|
true);
|
||||||
|
|
||||||
|
Force_Unlock_Keybind = new ConfigElement<KeyCode>("Force Unlock Keybind",
|
||||||
|
"The keybind to toggle the 'Force Unlock Mouse' setting. Only usable when UnityExplorer is open.",
|
||||||
|
KeyCode.F6);
|
||||||
|
|
||||||
|
Aggressive_Force_Unlock = new ConfigElement<bool>("Aggressive Mouse Unlock",
|
||||||
|
"Use Camera.onPostRender callback to aggressively force the Mouse to be unlocked (requires game restart).",
|
||||||
|
false);
|
||||||
|
|
||||||
//Default_Tab = new ConfigElement<MenuPages>("Default Tab",
|
//Default_Tab = new ConfigElement<MenuPages>("Default Tab",
|
||||||
// "The default menu page when starting the game.",
|
// "The default menu page when starting the game.",
|
||||||
// MenuPages.Home);
|
// MenuPages.Home);
|
||||||
@ -84,10 +98,6 @@ namespace UnityExplorer.Core.Config
|
|||||||
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
"Should UnityEngine.Debug.Log messages be printed to UnityExplorer's log?",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Force_Unlock_Mouse = new ConfigElement<bool>("Force Unlock Mouse",
|
|
||||||
"Force the Cursor to be unlocked (visible) when the UnityExplorer menu is open.",
|
|
||||||
true);
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -41,6 +41,9 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
|
if (ConfigManager.Aggressive_Force_Unlock.Value)
|
||||||
|
RuntimeProvider.Instance.SetupCameraDelegate();
|
||||||
|
|
||||||
SetupPatches();
|
SetupPatches();
|
||||||
|
|
||||||
UpdateCursorControl();
|
UpdateCursorControl();
|
||||||
@ -49,6 +52,20 @@ namespace UnityExplorer.Core.Input
|
|||||||
ConfigManager.Force_Unlock_Mouse.OnValueChanged += (bool val) => { Unlock = val; };
|
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()
|
public static void UpdateCursorControl()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -26,6 +26,24 @@ namespace UnityExplorer.Core.Runtime.Il2Cpp
|
|||||||
TextureUtil = new Il2CppTextureUtil();
|
TextureUtil = new Il2CppTextureUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetupCameraDelegate()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var action = new Action<Camera>(CursorUnlocker.OnCameraPostRender);
|
||||||
|
var _delegate = DelegateSupport.ConvertDelegate<Camera.CameraCallback>(action);
|
||||||
|
if (Camera.onPostRender == null)
|
||||||
|
Camera.onPostRender = _delegate;
|
||||||
|
else
|
||||||
|
Camera.onPostRender = Camera.onPostRender.CombineImpl(_delegate).TryCast<Camera.CameraCallback>();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception setting up Camera.onPostRender callback: {ex}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetupEvents()
|
public override void SetupEvents()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -12,6 +12,7 @@ using UnityEngine.SceneManagement;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using UnityExplorer.Core;
|
using UnityExplorer.Core;
|
||||||
using UnityExplorer.Core.CSharp;
|
using UnityExplorer.Core.CSharp;
|
||||||
|
using UnityExplorer.Core.Input;
|
||||||
|
|
||||||
namespace UnityExplorer.Core.Runtime.Mono
|
namespace UnityExplorer.Core.Runtime.Mono
|
||||||
{
|
{
|
||||||
@ -26,6 +27,11 @@ namespace UnityExplorer.Core.Runtime.Mono
|
|||||||
DummyBehaviour.Setup();
|
DummyBehaviour.Setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void SetupCameraDelegate()
|
||||||
|
{
|
||||||
|
Camera.onPostRender += CursorUnlocker.OnCameraPostRender;
|
||||||
|
}
|
||||||
|
|
||||||
public override void SetupEvents()
|
public override void SetupEvents()
|
||||||
{
|
{
|
||||||
Application.logMessageReceived += Application_logMessageReceived;
|
Application.logMessageReceived += Application_logMessageReceived;
|
||||||
|
@ -35,6 +35,8 @@ namespace UnityExplorer
|
|||||||
|
|
||||||
public abstract void Initialize();
|
public abstract void Initialize();
|
||||||
|
|
||||||
|
public abstract void SetupCameraDelegate();
|
||||||
|
|
||||||
public abstract void SetupEvents();
|
public abstract void SetupEvents();
|
||||||
|
|
||||||
public abstract void StartCoroutine(IEnumerator routine);
|
public abstract void StartCoroutine(IEnumerator routine);
|
||||||
|
@ -80,7 +80,7 @@ namespace UnityExplorer
|
|||||||
UIManager.Update();
|
UIManager.Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
#region LOGGING
|
#region LOGGING
|
||||||
|
|
||||||
public static void Log(object message)
|
public static void Log(object message)
|
||||||
=> Log(message, LogType.Log, false);
|
=> Log(message, LogType.Log, false);
|
||||||
@ -119,6 +119,6 @@ namespace UnityExplorer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,6 +83,9 @@ namespace UnityExplorer.UI
|
|||||||
if (!ShowMenu)
|
if (!ShowMenu)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Keybind.Value))
|
||||||
|
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
|
||||||
|
|
||||||
UIBehaviourModel.UpdateInstances();
|
UIBehaviourModel.UpdateInstances();
|
||||||
|
|
||||||
if (EventSystem.current != EventSys)
|
if (EventSystem.current != EventSys)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user