Skip to content

Game.SceneFlow.ControllerPairingScreen

Assembly: Assembly-CSharp.dll
Namespace: Game.SceneFlow

Type: class

Base: FullScreenOverlay

Summary:
ControllerPairingScreen is a fullscreen overlay that handles controller pairing and user switching flows. It presents an overlay screen to the player, binds actions for "continue" (Switch User) and "cancel", and waits for either explicit input actions or an attached input device event. It uses PlatformManager to perform sign-in or device association and launches a WaitScreen while sign-in is in progress. If the active user changes during sign-in and the game is running (or in the editor), it returns the player to the main menu.


Fields

  • This class declares no private fields of its own.
    Most of the instance state it references (for example m_Done and m_CompletedEvent) is provided by the FullScreenOverlay base class.

Properties

  • protected override OverlayScreen overlayScreen { get; }
    Returns OverlayScreen.ControllerPairingChanged — identifies the overlay screen shown by this overlay.

  • protected override string continueDisplayProperty { get; }
    Returns the display string key "Switch User" for the continue action/button.

  • protected override string cancelDisplayProperty { get; }
    Returns the display string key "Cancel" for the cancel action/button.

  • protected override int cancelDisplayPriority { get; }
    Returns 30 — the priority value used when registering the cancel action display.

Constructors

  • This class has no explicit constructors; it uses the default parameterless constructor inherited from System.Object. Initialization is performed in Execute when the overlay is activated.

Methods

  • public override async Task Execute(GameManager manager, CancellationToken token)
    Main asynchronous entry point for the overlay. Execution flow:
  • Creates two EnabledActionScoped instances to bind continue (actionA) and cancel (actionB) inputs with labels and priorities.
  • Creates an overlay barrier via InputManager.instance.CreateOverlayBarrier to prevent other input from interfering.
  • Activates the overlay UI via manager.userInterface.overlayBindings.ActivateScreenScoped(overlayScreen).
  • Enters a loop until m_Done is set:
    • Starts two tasks: IScreenState.WaitForInput to await continue/cancel actions, and IScreenState.WaitForDevice to wait for device connection.
    • Awaits Task.WhenAny(input, device) and invokes m_CompletedEvent to notify waiting logic.
    • If input completed successfully:
    • If the input indicates "ok" (continue), calls PlatformManager.instance.SignIn with UserChangingCallback; sets m_Done on success and sends the player to the main menu if the user changed and the game is running.
    • If the input indicates cancel, calls PlatformManager.instance.AssociateDevice with the detected device and sets m_Done based on the result.
    • If device task completes successfully (or other unexpected completion), sets m_Done to true to dismiss the overlay.
  • Ensures proper disposal of action scopes, overlay bindings and the overlay barrier.

The method also defines a nested callback:

  • void UserChangingCallback(Task signInTask)
    Called when SignIn has been initiated. It launches a WaitScreen to show sign-in progress: new WaitScreen().Execute(manager, token, signInTask).

Notes: - Uses EnabledActionScoped to temporarily enable controller actions with UI labels. - Uses PlatformManager to perform sign-in and device association. - If the active user changes while in-game or in-editor, it calls manager.MainMenu() to return to the main menu.

Usage Example

// Example: invoking the controller pairing overlay from a GameManager context
var screen = new Game.SceneFlow.ControllerPairingScreen();
CancellationToken token = CancellationToken.None; // or a real token provided by the caller
await screen.Execute(manager, token);