Game.SceneFlow.ControllerDisconnectedScreen
Assembly:
Assembly-CSharp (game assembly)
Namespace: Game.SceneFlow
Type: class
Base: FullScreenOverlay
Summary:
ControllerDisconnectedScreen is a FullScreenOverlay-derived screen used by the scene flow to inform the player that a controller has been disconnected and to wait for either a new device to be connected or for a user key/action to continue. It registers an "AnyKey" overlay action, creates an input overlay barrier while shown, activates the controller-disconnected overlay UI, and then waits asynchronously for either an input action or a device arrival. If an input action occurs it attempts to associate the input device via PlatformManager.instance.AssociateDevice; otherwise the screen will exit when a device event or cancellation occurs. The class is designed to be cancellable via CancellationToken and cooperates with the overlay/input scoping helpers used across the game's UI flow.
Fields
- This class declares no private instance fields of its own in the provided file.
It relies on functionality and fields provided by its base class (FullScreenOverlay), such as: - m_Done — controls the loop that keeps the overlay visible until completion.
- m_CompletedEvent — optional callback invoked when waiting operations complete.
- continueDisplayPriority — (used when creating the EnabledActionScoped) — inherited or provided by the base.
These base members are used to coordinate completion and input handling while the overlay is active.
Properties
-
protected override OverlayScreen overlayScreen { get; }
Returns OverlayScreen.ControllerDisconnected. Indicates which overlay screen UI to activate when this overlay runs. -
protected override string actionA { get; }
Returns "AnyKey". The action name used to register an enabled input action that will cause the overlay to try to continue. -
protected override string continueDisplayProperty { get; }
Returns "Continue". The display property name used with the enabled action to show the continue prompt.
Constructors
public ControllerDisconnectedScreen()
The default constructor is used (none explicitly declared in the file). Initialization is handled by the base class and the overridden property getters.
Methods
public override async System.Threading.Tasks.Task Execute(GameManager manager, System.Threading.CancellationToken token)
Main async entry point to run the overlay. Behavior summary:- Creates an EnabledActionScoped for the "AnyKey" action (group "Engagement") with the proper display property and priority so the overlay shows a continue prompt and accepts the action as input.
- Creates an overlay input barrier via Game.Input.InputManager.instance.CreateOverlayBarrier to prevent unrelated input from reaching other systems while the overlay is active.
- Activates the controller-disconnected overlay UI via manager.userInterface.overlayBindings.ActivateScreenScoped(overlayScreen).
- Enters a loop that continues until m_Done is true:
- Starts two waits in parallel:
- IScreenState.WaitForInput(continueAction, null, m_CompletedEvent, token) — waits for the registered overlay action input and returns a tuple (ok, InputDevice).
- IScreenState.WaitForDevice(m_CompletedEvent, token) — waits for a device event (e.g., a controller being connected).
- Awaits Task.WhenAny(input, device) so either path can wake the loop.
- Invokes m_CompletedEvent (if set) after one of the waits finishes.
- If the input task completed successfully, calls PlatformManager.instance.AssociateDevice(input.Result.device) and sets m_Done to the boolean result (association success keeps/ends the screen based on returned value).
- If the device task completed successfully, sets m_Done = true (a device arrival will let the overlay exit).
- On other completion/failure/cancellation, sets m_Done = true to exit.
- Uses using blocks to ensure the EnabledActionScoped, the overlay barrier and the ActivateScreenScoped are disposed when the overlay finishes or if canceled.
Remarks: - The method cooperates with the Unity InputSystem's InputDevice type (UnityEngine.InputSystem.InputDevice). - Cancellation is honored via the provided CancellationToken. - Association of devices is delegated to PlatformManager.instance.AssociateDevice; the overlay does not directly bind hardware beyond requesting association.
Usage Example
// The screen is invoked by the game's scene flow controller, but here's how its Execute method behaves.
// Example: called from scene-flow runtime with a GameManager and CancellationToken:
var screen = new ControllerDisconnectedScreen();
await screen.Execute(gameManagerInstance, cancellationToken);
// Internally the screen creates an overlay barrier, activates the controller-disconnected UI,
// and waits for either the "AnyKey" overlay action or for a new device to appear.
// If the "AnyKey" action is received it attempts to associate the InputDevice via PlatformManager.instance.AssociateDevice.
Additional notes: - Typical usage is via the game's scene flow; modders should not need to instantiate this class directly in normal operation. - If extending or customizing behavior, be mindful to invoke base behavior or to replicate the overlay/action/scoped disposal pattern so input remains correctly isolated while the overlay is active.