Manage profiles
Create and manage multiple player profiles on a single device to allow players to sign in with different accounts.
Read time 1 minuteLast updated 8 months ago
Players can use profiles to sign in to multiple accounts on a single device. Profiles add a level of isolation to the values saved to the . Profiles are not automatically persisted; it’s up to developers to determine how to manage them.
PlayerPrefsSwitch profiles
Players must be signed out to switch the current profile. Use . The profile name only supports alphanumeric values, `-`, `_` and has a maximum length of 30 characters.
AuthenticationService.Instance.SwitchProfile(profileName)If a player is not signed out, throws an with the error code .
SwitchProfileAuthenticationExceptionAuthenticationErrorCodes.ClientInvalidUserStateIf an invalid name is used, throws an with the error code
SwitchProfileAuthenticationExceptionAuthenticationErrorCodes.ClientInvalidProfileCurrent profile
To view the current profile, use .
AuthenticationService.Instance.ProfileDefault profile
If no profile is provided in the initialization options, the value is used.
defaultSet the profile at initialization
Optionally, you can set the profile when initializing . The uses the value if no profile is provided.
UnityServicesAuthenticationServicedefaultasync Task InitializeUnityServices(){ var options = new InitializationOptions(); options.SetProfile("test_profile"); await UnityServices.InitializeAsync(options);}