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 latch the first device button press and completes the join when that button is RELEASED,
so the join cascade (device routing, menu activation) never runs while the button is still held — preventing the
press from leaking into UI actions (e.g. submitting the focused option of the menu shown right after joining).
Provides asynchronous waiting for primary device selection with timeout handling and proper cleanup mechanisms.
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 |