added float axis support and gameplay scene
This commit is contained in:
1 parent
12ec4f72f5
commit
158850aa45
8 files changed
+1519
-9
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
@@ -62,6 +58,17 @@ namespace Code.Input
|
||||
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)
|
||||
{
|
||||
_inputActionAsset.actionMaps[(int)actionMap].Enable();
|
||||
|
||||
@@ -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
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f1cd135c65a79ce41b92ef8babb59d1a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -42,6 +42,15 @@
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": false
|
||||
},
|
||||
{
|
||||
"name": "Move",
|
||||
"type": "Value",
|
||||
"id": "41ff2420-c356-4ef0-9971-239000a27d63",
|
||||
"expectedControlType": "Axis",
|
||||
"processors": "",
|
||||
"interactions": "",
|
||||
"initialStateCheck": true
|
||||
}
|
||||
],
|
||||
"bindings": [
|
||||
@@ -55,6 +64,39 @@
|
||||
"action": "New action",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "1D Axis",
|
||||
"id": "41b9c2e0-5dac-4ca5-952f-f628b79afa99",
|
||||
"path": "1DAxis(whichSideWins=1)",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": true,
|
||||
"isPartOfComposite": false
|
||||
},
|
||||
{
|
||||
"name": "negative",
|
||||
"id": "6c1aacd1-fbfa-46a6-80c8-f85fb556c38a",
|
||||
"path": "<Keyboard>/a",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
},
|
||||
{
|
||||
"name": "positive",
|
||||
"id": "92475243-8831-454f-a2a2-158dcc7857bb",
|
||||
"path": "<Keyboard>/d",
|
||||
"interactions": "",
|
||||
"processors": "",
|
||||
"groups": "",
|
||||
"action": "Move",
|
||||
"isComposite": false,
|
||||
"isPartOfComposite": true
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -8,6 +8,9 @@ EditorBuildSettings:
|
||||
- enabled: 1
|
||||
path: Assets/Resources/Scenes/MainMenu.unity
|
||||
guid: 8c9cfa26abfee488c85f1582747f6a02
|
||||
- enabled: 1
|
||||
path: Assets/Resources/Scenes/Gameplay.unity
|
||||
guid: f1cd135c65a79ce41b92ef8babb59d1a
|
||||
m_configObjects:
|
||||
com.unity.input.settings.actions: {fileID: -944628639613478452, guid: 2bcd2660ca9b64942af0de543d8d7100, type: 3}
|
||||
m_UseUCBPForAssetBundles: 0
|
||||
Reference in new issue
Block a user