Proper input layering with console
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"ID": "cb74184545f392e5c67815808bc63e58",
|
"ID": "cb74184545f392e5c67815808bc63e58",
|
||||||
"TypeName": "FlaxEngine.Prefab",
|
"TypeName": "FlaxEngine.Prefab",
|
||||||
"EngineBuild": 6332,
|
"EngineBuild": 6606,
|
||||||
"Data": [
|
"Data": [
|
||||||
{
|
{
|
||||||
"ID": "9e1b61dc44338f962e69f78ecb3d0536",
|
"ID": "9e1b61dc44338f962e69f78ecb3d0536",
|
||||||
@@ -28,7 +28,9 @@
|
|||||||
"B": 0.0,
|
"B": 0.0,
|
||||||
"A": 1.0
|
"A": 1.0
|
||||||
},
|
},
|
||||||
"ConsoleFont": "43f32bec443158643f53699f07b2e09c"
|
"ConsoleFont": "43f32bec443158643f53699f07b2e09c",
|
||||||
|
"InputSettingsGameplay": "8ec53dba4c238bfbea1d62922e612a4d",
|
||||||
|
"InputSettingsMenu": "d1c7e5f241c7c7602e84a39a31d6b532"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -46,6 +48,9 @@
|
|||||||
"Control": "FlaxEngine.GUI.Label",
|
"Control": "FlaxEngine.GUI.Label",
|
||||||
"Data": {
|
"Data": {
|
||||||
"Text": "120fps",
|
"Text": "120fps",
|
||||||
|
"CaseOption": 0,
|
||||||
|
"Bold": false,
|
||||||
|
"Italic": false,
|
||||||
"TextColor": {
|
"TextColor": {
|
||||||
"R": 1.0,
|
"R": 1.0,
|
||||||
"G": 1.0,
|
"G": 1.0,
|
||||||
@@ -61,9 +66,10 @@
|
|||||||
"HorizontalAlignment": 2,
|
"HorizontalAlignment": 2,
|
||||||
"VerticalAlignment": 2,
|
"VerticalAlignment": 2,
|
||||||
"Wrapping": 0,
|
"Wrapping": 0,
|
||||||
|
"BaseLinesGapScale": 1.0,
|
||||||
"Font": {
|
"Font": {
|
||||||
"Font": "43f32bec443158643f53699f07b2e09c",
|
"Font": "43f32bec443158643f53699f07b2e09c",
|
||||||
"Size": 15
|
"Size": 15.0
|
||||||
},
|
},
|
||||||
"Material": null,
|
"Material": null,
|
||||||
"Margin": {
|
"Margin": {
|
||||||
@@ -115,6 +121,7 @@
|
|||||||
"B": 0.0,
|
"B": 0.0,
|
||||||
"A": 0.0
|
"A": 0.0
|
||||||
},
|
},
|
||||||
|
"BackgroundBrush": null,
|
||||||
"Enabled": true,
|
"Enabled": true,
|
||||||
"Visible": true,
|
"Visible": true,
|
||||||
"AutoFocus": false
|
"AutoFocus": false
|
||||||
|
|||||||
74
Content/Settings/EngineSettings/MenuInputSettings.json
Normal file
74
Content/Settings/EngineSettings/MenuInputSettings.json
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
{
|
||||||
|
"ID": "d1c7e5f241c7c7602e84a39a31d6b532",
|
||||||
|
"TypeName": "FlaxEditor.Content.Settings.InputSettings",
|
||||||
|
"EngineBuild": 6606,
|
||||||
|
"Data": {
|
||||||
|
"ActionMappings": [
|
||||||
|
{
|
||||||
|
"Name": "Exit",
|
||||||
|
"Mode": 1,
|
||||||
|
"Key": 27,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "DebugTrigger1",
|
||||||
|
"Mode": 2,
|
||||||
|
"Key": 112,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "DebugTrigger2",
|
||||||
|
"Mode": 2,
|
||||||
|
"Key": 113,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "DebugTrigger3",
|
||||||
|
"Mode": 2,
|
||||||
|
"Key": 114,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Console",
|
||||||
|
"Mode": 1,
|
||||||
|
"Key": 220,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Console",
|
||||||
|
"Mode": 1,
|
||||||
|
"Key": 223,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Console",
|
||||||
|
"Mode": 1,
|
||||||
|
"Key": 192,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "ClearConsole",
|
||||||
|
"Mode": 1,
|
||||||
|
"Key": 66,
|
||||||
|
"MouseButton": 0,
|
||||||
|
"GamepadButton": 0,
|
||||||
|
"Gamepad": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"AxisMappings": []
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,8 +26,8 @@ public class CameraMovement : Script
|
|||||||
Actor rootActor = Actor.GetChild(0);
|
Actor rootActor = Actor.GetChild(0);
|
||||||
Camera camera = rootActor.GetChild<Camera>();
|
Camera camera = rootActor.GetChild<Camera>();
|
||||||
|
|
||||||
float xAxis = InputManager.GetAxisRaw("Mouse X");
|
float xAxis = Input.GetAxisRaw("Mouse X");
|
||||||
float yAxis = InputManager.GetAxisRaw("Mouse Y");
|
float yAxis = Input.GetAxisRaw("Mouse Y");
|
||||||
if (xAxis != 0.0f || yAxis != 0.0f)
|
if (xAxis != 0.0f || yAxis != 0.0f)
|
||||||
{
|
{
|
||||||
viewPitch += yAxis;
|
viewPitch += yAxis;
|
||||||
@@ -40,8 +40,8 @@ public class CameraMovement : Script
|
|||||||
camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll);
|
camera.Orientation = Quaternion.Euler(viewPitch, viewYaw, viewRoll);
|
||||||
}
|
}
|
||||||
|
|
||||||
float inputH = InputManager.GetAxis("Horizontal");
|
float inputH = Input.GetAxis("Horizontal");
|
||||||
float inputV = InputManager.GetAxis("Vertical");
|
float inputV = Input.GetAxis("Vertical");
|
||||||
Float3 move = new Float3(inputH, 0.0f, inputV);
|
Float3 move = new Float3(inputH, 0.0f, inputV);
|
||||||
|
|
||||||
if (!move.IsZero)
|
if (!move.IsZero)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using FlaxEditor;
|
using FlaxEditor;
|
||||||
|
using FlaxEditor.Content.Settings;
|
||||||
using FlaxEngine;
|
using FlaxEngine;
|
||||||
using FlaxEngine.Assertions;
|
using FlaxEngine.Assertions;
|
||||||
using FlaxEngine.GUI;
|
using FlaxEngine.GUI;
|
||||||
@@ -13,23 +14,27 @@ public class ConsoleScript : Script
|
|||||||
public Color BackgroundColor;
|
public Color BackgroundColor;
|
||||||
|
|
||||||
public Texture BackgroundTexture;
|
public Texture BackgroundTexture;
|
||||||
private ConsoleContentTextBox consoleBox;
|
|
||||||
|
|
||||||
public FontAsset ConsoleFont;
|
public FontAsset ConsoleFont;
|
||||||
|
|
||||||
[Limit(5, 720)] public int ConsoleFontSize = 16;
|
[Limit(5, 720)] public int ConsoleFontSize = 16;
|
||||||
|
|
||||||
[Limit(0.05f, 1.0f)] public float ConsoleHeight = 0.65f;
|
[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(0)] public int ConsoleNotifyLines = 15;
|
||||||
|
|
||||||
[Limit(0f)] public float ConsoleSpeed = 3500f;
|
[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;
|
private int fontHeight;
|
||||||
|
|
||||||
public override void OnStart()
|
public override void OnStart()
|
||||||
@@ -259,6 +264,8 @@ public class ConsoleScript : Script
|
|||||||
|
|
||||||
consoleInputBox.Focus();
|
consoleInputBox.Focus();
|
||||||
Parent.As<UICanvas>().ReceivesEvents = true;
|
Parent.As<UICanvas>().ReceivesEvents = true;
|
||||||
|
|
||||||
|
Input.SetInputMappingFromSettings(InputSettingsMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnConsoleClose()
|
public void OnConsoleClose()
|
||||||
@@ -271,6 +278,7 @@ public class ConsoleScript : Script
|
|||||||
Editor.Instance.Windows.GameWin.Focus();
|
Editor.Instance.Windows.GameWin.Focus();
|
||||||
#endif
|
#endif
|
||||||
Parent.As<UICanvas>().ReceivesEvents = false;
|
Parent.As<UICanvas>().ReceivesEvents = false;
|
||||||
|
Input.SetInputMappingFromSettings(InputSettingsGameplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUpdate()
|
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;
|
float sensitivity = 1.0f / 8.0f;
|
||||||
sensitivity = 1.0f;
|
sensitivity = 1.0f;
|
||||||
|
|
||||||
//var asf = InputManager.GetAxisRaw("Mouse X");
|
//var asf = Input.GetAxisRaw("Mouse X");
|
||||||
//if (asf != 0.0f)
|
//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.viewDeltaX += Input.GetAxisRaw("Mouse X") * sensitivity;
|
||||||
currentState.input.viewDeltaY += InputManager.GetAxisRaw("Mouse Y") * sensitivity;
|
currentState.input.viewDeltaY += Input.GetAxisRaw("Mouse Y") * sensitivity;
|
||||||
currentState.input.viewDeltaX += InputManager.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
|
currentState.input.viewDeltaX += Input.GetAxisRaw("LookRight") * Time.DeltaTime * 100;
|
||||||
currentState.input.viewDeltaY += -InputManager.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
|
currentState.input.viewDeltaY += -Input.GetAxisRaw("LookUp") * Time.DeltaTime * 100;
|
||||||
|
|
||||||
currentState.input.moveForward = InputManager.GetAxis("Vertical");
|
currentState.input.moveForward = Input.GetAxis("Vertical");
|
||||||
currentState.input.moveRight = InputManager.GetAxis("Horizontal");
|
currentState.input.moveRight = Input.GetAxis("Horizontal");
|
||||||
currentState.input.attacking = InputManager.GetAction("Attack");
|
currentState.input.attacking = Input.GetAction("Attack");
|
||||||
currentState.input.jumping = InputManager.GetAction("Jump");
|
currentState.input.jumping = Input.GetAction("Jump");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user