docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface IPrimaryAccountSystem

    Provides access to all primary account related functionality.

    Namespace: Unity.PlatformToolkit
    Assembly: Unity.PlatformToolkit.dll
    Syntax
    public interface IPrimaryAccountSystem
    Remarks

    Primary account is the account that players will expect most actions and data to be associated with, e.g. save games and achievements. The selection of the primary account is dictated by the platform. Usually this is the account which launched the game. On platforms that support only one signed in account at a time, that account is the primary.

    On some platforms the primary account might not be available even if accounts are supported. Use PrimaryAccount capability to check if the primary account is supported.

    Properties

    Current

    Current primary account.

    Declaration
    IAccount Current { get; }
    Property Value
    Type Description
    IAccount
    See Also
    Primary
    PrimaryAccount

    Methods

    Establish()

    Sign in the primary account if one is not currently signed in, then return the current primary account.

    Declaration
    Task<IAccount> Establish()
    Returns
    Type Description
    Task<IAccount>

    Task that contains the current primary account. The same account can be read from Current.

    If the primary account is already signed in when calling Establish(), result will contain the same account.

    Remarks

    Establish() might show a system sign in prompt. There is no way to tell how long the prompt will be shown, so make sure to only call Establish() when appropriate.

    Some platforms impose a limit to how many times a user can be presented with a sign in prompt. If the primary account is not signed in and the platform does not allow prompting the user to sign in, Establish() will throw a TemporarilyUnavailableException. Check IPrimaryAccountSystemCapabilities.EstablishLimited to find out if Establish() can throw a TemporarilyUnavailableException.

    On platforms where IPrimaryAccountSystemCapabilities.EstablishLimited capability is true, it’s recommended to treat accounts as optional and design your game to work both with an account and without one.

    Exceptions
    Type Condition
    UserRefusalException

    The user has canceled the sign in prompt.

    TemporarilyUnavailableException

    Sign in prompt could not be shown.

    See Also
    Primary
    PrimaryAccount

    Events

    OnChange

    Invoked after primary account changes.

    Declaration
    event Action OnChange
    Event Type
    Type Description
    Action
    Remarks

    Check Current to get the current primary account.

    Exactly if and when the primary account can change is platform dependent. On some platforms the same primary account is guaranteed to remain signed in throughout the entire game session, while on other platforms the primary account can sign in and sign out at any moment. Refer to platform support package documentation to find out how to handle changes to the primary account.

    Will not get invoked if the primary account is set during Initialize().

    See Also
    Primary
    PrimaryAccount

    See Also

    Primary
    PrimaryAccount
    In This Article
    Back to top
    Copyright © 2025 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)