Proper input layering with console
This commit is contained in:
@@ -26,8 +26,8 @@ public class CameraMovement : Script
|
||||
Actor rootActor = Actor.GetChild(0);
|
||||
Camera camera = rootActor.GetChild<Camera>();
|
||||
|
||||
float xAxis = InputManager.GetAxisRaw("Mouse X");
|
||||
float yAxis = InputManager.GetAxisRaw("Mouse Y");
|
||||
float xAxis = Input.GetAxisRaw("Mouse X");
|
||||
float yAxis = Input.GetAxisRaw("Mouse Y");
|
||||
if (xAxis != 0.0f || yAxis != 0.0f)
|
||||
{
|
||||
viewPitch += yAxis;
|
||||
@@ -40,8 +40,8 @@ public class CameraMovement : Script
|
||||
camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll);
|
||||
}
|
||||
|
||||
float inputH = InputManager.GetAxis("Horizontal");
|
||||
float inputV = InputManager.GetAxis("Vertical");
|
||||
float inputH = Input.GetAxis("Horizontal");
|
||||
float inputV = Input.GetAxis("Vertical");
|
||||
Float3 move = new Float3(inputH, 0.0f, inputV);
|
||||
|
||||
if (!move.IsZero)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using FlaxEditor;
|
||||
using FlaxEditor.Content.Settings;
|
||||
using FlaxEngine;
|
||||
using FlaxEngine.Assertions;
|
||||
using FlaxEngine.GUI;
|
||||
@@ -13,23 +14,27 @@ public class ConsoleScript : Script
|
||||
public Color BackgroundColor;
|
||||
|
||||
public Texture BackgroundTexture;
|
||||
private ConsoleContentTextBox consoleBox;
|
||||
|
||||
|
||||
public FontAsset ConsoleFont;
|
||||
|
||||
[Limit(5, 720)] public int ConsoleFontSize = 16;
|
||||
|
||||
[Limit(0.05f, 1.0f)] public float ConsoleHeight = 0.65f;
|
||||
private ConsoleInputTextBox consoleInputBox;
|
||||
|
||||
internal InputEvent consoleInputEvent;
|
||||
private ConsoleContentTextBox consoleNotifyBox;
|
||||
|
||||
[Limit(0)] public int ConsoleNotifyLines = 15;
|
||||
|
||||
[Limit(0f)] public float ConsoleSpeed = 3500f;
|
||||
|
||||
private UIControl rootControl;
|
||||
public JsonAssetReference<InputSettings> InputSettingsGameplay;
|
||||
|
||||
public JsonAssetReference<InputSettings> InputSettingsMenu;
|
||||
|
||||
|
||||
private ConsoleInputTextBox consoleInputBox;
|
||||
internal InputEvent consoleInputEvent;
|
||||
private ConsoleContentTextBox consoleBox;
|
||||
private ConsoleContentTextBox consoleNotifyBox;
|
||||
private UIControl rootControl;
|
||||
private int fontHeight;
|
||||
|
||||
public override void OnStart()
|
||||
@@ -259,6 +264,8 @@ public class ConsoleScript : Script
|
||||
|
||||
consoleInputBox.Focus();
|
||||
Parent.As<UICanvas>().ReceivesEvents = true;
|
||||
|
||||
Input.SetInputMappingFromSettings(InputSettingsMenu);
|
||||
}
|
||||
|
||||
public void OnConsoleClose()
|
||||
@@ -271,6 +278,7 @@ public class ConsoleScript : Script
|
||||
Editor.Instance.Windows.GameWin.Focus();
|
||||
#endif
|
||||
Parent.As<UICanvas>().ReceivesEvents = false;
|
||||
Input.SetInputMappingFromSettings(InputSettingsGameplay);
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
using FlaxEngine;
|
||||
|
||||
namespace Game;
|
||||
|
||||
public static class InputManager
|
||||
{
|
||||
public static bool GetAction(string name)
|
||||
{
|
||||
if (Console.IsOpen)
|
||||
return false;
|
||||
return Input.GetAction(name);
|
||||
}
|
||||
|
||||
public static float GetAxis(string name)
|
||||
{
|
||||
if (Console.IsOpen)
|
||||
return 0.0f;
|
||||
return Input.GetAxis(name);
|
||||
}
|
||||
|
||||
public static float GetAxisRaw(string name)
|
||||
{
|
||||
if (Console.IsOpen)
|
||||
return 0.0f;
|
||||
return Input.GetAxisRaw(name);
|
||||
}
|
||||
}
|
||||
@@ -51,19 +51,19 @@ public class PlayerInputLocal : PlayerInput
|
||||
float sensitivity = 1.0f / 8.0f;
|
||||
sensitivity = 1.0f;
|
||||
|
||||
//var asf = InputManager.GetAxisRaw("Mouse X");
|
||||
//var asf = Input.GetAxisRaw("Mouse X");
|
||||
//if (asf != 0.0f)
|
||||
// Console.Print(InputManager.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture));
|
||||
// Console.Print(Input.GetAxisRaw("Mouse X").ToString("G9", System.Globalization.CultureInfo.InvariantCulture));
|
||||
|
||||
currentState.input.viewDeltaX += InputManager.GetAxisRaw("Mouse X") * sensitivity;
|
||||
currentState.input.viewDeltaY += InputManager.GetAxisRaw("Mouse Y") * sensitivity;
|
||||
currentState.input.viewDeltaX += InputManager.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
|
||||
currentState.input.viewDeltaY += -InputManager.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
|
||||
currentState.input.viewDeltaX += Input.GetAxisRaw("Mouse X") * sensitivity;
|
||||
currentState.input.viewDeltaY += Input.GetAxisRaw("Mouse Y") * sensitivity;
|
||||
currentState.input.viewDeltaX += Input.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
|
||||
currentState.input.viewDeltaY += -Input.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
|
||||
|
||||
currentState.input.moveForward = InputManager.GetAxis("Vertical");
|
||||
currentState.input.moveRight = InputManager.GetAxis("Horizontal");
|
||||
currentState.input.attacking = InputManager.GetAction("Attack");
|
||||
currentState.input.jumping = InputManager.GetAction("Jump");
|
||||
currentState.input.moveForward = Input.GetAxis("Vertical");
|
||||
currentState.input.moveRight = Input.GetAxis("Horizontal");
|
||||
currentState.input.attacking = Input.GetAction("Attack");
|
||||
currentState.input.jumping = Input.GetAction("Jump");
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user