Manage profiles
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 PlayerPrefs
. Profiles are not automatically persisted; it’s up to developers to determine how to manage them.
Switch profiles
Players must be signed out to switch the current profile. Use AuthenticationService.Instance.SwitchProfile(profileName)
. The profile name may only contain alphanumeric values, `-`, `_` and have a maximum length of 30 characters.
If a player is not signed out, SwitchProfile
throws an AuthenticationException
with the error code AuthenticationErrorCodes.ClientInvalidUserState
.
If an invalid name is used, SwitchProfile
throws an AuthenticationException
with the error code AuthenticationErrorCodes.ClientInvalidProfile
Current profile
To view the current profile, use AuthenticationService.Instance.Profile
Default profile
If there is no profile provided in the initialization options, the value default
is used.
Set the profile at initialization
Optionally, you can set the profile when initializing UnityServices
. The AuthenticationService
will use the value default
if a profile is not provided.
async Task InitializeUnityServices()
{
var options = new InitializationOptions();
options.SetProfile(“test_profile”);
await UnityServices.InitializeAsync(options);
}