logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityUiInputRouter

    Unity component responsible for routing input from specific devices to UI elements.
    Manages device pairing with UI PlayerInput based on configured routing modes and primary device selection.
    Supports primary-only routing and handles keyboard/mouse combinations according to configuration settings.

    Inheritance
    object
    UnityUiInputRouter
    Implements
    IUiInputRouter
    Namespace: Serenity.InputGateway.Infrastructure.Components
    Assembly: Serenity.UnityPlayerInput.Infrastructure.dll
    Syntax
    public class UnityUiInputRouter : MonoBehaviour, IUiInputRouter

    Constructors

    UnityUiInputRouter()

    Declaration
    public UnityUiInputRouter()

    Methods

    Initialize(object, IPlayerInputRoutingSettings, ILogService)

    Initializes the UI input router with PlayerInput component and routing settings configuration.
    Validates input parameters and configures the router for proper input routing behavior.
    Sets up control scheme switching behavior according to routing requirements.

    Declaration
    public void Initialize(object playerInputHandler, IPlayerInputRoutingSettings routingSettings, ILogService logService)
    Parameters
    Type Name Description
    object playerInputHandler

    The PlayerInput component to route input for.

    IPlayerInputRoutingSettings routingSettings

    Configuration settings for input routing behavior.

    ILogService logService

    The logging service for diagnostic output.

    Exceptions
    Type Condition
    ArgumentException

    Thrown when playerInputHandler is not a valid PlayerInput instance.

    Route(string)

    Routes input to UI elements based on configured routing mode and specified primary device.
    Supports different routing modes including primary-only input control.
    Logs warnings when routing settings are not configured or routing mode is unknown.

    Declaration
    public void Route(string p1DeviceId)
    Parameters
    Type Name Description
    string p1DeviceId

    The device ID of the primary device to route input for.

    RouteAllDevices()

    Routes input so that all devices can control the UI simultaneously.
    Unpairs all devices from the UI PlayerInput and pairs all available input devices.
    Enables automatic control scheme switching for flexible device usage.

    Declaration
    public void RouteAllDevices()

    RoutePrimaryOnly(string)

    Routes input so that only the primary device (P1) can control the UI.
    Unpairs all devices from the UI PlayerInput and pairs only the device with the given ID.

    Declaration
    public void RoutePrimaryOnly(string p1DeviceId)
    Parameters
    Type Name Description
    string p1DeviceId

    The deviceId of the primary device (P1).

    Implements

    IUiInputRouter
    In this article
    © 2026 Serenity. All Rights Reserved