Class PlayerInputController
Handles player input using the new Unity Input System and converts it to character actions. Subscribes to input action callbacks and manages UI toggles, movement, camera, and context menus.
public class PlayerInputController : MonoBehaviour
- Inheritance
-
ObjectComponentBehaviourMonoBehaviourPlayerInputController
- Inherited Members
-
MonoBehaviour.IsInvoking()MonoBehaviour.CancelInvoke()MonoBehaviour.StopCoroutine(Coroutine)MonoBehaviour.StopAllCoroutines()MonoBehaviour.destroyCancellationTokenMonoBehaviour.useGUILayoutMonoBehaviour.didStartMonoBehaviour.didAwakeMonoBehaviour.runInEditModeBehaviour.enabledBehaviour.isActiveAndEnabledComponent.GetComponent<T>()Component.TryGetComponent<T>(out T)Component.GetComponentInChildren<T>()Component.GetComponentsInChildren<T>()Component.GetComponentInParent<T>()Component.GetComponentsInParent<T>()Component.GetComponents<T>()Component.GetComponentIndex()Component.CompareTag(TagHandle)Component.transformComponent.transformHandleComponent.gameObjectComponent.tagObject.GetEntityId()Object.GetInstanceID()Object.GetHashCode()Object.InstantiateAsync<T>(T)Object.InstantiateAsync<T>(T, Transform)Object.InstantiateAsync<T>(T, Vector3, Quaternion)Object.InstantiateAsync<T>(T, Transform, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion)Object.Instantiate(Object, Vector3, Quaternion, Transform)Object.Instantiate(Object)Object.Instantiate(Object, Scene)Object.Instantiate<T>(T, InstantiateParameters)Object.Instantiate<T>(T, Vector3, Quaternion, InstantiateParameters)Object.Instantiate(Object, Transform)Object.Instantiate<T>(T)Object.Instantiate<T>(T, Vector3, Quaternion)Object.Instantiate<T>(T, Vector3, Quaternion, Transform)Object.Instantiate<T>(T, Transform)Object.Destroy(Object)Object.DestroyImmediate(Object)Object.DontDestroyOnLoad(Object)Object.DestroyObject(Object)Object.FindObjectsOfType<T>()Object.FindObjectsByType<T>(FindObjectsSortMode)Object.FindObjectsByType<T>(FindObjectsInactive, FindObjectsSortMode)Object.FindObjectOfType<T>()Object.FindFirstObjectByType<T>()Object.FindAnyObjectByType<T>()Object.FindFirstObjectByType<T>(FindObjectsInactive)Object.FindAnyObjectByType<T>(FindObjectsInactive)Object.FindObjectsByType<T>()Object.FindObjectsByType<T>(FindObjectsInactive)Object.ToString()Object.nameObject.hideFlags
Properties
Character
The player character associated with this input controller.
public IPlayerCharacter Character { get; }
Property Value
Controls
Shared PlayerControls for read-only queries (hotkey bar, chat).
public static PlayerControls Controls { get; }
Property Value
- PlayerControls
ForcedMouseMode
True when the mouse mode was explicitly set by a UI element (prevents auto-dismiss from overriding a deliberate cursor show).
public static bool ForcedMouseMode { get; }
Property Value
MouseMode
Gets or sets the current mouse mode. True = cursor visible/unlocked. False = cursor hidden/locked to the game window.
public static bool MouseMode { get; set; }
Property Value
Methods
Deinitialize()
Deinitializes the input controller, unsubscribing from input events and character input handling.
public void Deinitialize()
EnsureControlsCreated()
Creates the shared PlayerControls asset and applies the player's saved keybinding overrides, without enabling any action map.
public static void EnsureControlsCreated()
Remarks
Split out of InitializeControls() so the settings panel can list and rebind keys before the player has entered the world. The asset on its own is inert data: no action fires until a map is enabled, so creating it early does not make the world's input live on the login screen.
Called from the client's boot phase. Before that existed, the asset was created only by Initialize(IPlayerCharacter) on world entry — so the Key Bindings tab had nothing to show until then, and a saved override was not read until then either.
ForceClickMouseButtonInCenterOfGameWindow()
public static void ForceClickMouseButtonInCenterOfGameWindow()
Initialize(IPlayerCharacter)
Initializes the input controller for the specified player character. Subscribes to input events and character input handling.
public void Initialize(IPlayerCharacter character)
Parameters
characterIPlayerCharacterThe player character to control.
InitializeControls()
Ensures the static Controls instance is created and its maps are enabled.
public static void InitializeControls()
KCCPlayer_OnHandleCharacterInput()
Handles character input for KinematicCharacterController. Converts input states into KCCInputReplicateData for movement replication.
public KCCInputReplicateData KCCPlayer_OnHandleCharacterInput()
Returns
- KCCInputReplicateData
KCCInputReplicateData containing movement and camera input.
LoadBindingOverrides()
Loads keybinding overrides from global config.
public static void LoadBindingOverrides()
Remarks
Public so the boot phase can apply saved bindings as soon as the configuration is loaded, rather than leaving them until world entry.
ResetForcedMouseMode()
Clears the forced-mouse-mode flag.
public static void ResetForcedMouseMode()
SaveBindingOverrides()
Persists keybinding overrides to global configuration.
public static void SaveBindingOverrides()
Remarks
Through SetString(string, string), which schedules the debounced write. Writing straight into the store left the new binding in memory only: it survived until something else happened to save the file, and was lost outright if nothing did.
ToggleMouseMode(bool)
Toggles mouse mode. Pass true to force the new state.
public static void ToggleMouseMode(bool forceMouseMode = false)
Parameters
forceMouseModebool
Events
OnToggleMouseMode
Invoked when MouseMode changes.
public static event Action<bool> OnToggleMouseMode