Hello,
I like the way it is possible to listen to PlayerInput events using UnityEvents, like this :
// OnMove will be added to UnityEvents in the inspector
public void OnMove(InputAction.CallbackContext ctx)
{
// Code for any OnMove callback
// Code for specific phase
if (context.phase == InputActionPhase.Canceled) { }
if (context.phase == InputActionPhase.Started) { }
if (context.phase == InputActionPhase.Performed) { }
}
However, I need for my project to read it with C# events. But with C# events, I can only subscribe to individual InputActionPhase events :
public void ConfigurePlayerInputReceiver()
{
InputAction moveInputAction = playerInput.currentActionMap.FindAction("Move");
moveInputAction.canceled += OnMoveCanceled;
moveInputAction.started += OnMoveStarted;
moveInputAction.performed += OnMovePerformed;
}
private void OnMoveCanceled(InputAction.CallbackContext ctx) { // Code for any OnMove callback}
private void OnMoveStarted(InputAction.CallbackContext ctx) { // Code for any OnMove callback }
private void OnMovePerformed(InputAction.CallbackContext ctx) { // Code for any OnMove callback }
I need to write 3 time the same code for any OnMove callback. Is there a way I can subscribe with c# event like moveInputAction.anyCallbackContext += Listen
?