mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2026-10-10 13:03:15 +08:00
Wrapped the InputManager so I can disable the games input when we enable the freecam (if it's using Unity's input solution).
This commit is contained in:
@@ -227,11 +227,11 @@ namespace UnityExplorer.CSConsole
|
||||
if (SRENotSupported)
|
||||
return;
|
||||
|
||||
if (!InputManager.GetKey(KeyCode.LeftControl) && !InputManager.GetKey(KeyCode.RightControl))
|
||||
if (!IInputManager.GetKey(KeyCode.LeftControl) && !IInputManager.GetKey(KeyCode.RightControl))
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.Home))
|
||||
if (IInputManager.GetKeyDown(KeyCode.Home))
|
||||
JumpToStartOrEndOfLine(true);
|
||||
else if (InputManager.GetKeyDown(KeyCode.End))
|
||||
else if (IInputManager.GetKeyDown(KeyCode.End))
|
||||
JumpToStartOrEndOfLine(false);
|
||||
}
|
||||
|
||||
@@ -250,8 +250,8 @@ namespace UnityExplorer.CSConsole
|
||||
}
|
||||
|
||||
if (EnableCtrlRShortcut
|
||||
&& (InputManager.GetKey(KeyCode.LeftControl) || InputManager.GetKey(KeyCode.RightControl))
|
||||
&& InputManager.GetKeyDown(KeyCode.R)
|
||||
&& (IInputManager.GetKey(KeyCode.LeftControl) || IInputManager.GetKey(KeyCode.RightControl))
|
||||
&& IInputManager.GetKeyDown(KeyCode.R)
|
||||
&& timeOfLastCtrlR.OccuredEarlierThanDefault())
|
||||
{
|
||||
timeOfLastCtrlR = Time.realtimeSinceStartup;
|
||||
@@ -267,7 +267,7 @@ namespace UnityExplorer.CSConsole
|
||||
return;
|
||||
|
||||
// prevent escape wiping input
|
||||
if (InputManager.GetKeyDown(KeyCode.Escape))
|
||||
if (IInputManager.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
Input.Text = previousInput;
|
||||
|
||||
|
||||
@@ -0,0 +1,235 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Panels;
|
||||
using UniverseLib.Input;
|
||||
|
||||
namespace UnityExplorer
|
||||
{
|
||||
|
||||
public class IInputManager {
|
||||
|
||||
private static Dictionary<KeyCode, bool> getKeyDict = new Dictionary<KeyCode, bool>();
|
||||
private static Dictionary<KeyCode, bool> getKeyDownDict = new Dictionary<KeyCode, bool>();
|
||||
private static Dictionary<KeyCode, bool> getKeyUpDict = new Dictionary<KeyCode, bool>();
|
||||
|
||||
private static Dictionary<int, bool> getMouseButton = new Dictionary<int, bool>();
|
||||
private static Dictionary<int, bool> getMouseButtonDown = new Dictionary<int, bool>();
|
||||
|
||||
public static Vector3 MousePosition => InputManager.MousePosition;
|
||||
|
||||
public static void Setup(){
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyTarget = typeof(Input).GetMethod("GetKey", new Type[] {typeof(string)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyString))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyTarget = typeof(Input).GetMethod("GetKey", new Type[] {typeof(KeyCode)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyKeyCode))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyDownTarget = typeof(Input).GetMethod("GetKeyDown", new Type[] {typeof(string)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyDownTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyDownTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyDownString))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyDownTarget = typeof(Input).GetMethod("GetKeyDown", new Type[] {typeof(KeyCode)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyDownTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyDownTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyDownKeyCode))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyUpTarget = typeof(Input).GetMethod("GetKeyUp", new Type[] {typeof(string)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyUpTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyUpTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyUpString))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getKeyUpTarget = typeof(Input).GetMethod("GetKeyUp", new Type[] {typeof(KeyCode)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getKeyUpTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getKeyUpTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideKeyUpKeyCode))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getMouseButtonTarget = typeof(Input).GetMethod("GetMouseButton", new Type[] {typeof(int)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getMouseButtonTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getMouseButtonTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideMouseButton))));
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
MethodInfo getMouseButtonDownTarget = typeof(Input).GetMethod("GetMouseButtonDown", new Type[] {typeof(int)});
|
||||
#if CPP
|
||||
if (IL2CPPUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(getMouseButtonDownTarget) == null)
|
||||
return;
|
||||
#endif
|
||||
ExplorerCore.Harmony.Patch(getMouseButtonDownTarget,
|
||||
postfix: new(AccessTools.Method(typeof(IInputManager), nameof(OverrideMouseButtonDown))));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// Postfix functions
|
||||
|
||||
public static void OverrideKeyString(ref bool __result, ref string key)
|
||||
{
|
||||
KeyCode thisKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), key);
|
||||
getKeyDict[thisKeyCode] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideKeyKeyCode(ref bool __result, ref KeyCode key)
|
||||
{
|
||||
if (key == KeyCode.None) return;
|
||||
|
||||
getKeyDict[key] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideKeyDownString(ref bool __result, ref string key)
|
||||
{
|
||||
KeyCode thisKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), key);
|
||||
getKeyDownDict[thisKeyCode] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideKeyDownKeyCode(ref bool __result, ref KeyCode key)
|
||||
{
|
||||
if (key == KeyCode.None) return;
|
||||
|
||||
getKeyDownDict[key] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideKeyUpString(ref bool __result, ref string key)
|
||||
{
|
||||
KeyCode thisKeyCode = (KeyCode) System.Enum.Parse(typeof(KeyCode), key);
|
||||
getKeyUpDict[thisKeyCode] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideKeyUpKeyCode(ref bool __result, ref KeyCode key)
|
||||
{
|
||||
if (key == KeyCode.None) return;
|
||||
|
||||
getKeyUpDict[key] = __result;
|
||||
if (FreeCamPanel.ShouldOverrideInput()){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideMouseButton(ref bool __result, ref int button)
|
||||
{
|
||||
getMouseButton[button] = __result;
|
||||
// Since UnityExplorer uses Unity's native UI for its menu, we can't switch off the mouse interaction with it on this wrapper.
|
||||
// Therefore, if we still want to interact with the Unity Explorer menu we would need to let the button action pass through when it's open.
|
||||
if (FreeCamPanel.ShouldOverrideInput() && !(button == 0 && UIManager.ShowMenu)){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OverrideMouseButtonDown(ref bool __result, ref int button)
|
||||
{
|
||||
getMouseButtonDown[button] = __result;
|
||||
// Since UnityExplorer uses Unity's native UI for its menu, we can't switch off the mouse interaction with it on this wrapper.
|
||||
// Therefore, if we still want to interact with the Unity Explorer menu we would need to let the button action pass through when it's open.
|
||||
if (FreeCamPanel.ShouldOverrideInput() && button != 0){
|
||||
__result = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapped methods
|
||||
|
||||
public static bool GetKey(KeyCode key){
|
||||
if (key == KeyCode.None) return false;
|
||||
// Trigger the original InputManager method
|
||||
InputManager.GetKey(key);
|
||||
return getKeyDict[key];
|
||||
}
|
||||
|
||||
public static bool GetKeyDown(KeyCode key){
|
||||
if (key == KeyCode.None) return false;
|
||||
// Trigger the original InputManager method
|
||||
InputManager.GetKeyDown(key);
|
||||
return getKeyDownDict[key];
|
||||
}
|
||||
|
||||
public static bool GetKeyUp(KeyCode key){
|
||||
if (key == KeyCode.None) return false;
|
||||
// Trigger the original InputManager method
|
||||
InputManager.GetKeyUp(key);
|
||||
return getKeyUpDict[key];
|
||||
}
|
||||
|
||||
public static bool GetMouseButton(int button){
|
||||
// Trigger the original InputManager method
|
||||
InputManager.GetMouseButton(button);
|
||||
return getMouseButton[button];
|
||||
}
|
||||
|
||||
public static bool GetMouseButtonDown(int button){
|
||||
// Trigger the original InputManager method
|
||||
InputManager.GetMouseButtonDown(button);
|
||||
return getMouseButtonDown[button];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,13 +105,13 @@ namespace UnityExplorer
|
||||
maybeForcePause();
|
||||
UIManager.GetPanel<UnityExplorer.UI.Panels.Misc>(UIManager.Panels.Misc).MaybeTakeScreenshot();
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.Pause.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Pause.Value))
|
||||
{
|
||||
UIManager.GetTimeScaleWidget().PauseToggle();
|
||||
}
|
||||
|
||||
// FrameSkip
|
||||
if (InputManager.GetKeyDown(ConfigManager.Frameskip.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Frameskip.Value))
|
||||
{
|
||||
if (UIManager.GetTimeScaleWidget().IsPaused()) {
|
||||
UIManager.GetTimeScaleWidget().PauseToggle();
|
||||
@@ -119,22 +119,22 @@ namespace UnityExplorer
|
||||
}
|
||||
}
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.Screenshot.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Screenshot.Value))
|
||||
{
|
||||
UIManager.GetPanel<UnityExplorer.UI.Panels.Misc>(UIManager.Panels.Misc).screenshotStatus = UnityExplorer.UI.Panels.Misc.ScreenshotState.TurnOffUI;
|
||||
}
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.HUD_Toggle.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.HUD_Toggle.Value))
|
||||
{
|
||||
UIManager.GetPanel<UnityExplorer.UI.Panels.Misc>(UIManager.Panels.Misc).ToggleHUDElements();
|
||||
}
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.Freecam_Toggle.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Freecam_Toggle.Value))
|
||||
{
|
||||
FreeCamPanel.StartStopButton_OnClick();
|
||||
}
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.Block_Freecam_Movement.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Block_Freecam_Movement.Value))
|
||||
{
|
||||
FreeCamPanel.blockFreecamMovementToggle.isOn = !FreeCamPanel.blockFreecamMovementToggle.isOn;
|
||||
}
|
||||
|
||||
+2
-1
@@ -59,6 +59,7 @@ namespace UnityExplorer
|
||||
|
||||
//Extra inits
|
||||
KeypressListener.Setup();
|
||||
IInputManager.Setup();
|
||||
}
|
||||
|
||||
// Do a delayed setup so that objects aren't destroyed instantly.
|
||||
@@ -80,7 +81,7 @@ namespace UnityExplorer
|
||||
internal static void Update()
|
||||
{
|
||||
// check master toggle
|
||||
if (InputManager.GetKeyDown(ConfigManager.Master_Toggle.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Master_Toggle.Value))
|
||||
{
|
||||
UIManager.ShowMenu = !UIManager.ShowMenu;
|
||||
}
|
||||
|
||||
@@ -113,10 +113,10 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public bool TryUpdate()
|
||||
{
|
||||
if (InputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.World_MouseInspect_Keybind.Value))
|
||||
Instance.StartInspect(MouseInspectMode.World, inspectorAction);
|
||||
|
||||
if (InputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.UI_MouseInspect_Keybind.Value))
|
||||
Instance.StartInspect(MouseInspectMode.UI, inspectorAction);
|
||||
|
||||
if (Inspecting)
|
||||
@@ -127,20 +127,20 @@ namespace UnityExplorer.Inspectors
|
||||
|
||||
public void UpdateInspect()
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.Escape))
|
||||
if (IInputManager.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
StopInspect();
|
||||
return;
|
||||
}
|
||||
|
||||
if (InputManager.GetMouseButtonDown(0))
|
||||
if (IInputManager.GetMouseButtonDown(0))
|
||||
{
|
||||
CurrentInspector.OnSelectMouseInspect(inspectorAction);
|
||||
StopInspect();
|
||||
return;
|
||||
}
|
||||
|
||||
Vector3 mousePos = InputManager.MousePosition;
|
||||
Vector3 mousePos = IInputManager.MousePosition;
|
||||
if (mousePos != lastMousePos)
|
||||
UpdatePosition(mousePos);
|
||||
|
||||
|
||||
@@ -13,8 +13,8 @@ namespace UnityExplorer.UI
|
||||
public static int Height => ActiveDisplay.renderingHeight;
|
||||
|
||||
public static Vector3 MousePosition => Application.isEditor
|
||||
? InputManager.MousePosition
|
||||
: Display.RelativeMouseAt(InputManager.MousePosition);
|
||||
? IInputManager.MousePosition
|
||||
: Display.RelativeMouseAt(IInputManager.MousePosition);
|
||||
|
||||
public static bool MouseInTargetDisplay => MousePosition.z == ActiveDisplayIndex;
|
||||
|
||||
|
||||
@@ -100,14 +100,14 @@ namespace UnityExplorer.UI.Panels
|
||||
if (!Suggesting(handler))
|
||||
return false;
|
||||
|
||||
bool up = InputManager.GetKey(KeyCode.UpArrow);
|
||||
bool down = InputManager.GetKey(KeyCode.DownArrow);
|
||||
bool up = IInputManager.GetKey(KeyCode.UpArrow);
|
||||
bool down = IInputManager.GetKey(KeyCode.DownArrow);
|
||||
|
||||
if (up || down)
|
||||
{
|
||||
if (up)
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.UpArrow))
|
||||
if (IInputManager.GetKeyDown(KeyCode.UpArrow))
|
||||
{
|
||||
SetSelectedSuggestion(SelectedIndex - 1);
|
||||
timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f;
|
||||
@@ -120,7 +120,7 @@ namespace UnityExplorer.UI.Panels
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InputManager.GetKeyDown(KeyCode.DownArrow))
|
||||
if (IInputManager.GetKeyDown(KeyCode.DownArrow))
|
||||
{
|
||||
SetSelectedSuggestion(SelectedIndex + 1);
|
||||
timeOfLastNavHold = Time.realtimeSinceStartup + 0.3f;
|
||||
@@ -140,12 +140,12 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
public static bool CheckEnter(ISuggestionProvider handler)
|
||||
{
|
||||
return Suggesting(handler) && InputManager.GetKeyDown(KeyCode.Return);
|
||||
return Suggesting(handler) && IInputManager.GetKeyDown(KeyCode.Return);
|
||||
}
|
||||
|
||||
public static bool CheckEscape(ISuggestionProvider handler)
|
||||
{
|
||||
return Suggesting(handler) && InputManager.GetKeyDown(KeyCode.Escape);
|
||||
return Suggesting(handler) && IInputManager.GetKeyDown(KeyCode.Escape);
|
||||
}
|
||||
|
||||
private static void SetSelectedSuggestion(int index)
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace UnityExplorer.UI.Panels
|
||||
{
|
||||
inFreeCamMode = true;
|
||||
|
||||
previousMousePosition = InputManager.MousePosition;
|
||||
previousMousePosition = IInputManager.MousePosition;
|
||||
|
||||
CacheMainCamera();
|
||||
SetupFreeCamera();
|
||||
@@ -524,6 +524,10 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
UpdateClippingPlanes();
|
||||
}
|
||||
|
||||
public static bool ShouldOverrideInput(){
|
||||
return inFreeCamMode;
|
||||
}
|
||||
}
|
||||
|
||||
internal class FreeCamBehaviour : MonoBehaviour
|
||||
@@ -564,39 +568,39 @@ namespace UnityExplorer.UI.Panels
|
||||
|
||||
float moveSpeed = FreeCamPanel.desiredMoveSpeed * 0.01665f; //"0.01665f" (60fps) in place of Time.DeltaTime. DeltaTime causes issues when game is paused.
|
||||
float speedModifier = 1;
|
||||
if (InputManager.GetKey(ConfigManager.Speed_Up_Movement.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Speed_Up_Movement.Value))
|
||||
speedModifier = 10f;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Speed_Down_Movement.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Speed_Down_Movement.Value))
|
||||
speedModifier = 0.1f;
|
||||
|
||||
moveSpeed *= speedModifier;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Left_1.Value) || InputManager.GetKey(ConfigManager.Left_2.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Left_1.Value) || IInputManager.GetKey(ConfigManager.Left_2.Value))
|
||||
transform.position += transform.right * -1 * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Right_1.Value) || InputManager.GetKey(ConfigManager.Right_2.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Right_1.Value) || IInputManager.GetKey(ConfigManager.Right_2.Value))
|
||||
transform.position += transform.right * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Forwards_1.Value) || InputManager.GetKey(ConfigManager.Forwards_2.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Forwards_1.Value) || IInputManager.GetKey(ConfigManager.Forwards_2.Value))
|
||||
transform.position += transform.forward * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Backwards_1.Value) || InputManager.GetKey(ConfigManager.Backwards_2.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Backwards_1.Value) || IInputManager.GetKey(ConfigManager.Backwards_2.Value))
|
||||
transform.position += transform.forward * -1 * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Up.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Up.Value))
|
||||
transform.position += transform.up * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Down.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Down.Value))
|
||||
transform.position += transform.up * -1 * moveSpeed;
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Tilt_Left.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Tilt_Left.Value))
|
||||
transform.Rotate(0, 0, moveSpeed, Space.Self);
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Tilt_Right.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Tilt_Right.Value))
|
||||
transform.Rotate(0, 0, - moveSpeed, Space.Self);
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Tilt_Reset.Value)){
|
||||
if (IInputManager.GetKey(ConfigManager.Tilt_Reset.Value)){
|
||||
// Extract the forward direction of the original quaternion
|
||||
Vector3 forwardDirection = transform.rotation * Vector3.forward;
|
||||
// Reset the tilt by creating a new quaternion with no tilt
|
||||
@@ -605,9 +609,9 @@ namespace UnityExplorer.UI.Panels
|
||||
transform.rotation = newRotation;
|
||||
}
|
||||
|
||||
if (InputManager.GetMouseButton(1))
|
||||
if (IInputManager.GetMouseButton(1))
|
||||
{
|
||||
Vector3 mouseDelta = InputManager.MousePosition - FreeCamPanel.previousMousePosition;
|
||||
Vector3 mouseDelta = IInputManager.MousePosition - FreeCamPanel.previousMousePosition;
|
||||
if (mouseDelta.x != 0 || mouseDelta.y != 0){
|
||||
// Calculate the mouse movement vector depending on the current camera tilt.
|
||||
float tiltAngle = transform.eulerAngles.z;
|
||||
@@ -622,26 +626,26 @@ namespace UnityExplorer.UI.Panels
|
||||
transform.localEulerAngles = new Vector3(newRotationY, newRotationX, transform.localEulerAngles.z);
|
||||
}
|
||||
|
||||
FreeCamPanel.previousMousePosition = InputManager.MousePosition;
|
||||
FreeCamPanel.previousMousePosition = IInputManager.MousePosition;
|
||||
}
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Decrease_FOV.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Decrease_FOV.Value))
|
||||
{
|
||||
FreeCamPanel.ourCamera.fieldOfView -= moveSpeed;
|
||||
}
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Increase_FOV.Value))
|
||||
if (IInputManager.GetKey(ConfigManager.Increase_FOV.Value))
|
||||
{
|
||||
FreeCamPanel.ourCamera.fieldOfView += moveSpeed;
|
||||
}
|
||||
|
||||
if (InputManager.GetKey(ConfigManager.Reset_FOV.Value)){
|
||||
if (IInputManager.GetKey(ConfigManager.Reset_FOV.Value)){
|
||||
FreeCamPanel.ourCamera.fieldOfView = FreeCamPanel.usingGameCamera ? FreeCamPanel.originalCameraFOV : 60;
|
||||
}
|
||||
|
||||
FreeCamPanel.UpdatePositionInput();
|
||||
|
||||
FreeCamPanel.previousMousePosition = InputManager.MousePosition;
|
||||
FreeCamPanel.previousMousePosition = IInputManager.MousePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -135,7 +135,7 @@ namespace UnityExplorer.UI
|
||||
Notification.Update();
|
||||
|
||||
// Check forceUnlockMouse toggle
|
||||
if (InputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
|
||||
if (IInputManager.GetKeyDown(ConfigManager.Force_Unlock_Toggle.Value))
|
||||
UniverseLib.Config.ConfigManager.Force_Unlock_Mouse = !UniverseLib.Config.ConfigManager.Force_Unlock_Mouse;
|
||||
|
||||
// update the timescale value
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
if (control == null)
|
||||
return;
|
||||
|
||||
if (!InputManager.GetMouseButton(0))
|
||||
if (!IInputManager.GetMouseButton(0))
|
||||
{
|
||||
control.slider.value = 0f;
|
||||
control = null;
|
||||
|
||||
Reference in New Issue
Block a user