The InputDeviceManager is a static class that manages input devices, player inputs, and control schemes across the application. It provides centralized input management for both single-player and multiplayer scenarios.
This manager handles player input registration, control scheme tracking, and action map management for loading states.
Info: The InputDeviceManager is automatically used by LunaUIManager and doesn't require manual initialization in most cases.
The InputDeviceManager is automatically initialized and managed by LunaUIManager. The LunaUIManager calls OnEnable() and OnDisable() methods and handles player input registration through its OnPlayerJoined and OnPlayerLeft events.
InputPrompt components automatically subscribe to InputDeviceManager events to update their display when:
Collection of all registered PlayerInput instances. Used for managing multiple players in local multiplayer scenarios.
public static List<PlayerInput> PlayerInputs { get; }List of current control schemes for each player. Tracks the active input method (keyboard, gamepad, etc.) for each registered player.
public static List<InputIconControlScheme> CurrentSchemes { get; }List of action names that trigger escape functionality. These actions are automatically bound to escape events when players are registered.
public static List<string> EscapeActionNames { get; }List of action map names that should be enabled during loading states. These maps are automatically managed during loading transitions.
public static List<string> LoadingActionMaps { get; }Events triggered when players are added or removed from the input system.
public static event Action<PlayerInput, int> OnPlayerAdded;
public static event Action<PlayerInput, int> OnPlayerRemoved;Event triggered when a player's control scheme changes (e.g., switching from keyboard to gamepad).
public static event Action<InputIconControlScheme> OnControlSchemeChange;Initializes the InputDeviceManager with escape action names, loading action maps, and multiplayer settings. Called automatically by LunaUIManager.
public static void OnEnable(List<string> escapeActionNames, List<string> loadingActionMaps, bool localMultiplayer)Cleans up the InputDeviceManager by unsubscribing from input system events. Called automatically when the manager is disabled.
public static void OnDisable()Registers a new PlayerInput instance with the manager. Automatically binds escape actions and updates control scheme tracking.
public static void AddPlayerInput(PlayerInput playerInput)Unregisters a PlayerInput instance from the manager. Cleans up escape action bindings and removes from tracking lists.
public static void RemovePlayerInput(PlayerInput playerInput)Updates the control scheme for a specific player input index. Triggers the OnControlSchemeChange event if the scheme has changed.
public static void UpdateControlScheme(int inputIndex, bool forceInvoke = false)
// or
public static void UpdateControlScheme(InputIconControlScheme newScheme, int inputIndex, bool forceInvoke = false)Methods for managing action maps during loading states. These are called automatically by loading transitions.
public static void OnLoadingStart()
public static void OnLoadingEnd()Utility methods for enabling and disabling specific action maps across input assets.
public static void SetEnabledActionMaps(InputActionAsset asset, ICollection<string> mapsToEnable)
public static void SetDisabledActionMaps(InputActionAsset asset, ICollection<string> mapsToDisable)
public static void ActionMapEnableOthers(InputActionAsset inputActionAsset, List<string> actionMapsToEnable)Example of how to listen to player join/leave events for UI updates or game logic.
void Start()
{
InputDeviceManager.OnPlayerAdded += OnPlayerJoined;
InputDeviceManager.OnPlayerRemoved += OnPlayerLeft;
}
void OnPlayerJoined(PlayerInput playerInput, int playerIndex)
{
Debug.Log($"Player {playerIndex} joined with device: {playerInput.devices[0].displayName}");
// Update UI, spawn player, etc.
}
void OnPlayerLeft(PlayerInput playerInput, int playerIndex)
{
Debug.Log($"Player {playerIndex} left");
// Clean up player data, update UI, etc.
}Example of how to respond to control scheme changes for UI updates.
void Start()
{
InputDeviceManager.OnControlSchemeChange += OnControlSchemeChanged;
}
void OnControlSchemeChanged(InputIconControlScheme newScheme)
{
// Update input prompts, button icons, etc.
switch (newScheme)
{
case InputIconControlScheme.Keyboard:
// Show keyboard prompts
break;
case InputIconControlScheme.Gamepad:
// Show gamepad prompts
break;
}
}Info: In most cases, you don't need to manually interact with InputDeviceManager. It's automatically managed by LunaUIManager and works seamlessly with the UI system.
Settings
Theme
Light
Contrast
Material
Dark
Dim
Material Dark
System
Sidebar(Light & Contrast only)
Font Family
DM Sans
Wix
Inclusive Sans
AR One Sans
Direction