mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 06:08:16 +08:00
43 lines
1.4 KiB
C#
43 lines
1.4 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using UnityExplorer.Helpers;
|
|
using System.Diagnostics.CodeAnalysis;
|
|
#if CPP
|
|
using UnhollowerBaseLib;
|
|
#endif
|
|
|
|
namespace UnityExplorer.Input
|
|
{
|
|
public static class InputManager
|
|
{
|
|
private static IHandleInput m_inputModule;
|
|
|
|
public static Vector3 MousePosition => m_inputModule.MousePosition;
|
|
|
|
public static bool GetKeyDown(KeyCode key) => m_inputModule.GetKeyDown(key);
|
|
public static bool GetKey(KeyCode key) => m_inputModule.GetKey(key);
|
|
|
|
public static bool GetMouseButtonDown(int btn) => m_inputModule.GetMouseButtonDown(btn);
|
|
public static bool GetMouseButton(int btn) => m_inputModule.GetMouseButton(btn);
|
|
|
|
public static void Init()
|
|
{
|
|
#if CPP
|
|
if (InputSystem.TKeyboard != null || (ReflectionHelpers.LoadModule("Unity.InputSystem") && InputSystem.TKeyboard != null))
|
|
{
|
|
m_inputModule = new InputSystem();
|
|
}
|
|
else if (LegacyInput.TInput != null || (ReflectionHelpers.LoadModule("UnityEngine.InputLegacyModule") && LegacyInput.TInput != null))
|
|
{
|
|
m_inputModule = new LegacyInput();
|
|
}
|
|
#endif
|
|
|
|
if (m_inputModule == null)
|
|
{
|
|
ExplorerCore.LogWarning("Could not find any Input module!");
|
|
m_inputModule = new NoInput();
|
|
}
|
|
}
|
|
}
|
|
} |