added float axis support and gameplay scene

This commit is contained in:
MrTorex committed 2026-01-30 18:25:35 +03:00
1 parent 12ec4f72f5
commit 158850aa45
8 files changed
+1519 -9

No files matched your search

+1 -3
View File
@@ -11,9 +11,7 @@ namespace Code.Input
Vector2 MainMenuParalax { get; }
Vector2 LookInput { get; }
Vector2 MoveInput { get; }
bool SwitchCameraPressed { get; }
float MoveInput { get; }
void DebugBindAction(int mapId, int actionId, Action<InputAction.CallbackContext> action);
+13 -6
View File
@@ -10,9 +10,7 @@ namespace Code.Input
public Vector2 MainMenuParalax { get; private set; }
public Vector2 LookInput { get; private set; }
public Vector2 MoveInput { get; private set; }
public bool SwitchCameraPressed { get; private set; }
public float MoveInput { get; private set; }
public InputService(InputActionAsset inputActionAsset)
{
@@ -29,9 +27,7 @@ namespace Code.Input
private void SetupGameplayInputCallbacks()
{
var map = _inputActionAsset.actionMaps[(int)ActionMapping.Gameplay];
BindVector2(map, "Look", v => LookInput = v);
BindVector2(map, "Move", v => MoveInput = v);
BindButton(map, "SwitchCamera", v => SwitchCameraPressed = v);
BindAxis(map, "Move", v => MoveInput = v);
}
private void SetupMainMenuInputCallbacks()
@@ -61,6 +57,17 @@ namespace Code.Input
action.performed += ctx => setter(ctx.ReadValue<Vector2>());
action.canceled += _ => setter(Vector2.zero);
}
private void BindAxis(InputActionMap map, string actionName, System.Action<float> setter)
{
var action = map.FindAction(actionName);
if (action == null)
return;
action.performed += ctx => setter(ctx.ReadValue<float>());
action.canceled += _ => setter(0f);
}
public void EnableMap(ActionMapping actionMap)
{
+22
View File
@@ -0,0 +1,22 @@
using Code.DI;
using Code.Input;
using UnityEngine;
namespace Code.UI
{
public class GameplayController : MonoBehaviour
{
private IInputService _inputService;
public void Start()
{
_inputService = FindFirstObjectByType<DIContainer>().Resolve<IInputService>();
_inputService.EnableMap(ActionMapping.Gameplay);
}
public void Update()
{
Debug.Log(_inputService.MoveInput);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6eba792e8ea4481b8819feb8542a117c
timeCreated: 1769785776