PlayerInput es un componente del Input System pensado para asociar un jugador con sus Input Actions.
En el GameObject del jugador:
Add Component → Player Input
Después asignás el asset de Input Actions.
using UnityEngine.InputSystem;
public class PlayerController : MonoBehaviour
{
private PlayerInput playerInput;
void Awake()
{
playerInput = GetComponent<PlayerInput>();
}
}
Debug.Log(playerInput.currentActionMap.name);
playerInput.SwitchCurrentActionMap("UI");
Debug.Log(playerInput.currentControlScheme);
foreach (var device in playerInput.devices)
{
Debug.Log(device.displayName);
}