logo SERENITY
Game Systems Foundation
Search Results for

    Show / Hide Table of Contents

    Class UnityPrimaryInputGate

    Unity implementation of a primary input gate that waits for the first input device interaction to establish primary player control.
    Monitors input events to detect the first device press and automatically configures it as the primary input device.
    Provides asynchronous waiting for primary device selection with timeout handling and proper cleanup mechanisms.

    Inheritance
    object
    UnityPrimaryInputGate
    Implements
    IPrimaryInputGate
    IComponent
    IFoundationSettings
    Namespace: Serenity.InputGateway.Infrastructure.Components
    Assembly: Serenity.UnityPlayerInput.Infrastructure.dll
    Syntax
    public class UnityPrimaryInputGate : MonoBehaviour, IPrimaryInputGate, IComponent, IFoundationSettings

    Constructors

    UnityPrimaryInputGate()

    Declaration
    public UnityPrimaryInputGate()

    Methods

    AwaitAsync(CancellationToken)

    Asynchronously waits for the first input device interaction to establish the primary player device.
    Activates the target PlayerInput, waits for user validation, monitors input events, and returns device information.
    Shows optional prompt UI during waiting and handles timeout scenarios gracefully.

    Declaration
    public Task<(string scheme, string deviceId, string displayName)> AwaitAsync(CancellationToken cancellationToken)
    Parameters
    Type Name Description
    CancellationToken cancellationToken

    Cancellation token for aborting the wait operation.

    Returns
    Type Description
    Task<(string scheme, string deviceId, string displayName)>

    A tuple containing control scheme name, device ID, and device display name of the primary device.

    ConfigureRouting(IPlayerInputRoutingSettings)

    Configures routing settings used to pre-filter devices before notifying the service about a primary join.

    Declaration
    public void ConfigureRouting(IPlayerInputRoutingSettings routing)
    Parameters
    Type Name Description
    IPlayerInputRoutingSettings routing

    Routing settings providing device filter rules.

    Initialize(object, IPlayerInputService, ILogService)

    Initializes the primary input gate with PlayerInput handler and input service dependencies.
    Must be called from the installer to properly configure the gate for primary device detection.

    Declaration
    public void Initialize(object playerInputHandler, IPlayerInputService inputService, ILogService logService)
    Parameters
    Type Name Description
    object playerInputHandler

    The PlayerInput component to monitor for input events.

    IPlayerInputService inputService

    The player input service to notify when primary device is selected.

    ILogService logService

    The logging service for centralized logging output.

    SetPromptRoot(GameObject)

    Declaration
    public void SetPromptRoot(GameObject go)
    Parameters
    Type Name Description
    GameObject go

    Implements

    IPrimaryInputGate
    IComponent
    IFoundationSettings
    In this article
    © 2026 Serenity. All Rights Reserved