mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
Fix for games where InputSystem is present but not active
This commit is contained in:
parent
af3ee07143
commit
73cde0f91f
@ -47,32 +47,43 @@ namespace UnityExplorer.Core.Input
|
||||
|
||||
private static void InitHandler()
|
||||
{
|
||||
// First, just try to use the legacy input, see if its working.
|
||||
// The InputSystem package may be present but not actually activated, so we can find out this way.
|
||||
|
||||
if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_inputModule = new LegacyInput();
|
||||
CurrentType = InputType.Legacy;
|
||||
|
||||
// make sure its working
|
||||
GetKeyDown(KeyCode.F5);
|
||||
|
||||
ExplorerCore.Log("Initialized Legacy Input support");
|
||||
return;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// It's not working, we'll fall back to InputSystem.
|
||||
}
|
||||
}
|
||||
|
||||
if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
m_inputModule = new InputSystem();
|
||||
CurrentType = InputType.InputSystem;
|
||||
|
||||
// make sure its working, the package may be present but not enabled.
|
||||
GetKeyDown(KeyCode.F5);
|
||||
|
||||
ExplorerCore.Log("Initialized new InputSystem support.");
|
||||
return;
|
||||
}
|
||||
catch
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExplorerCore.LogWarning("The InputSystem package was found but it does not seem to be working, defaulting to legacy Input...");
|
||||
ExplorerCore.Log(ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
|
||||
{
|
||||
m_inputModule = new LegacyInput();
|
||||
CurrentType = InputType.Legacy;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
ExplorerCore.LogWarning("Could not find any Input Module Type!");
|
||||
m_inputModule = new NoInput();
|
||||
CurrentType = InputType.None;
|
||||
|
@ -12,8 +12,6 @@ namespace UnityExplorer.Core.Input
|
||||
{
|
||||
public InputSystem()
|
||||
{
|
||||
ExplorerCore.Log("Initializing new InputSystem support...");
|
||||
|
||||
m_kbCurrentProp = TKeyboard.GetProperty("current");
|
||||
m_kbIndexer = TKeyboard.GetProperty("Item", new Type[] { TKey });
|
||||
|
||||
|
@ -10,8 +10,6 @@ namespace UnityExplorer.Core.Input
|
||||
{
|
||||
public LegacyInput()
|
||||
{
|
||||
ExplorerCore.Log("Initializing Legacy Input support...");
|
||||
|
||||
m_mousePositionProp = TInput.GetProperty("mousePosition");
|
||||
m_mouseDeltaProp = TInput.GetProperty("mouseScrollDelta");
|
||||
m_getKeyMethod = TInput.GetMethod("GetKey", new Type[] { typeof(KeyCode) });
|
||||
|
Loading…
x
Reference in New Issue
Block a user