mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-15 22:07:48 +08:00
Cleanups
This commit is contained in:
parent
e309821743
commit
b012e2305c
@ -220,6 +220,7 @@
|
|||||||
<Compile Include="Input\InputManager.cs" />
|
<Compile Include="Input\InputManager.cs" />
|
||||||
<Compile Include="Input\InputSystem.cs" />
|
<Compile Include="Input\InputSystem.cs" />
|
||||||
<Compile Include="Input\LegacyInput.cs" />
|
<Compile Include="Input\LegacyInput.cs" />
|
||||||
|
<Compile Include="Input\NoInput.cs" />
|
||||||
<Compile Include="Menu\CursorControl.cs" />
|
<Compile Include="Menu\CursorControl.cs" />
|
||||||
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
|
<Compile Include="Menu\MainMenu\Pages\OptionsPage.cs" />
|
||||||
<Compile Include="Tests\TestClass.cs" />
|
<Compile Include="Tests\TestClass.cs" />
|
||||||
|
@ -14,7 +14,7 @@ using BepInEx.IL2CPP;
|
|||||||
|
|
||||||
namespace Explorer
|
namespace Explorer
|
||||||
{
|
{
|
||||||
[BepInPlugin(ExplorerCore.GUID, ExplorerCore.NAME, ExplorerCore.VERSION)]
|
[BepInPlugin(ExplorerCore.GUID, "Explorer", ExplorerCore.VERSION)]
|
||||||
#if CPP
|
#if CPP
|
||||||
public class ExplorerBepInPlugin : BasePlugin
|
public class ExplorerBepInPlugin : BasePlugin
|
||||||
#else
|
#else
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Target Name="ILRepacker" AfterTargets="Build">
|
<Target Name="ILRepacker" AfterTargets="Build">
|
||||||
|
|
||||||
<!-- Merging DLLs -->
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
|
<InputAssemblies Include="$(OutputPath)$(AssemblyName).dll" />
|
||||||
<InputAssemblies Include="..\lib\mcs.dll" />
|
<InputAssemblies Include="..\lib\mcs.dll" />
|
||||||
|
@ -7,19 +7,12 @@ namespace Explorer
|
|||||||
{
|
{
|
||||||
public static class InputManager
|
public static class InputManager
|
||||||
{
|
{
|
||||||
// If no Input modules loaded at all
|
|
||||||
public static bool NO_INPUT { get; private set; }
|
|
||||||
|
|
||||||
// If using new InputSystem module
|
|
||||||
public static bool USING_NEW_INPUT { get; private set; }
|
|
||||||
|
|
||||||
private static AbstractInput inputModule;
|
private static AbstractInput inputModule;
|
||||||
|
|
||||||
public static void Init()
|
public static void Init()
|
||||||
{
|
{
|
||||||
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
|
if (InputSystem.TKeyboard != null || TryLoadModule("Unity.InputSystem", InputSystem.TKeyboard))
|
||||||
{
|
{
|
||||||
USING_NEW_INPUT = true;
|
|
||||||
inputModule = new InputSystem();
|
inputModule = new InputSystem();
|
||||||
}
|
}
|
||||||
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.Input", LegacyInput.TInput))
|
else if (LegacyInput.TInput != null || TryLoadModule("UnityEngine.Input", LegacyInput.TInput))
|
||||||
@ -30,26 +23,20 @@ namespace Explorer
|
|||||||
if (inputModule == null)
|
if (inputModule == null)
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning("Could not find any Input module!");
|
ExplorerCore.LogWarning("Could not find any Input module!");
|
||||||
NO_INPUT = true;
|
inputModule = new NoInput();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
inputModule.Init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inputModule.Init();
|
||||||
|
|
||||||
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
|
bool TryLoadModule(string dll, Type check) => ReflectionHelpers.LoadModule(dll) && check != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Vector3 MousePosition => inputModule?.MousePosition ?? Vector3.zero;
|
public static Vector3 MousePosition => inputModule.MousePosition;
|
||||||
|
|
||||||
public static bool GetKeyDown(KeyCode key) => inputModule?.GetKeyDown(key) ?? false;
|
public static bool GetKeyDown(KeyCode key) => inputModule.GetKeyDown(key);
|
||||||
|
public static bool GetKey(KeyCode key) => inputModule.GetKey(key);
|
||||||
|
|
||||||
public static bool GetKey(KeyCode key) => inputModule?.GetKey(key) ?? false;
|
public static bool GetMouseButtonDown(int btn) => inputModule.GetMouseButtonDown(btn);
|
||||||
|
public static bool GetMouseButton(int btn) => inputModule.GetMouseButton(btn);
|
||||||
/// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
|
|
||||||
public static bool GetMouseButtonDown(int btn) => inputModule?.GetMouseButtonDown(btn) ?? false;
|
|
||||||
|
|
||||||
/// <param name="btn">0 = left, 1 = right, 2 = middle.</param>
|
|
||||||
public static bool GetMouseButton(int btn) => inputModule?.GetMouseButton(btn) ?? false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
25
src/Input/NoInput.cs
Normal file
25
src/Input/NoInput.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Explorer.Input
|
||||||
|
{
|
||||||
|
// Just a stub for games where no Input module was able to load at all.
|
||||||
|
|
||||||
|
public class NoInput : AbstractInput
|
||||||
|
{
|
||||||
|
public override Vector2 MousePosition => Vector2.zero;
|
||||||
|
|
||||||
|
public override bool GetKey(KeyCode key) => false;
|
||||||
|
|
||||||
|
public override bool GetKeyDown(KeyCode key) => false;
|
||||||
|
|
||||||
|
public override bool GetMouseButton(int btn) => false;
|
||||||
|
|
||||||
|
public override bool GetMouseButtonDown(int btn) => false;
|
||||||
|
|
||||||
|
public override void Init() { }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user