Player name management

Minimum SDK version: 2.5.0-pre.3. Ensure you have the right version.

Players can associate a player name with their player ID, providing a customizable and more readable representation of their identity. Player IDs map to exactly one player name, and vice versa.

Setting player name

Players must be signed in to create or update their player name. Use AuthenticationService.Instance.UpdatePlayerNameAsync(playerName). The name should not contain any white space and should have a maximum length of 50 characters. A randomly-generated suffix consisting of a hash and four digits (e.g. #1234) is automatically appended to the requested name.

If the player is not signed in or the request fails to complete successfully, UpdatePlayerNameAsync throws a RequestFailedException. If the update fails due to an authentication-specific error, UpdatePlayerNameAsync throws an AuthenticationException.

Getting player name

Players must be signed in to get their player name. Use AuthenticationService.Instance.GetPlayerNameAsync(). If no player name is found for the player, a random name is returned and assigned to the player.

If the player is not signed in or the request fails to complete successfully, GetPlayerNameAsync throws a RequestFailedException. If the get fails due to an authentication-specific error, GetPlayerNameAsync throws an AuthenticationException.

Caching

The player name is cached locally per profile each time UpdatePlayerNameAsync or GetPlayerNameAsync is called. To access the cached value of the player name, use AuthenticationService.Instance.PlayerName. The cached value is cleared after signing in with a new player, signing out, or attempting to call GetPlayerNameAsync when no player name exists. If the cached value is not set, accessing it returns null.