Manage player names
Manage player display names and handle naming updates throughout the player lifecycle.
Read time 1 minuteLast updated 8 months ago
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 . 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.
AuthenticationService.Instance.UpdatePlayerNameAsync(playerName)If the player is not signed in or the request fails to complete successfully, throws a RequestFailedException. If the update fails due to an authentication-specific error, throws an AuthenticationException.
UpdatePlayerNameAsyncUpdatePlayerNameAsyncGetting player name
Players must be signed in to get their player name. Use . If no player name is found for the player, a random name is returned and assigned to the player.
AuthenticationService.Instance.GetPlayerNameAsync()If the player is not signed in or the request fails to complete successfully, throws a RequestFailedException. If the get fails due to an authentication-specific error, GetPlayerNameAsync throws an AuthenticationException.
GetPlayerNameAsyncCaching
The player name is cached locally per profile each time or is called. To access the cached value of the player name, use . The cached value is cleared after signing in with a new player, signing out, or attempting to call when no player name exists. If the cached value is not set, accessing it returns null.
UpdatePlayerNameAsyncGetPlayerNameAsyncAuthenticationService.Instance.PlayerNameGetPlayerNameAsync