Skip to main content

PicoLoginController

A class in Root.Township, Features.Core.Device.Pico.

Client menu panel for signing in with a Pico account. Gets a Pico token, then logs in to the game account with platform credentials, or moves on to account registration if none exists.

Constructors​

MemberWhat it is
PicoLoginController()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

9 private and internal fields
MemberWhat it is
private ScalingFadeAnimator accountRequiredAnimatorPanel shown when an account must be registered or linked.
private const string ExternalLoginRequiredTextInstruction text shown on the panel before the player presses login.
private bool isLoggingInStops a second press while a login is in progress.
private static readonly Logger loggerNLog logger for this class.
private AnalyticalButton loginButtonThe button that starts the Pico login.
private TextRenderer loginInstructionTextText showing instructions or the last error.
private ScalingFadeAnimator picoLoginPromptAnimatorPanel holding the Pico login prompt.
private ScalingFadeAnimator seatedStandingAnimatorPanel for the seated or standing choice that this flow starts from.
private IUserService userServiceInjected user service used for tokens and login.

Methods​

MemberWhat it is
void BackToSitStand()Fades from the account-required panel back to the seated or standing choice.
void InitPicoAccountFlow()Moves from the seated or standing panel to the Pico login prompt, or to the account-required panel if a user is already logged in.
protected void Inject(IUserService userService)Receives the user service from VContainer.
7 private and internal methods
MemberWhat it is
private void OnDisable()Unhooks the login button.
private void OnEnable()Hooks the login button and resets its text and enabled state.
private async void OnLoginButtonPressed()Checks the platform is Pico, refreshes the token and user, then tries a platform login, loading the main menu on success.
private void OnLoginFailed(string reason)Shows the failure reason and re-enables the login button.
private void OnLoginSuccess()Pico login worked but no game account was found: fades to the account-required panel.
private async Task<bool> TryUpdateLoggedInUser()Refreshes the logged-in user unless one is already logged in; returns whether that worked.
private async Task<bool> TryUpdateUserAccessToken()Force-refreshes the access token when external platform sign-in is required; returns false on error or an empty token.