Handle cases where InputSystem is present but not active

This commit is contained in:
Sinai 2021-04-25 21:19:00 +10:00
parent 1487372832
commit 7f6a4514e4

View File

@ -39,26 +39,43 @@ namespace UnityExplorer.Core.Input
} }
public static void Init() public static void Init()
{
InitHandler();
CursorUnlocker.Init();
}
private static void InitHandler()
{ {
if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null)) if (InputSystem.TKeyboard != null || (ReflectionUtility.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
{
try
{ {
m_inputModule = new InputSystem(); m_inputModule = new InputSystem();
CurrentType = InputType.InputSystem; CurrentType = InputType.InputSystem;
// make sure its working, the package may be present but not enabled.
GetKeyDown(KeyCode.F5);
return;
} }
else if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null)) catch
{
ExplorerCore.LogWarning("The InputSystem package was found but it does not seem to be working, defaulting to legacy Input...");
}
}
if (LegacyInput.TInput != null || (ReflectionUtility.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
{ {
m_inputModule = new LegacyInput(); m_inputModule = new LegacyInput();
CurrentType = InputType.Legacy; CurrentType = InputType.Legacy;
return;
} }
if (m_inputModule == null)
{
ExplorerCore.LogWarning("Could not find any Input Module Type!"); ExplorerCore.LogWarning("Could not find any Input Module Type!");
m_inputModule = new NoInput(); m_inputModule = new NoInput();
CurrentType = InputType.None; CurrentType = InputType.None;
} }
CursorUnlocker.Init();
}
} }
} }