mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-17 22:48:04 +08:00
Add option to disable EventSystem override
This commit is contained in:
parent
041f2938f7
commit
1a26623080
@ -21,6 +21,7 @@ namespace UnityExplorer.Core.Config
|
|||||||
public static ConfigElement<bool> Force_Unlock_Mouse;
|
public static ConfigElement<bool> Force_Unlock_Mouse;
|
||||||
public static ConfigElement<KeyCode> Force_Unlock_Toggle;
|
public static ConfigElement<KeyCode> Force_Unlock_Toggle;
|
||||||
public static ConfigElement<bool> Aggressive_Mouse_Unlock;
|
public static ConfigElement<bool> Aggressive_Mouse_Unlock;
|
||||||
|
public static ConfigElement<bool> Disable_EventSystem_Override;
|
||||||
public static ConfigElement<string> Default_Output_Path;
|
public static ConfigElement<string> Default_Output_Path;
|
||||||
public static ConfigElement<bool> Log_Unity_Debug;
|
public static ConfigElement<bool> Log_Unity_Debug;
|
||||||
public static ConfigElement<bool> Hide_On_Startup;
|
public static ConfigElement<bool> Hide_On_Startup;
|
||||||
@ -93,7 +94,11 @@ namespace UnityExplorer.Core.Config
|
|||||||
KeyCode.None);
|
KeyCode.None);
|
||||||
|
|
||||||
Aggressive_Mouse_Unlock = new ConfigElement<bool>("Aggressive Mouse Unlock",
|
Aggressive_Mouse_Unlock = new ConfigElement<bool>("Aggressive Mouse Unlock",
|
||||||
"Use WaitForEndOfFrame to aggressively force the Mouse to be unlocked (requires game restart).",
|
"Use WaitForEndOfFrame to aggressively force the Mouse to be unlocked.\n<b>Requires restart to take effect.</b>",
|
||||||
|
false);
|
||||||
|
|
||||||
|
Disable_EventSystem_Override = new ConfigElement<bool>("Disable EventSystem override",
|
||||||
|
"If enabled, UnityExplorer will not override the EventSystem from the game.\n<b>May require restart to take effect.</b>",
|
||||||
false);
|
false);
|
||||||
|
|
||||||
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
Log_Unity_Debug = new ConfigElement<bool>("Log Unity Debug",
|
||||||
|
@ -37,12 +37,15 @@ namespace UnityExplorer.Core.Input
|
|||||||
lastVisibleState = Cursor.visible;
|
lastVisibleState = Cursor.visible;
|
||||||
|
|
||||||
SetupPatches();
|
SetupPatches();
|
||||||
|
|
||||||
UpdateCursorControl();
|
UpdateCursorControl();
|
||||||
|
|
||||||
|
// Hook up config values
|
||||||
|
|
||||||
|
// Force Unlock Mouse
|
||||||
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; };
|
||||||
|
|
||||||
|
// Aggressive Mouse Unlock
|
||||||
if (ConfigManager.Aggressive_Mouse_Unlock.Value)
|
if (ConfigManager.Aggressive_Mouse_Unlock.Value)
|
||||||
SetupAggressiveUnlock();
|
SetupAggressiveUnlock();
|
||||||
}
|
}
|
||||||
@ -83,7 +86,7 @@ namespace UnityExplorer.Core.Input
|
|||||||
Cursor.lockState = CursorLockMode.None;
|
Cursor.lockState = CursorLockMode.None;
|
||||||
Cursor.visible = true;
|
Cursor.visible = true;
|
||||||
|
|
||||||
if (UIManager.EventSys)
|
if (!ConfigManager.Disable_EventSystem_Override.Value && UIManager.EventSys)
|
||||||
SetEventSystem();
|
SetEventSystem();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -91,7 +94,7 @@ namespace UnityExplorer.Core.Input
|
|||||||
Cursor.lockState = lastLockMode;
|
Cursor.lockState = lastLockMode;
|
||||||
Cursor.visible = lastVisibleState;
|
Cursor.visible = lastVisibleState;
|
||||||
|
|
||||||
if (UIManager.EventSys)
|
if (!ConfigManager.Disable_EventSystem_Override.Value && UIManager.EventSys)
|
||||||
ReleaseEventSystem();
|
ReleaseEventSystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,28 +163,21 @@ namespace UnityExplorer.Core.Input
|
|||||||
|
|
||||||
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
public static void Prefix_EventSystem_set_current(ref EventSystem value)
|
||||||
{
|
{
|
||||||
if (!UIManager.EventSys)
|
if (!settingEventSystem && value)
|
||||||
{
|
|
||||||
if (value)
|
|
||||||
{
|
{
|
||||||
lastEventSystem = value;
|
lastEventSystem = value;
|
||||||
lastInputModule = value.currentInputModule;
|
lastInputModule = value.currentInputModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!UIManager.EventSys)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!settingEventSystem && value != UIManager.EventSys)
|
if (!settingEventSystem && ShouldActuallyUnlock && !ConfigManager.Disable_EventSystem_Override.Value)
|
||||||
{
|
|
||||||
lastEventSystem = value;
|
|
||||||
lastInputModule = value?.currentInputModule;
|
|
||||||
|
|
||||||
if (ShouldActuallyUnlock)
|
|
||||||
{
|
{
|
||||||
value = UIManager.EventSys;
|
value = UIManager.EventSys;
|
||||||
value.enabled = true;
|
value.enabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Force mouse to stay unlocked and visible while UnlockMouse and ShowMenu are true.
|
// Force mouse to stay unlocked and visible while UnlockMouse and ShowMenu are true.
|
||||||
// Also keep track of when anything else tries to set Cursor state, this will be the
|
// Also keep track of when anything else tries to set Cursor state, this will be the
|
||||||
|
@ -145,7 +145,7 @@ namespace UnityExplorer.UI
|
|||||||
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
|
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
|
||||||
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
|
CursorUnlocker.Unlock = !CursorUnlocker.Unlock;
|
||||||
|
|
||||||
if (EventSystem.current != EventSys)
|
if (!ConfigManager.Disable_EventSystem_Override.Value && EventSystem.current != EventSys)
|
||||||
CursorUnlocker.SetEventSystem();
|
CursorUnlocker.SetEventSystem();
|
||||||
|
|
||||||
UIPanel.UpdateFocus();
|
UIPanel.UpdateFocus();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user