Quick answer: PlayerInput component → tick Auto-Switch. Set Default Scheme. Subscribe to onControlsChanged to update UI prompts. For local multiplayer, do NOT use Auto-Switch — use PlayerInputManager.
Player picks up a controller mid-game. Game keeps reading keyboard. Or vice versa. Auto-Switch is off or the PlayerInput is configured for multiplayer.
The Symptom
Single-player game doesn’t hot-swap between keyboard/mouse and gamepad. UI prompts don’t update. Or attempting to swap by pressing buttons does nothing.
The Fix (Single Player)
PlayerInput Inspector:
Actions: PlayerControls (asset)
Default Scheme: Keyboard&Mouse
Auto-Switch: true // THIS
Behavior: Invoke Unity Events
Listen for swap:
public class PromptUpdater : MonoBehaviour
{
public PlayerInput playerInput;
public Image promptImage;
public Sprite kbIcon, padIcon;
void OnEnable() => playerInput.onControlsChanged += OnSchemeChanged;
void OnDisable() => playerInput.onControlsChanged -= OnSchemeChanged;
void OnSchemeChanged(PlayerInput pi)
{
promptImage.sprite = pi.currentControlScheme.Contains("Gamepad") ? padIcon : kbIcon;
}
}
For Local Multiplayer
Use PlayerInputManager. Auto-Switch on individual PlayerInputs would steal devices from other players. PlayerInputManager handles join/leave with explicit device claims.
Verifying
Start with keyboard. Press a gamepad button. Player should swap; OnSchemeChanged fires; UI updates. Plug/unplug controllers; same behavior.
“Auto-Switch on. Subscribe to onControlsChanged. Multiplayer uses PlayerInputManager.”
Related Issues
For OnScreenStick not tracking, see OnScreenStick. For Steam Input action sets, see Steam Input.
Auto-Switch. Subscribe. Prompts update.