Scripting API

PlayerInput

class in UnityEngine.InputSystem · Unity.InputSystem · inherits from MonoBehaviour

36 of 38 of Unity's members
In Tassix

One player's input: enables the default action map of its actions and tells scripts when actions trigger. With SendMessages (the default) or BroadcastMessages, "On<Action>(InputValue)" goes to the GameObject when an action performs (and when a Value action cancels); with C# events, onActionTriggered gets every callback; with Unity events, the action's event in actionEvents does.

Fields 3

const string ControlsChangedMessage
const string DeviceLostMessage
const string DeviceRegainedMessage

Properties 20

ReadOnlyArray<ActionEvent> actionEvents { get; set; }
InputActionAsset? actions { get; set; }
static ReadOnlyArray<PlayerInput> all { get; }
Camera? camera { get; set; }
ControlsChangedEvent controlsChangedEvent { get; }
InputActionMap? currentActionMap { get; set; }
string? currentControlScheme { get; }
string? defaultActionMap { get; set; }
string? defaultControlScheme { get; set; }
DeviceLostEvent deviceLostEvent { get; }
DeviceRegainedEvent deviceRegainedEvent { get; }
ReadOnlyArray<InputDevice> devices { get; }
bool hasMissingRequiredDevices { get; }
bool inputIsActive { get; }
static bool isSinglePlayer { get; }
bool neverAutoSwitchControlSchemes { get; set; }
PlayerNotifications notificationBehavior { get; set; }
int playerIndex { get; }
int splitScreenIndex { get; }
MonoBehaviour? uiInputModule { get; set; }

Methods 8

void ActivateInput()
void DeactivateInput()
static PlayerInput? FindFirstPairedToDevice(InputDevice device)
TDevice? GetDevice<TDevice>()
static PlayerInput? GetPlayerByIndex(int playerIndex)
void PassivateInput()
void SwitchCurrentActionMap(string mapNameOrId)
bool SwitchCurrentControlScheme(params InputDevice[] devices)
void SwitchCurrentControlScheme(string controlScheme, params InputDevice[] devices)

Events 4

event Action<InputAction.CallbackContext>? onActionTriggered
event Action<PlayerInput>? onControlsChanged
event Action<PlayerInput>? onDeviceLost
event Action<PlayerInput>? onDeviceRegained

Not in Tassix yet 2

DebugLogAction user

Checked against Unity

Conformance scenarios that exercise it, recorded in Unity and compared event by event.