PlayerInput
Manages the player's input action schemes and cursor state. Tracks active InputActionScheme instances in a HashSet, enabling/disabling them as needed. Locks the cursor on enable and disables all schemes on disable.
Definition
Namespace: Paragon.Townskeep.PlayerSystem
Assembly: Townskeep.dll
[AddComponentMenu("Input/Player Input")]
public class PlayerInput : ParagonBehaviourInheritance: SerializedMonoBehaviour → ParagonBehaviour → PlayerInput
Remarks
PlayerInput is the player-side bridge to Paragon's InputActionScheme system. It maintains a set of currently active input schemes and provides methods to activate, disable, and query them.
Lifecycle
Awake — Caches the
Playerreference and creates theactiveSchemessetOnEnable — Locks the cursor and activates the default
InputActionSchemeon the sameGameObjectOnDisable — Disables all active schemes and clears the set
Input scheme management
Schemes are tracked in a HashSet<InputActionScheme> to prevent double-activation. ActivateInputScheme() only calls Enable() if the scheme was not already in the set; DisableInputScheme() only calls Disable() if the scheme was present and removed.
The component is disabled by default. PlayerNetwork.Initialize() enables it only for the local client (networkPlayer.ClientID == ClientID), preventing remote player objects from processing input.
Quick Lookup
Access the player
playerInput.Player
Activate a scheme
playerInput.ActivateInputScheme(scheme)
Disable a scheme
playerInput.DisableInputScheme(scheme)
Disable all schemes
playerInput.DisableAllInputSchemes()
Find a scheme by name
playerInput.GetInputScheme("name")
Lock cursor
playerInput.LockCursor()
Unlock cursor
playerInput.UnlockCursor()
Properties
Player
The Player this input component belongs to.
Methods
Awake
Caches the Player component and creates the activeSchemes HashSet.
OnEnable (override)
Locks the cursor and activates the default InputActionScheme found on the same GameObject. Calls base.OnEnable() for debug system registration.
OnDisable (override)
Disables all active input schemes and clears the set. Calls base.OnDisable() for debug system unregistration.
LockCursor
Hides the cursor and locks it to the center of the screen.
UnlockCursor
Shows the cursor and unlocks it for free movement.
ActivateInputScheme
Enables an input scheme and adds it to the active set. No-op if the scheme is already active.
inputScheme
InputActionScheme
The scheme to activate
DisableInputScheme
Disables an input scheme and removes it from the active set. No-op if the scheme is not active.
inputScheme
InputActionScheme
The scheme to disable
DisableAllInputSchemes
Disables all currently active schemes and clears the active set.
GetInputScheme
Finds an active scheme by name. Returns null if not found.
name
string
The scheme name to search for
Returns: The matching InputActionScheme or null.
Common Pitfalls
Disabled by default
PlayerInput should be disabled on the prefab. PlayerNetwork.Initialize() enables it only for the local client. If accidentally enabled in the prefab, all player instances (including remote) will process input and lock the cursor.
Default scheme required on same GameObject
OnEnable() calls GetComponent<InputActionScheme>() to find the default scheme. If no InputActionScheme component exists on the same GameObject, a null will be passed to ActivateInputScheme(), which may cause issues with the HashSet.
GetInputScheme only searches active schemes
GetInputScheme() searches the activeSchemes set, not all schemes on the GameObject. A scheme that has been disabled will not be found.
See Also
Player — the player entity this input serves
PlayerNetwork — enables this component for the local client
InputActionScheme — the input system scheme wrapper
Last updated