Search Unity

Resolved How to change the PlayerName in LeaderboardEntry

Discussion in 'Leaderboards' started by salavideoclase7, Mar 26, 2023.

  1. salavideoclase7

    salavideoclase7

    Joined:
    Jul 8, 2022
    Posts:
    4
    In the API I can't find a way to change the PlayerName I get in LeaderboardEntry.
    By default it is set to something like "GaudyComposedGoldfish#7".

    How can I change it? Thanks in advance!
     
  2. AlexGalbraithCF

    AlexGalbraithCF

    Joined:
    Aug 27, 2021
    Posts:
    8
  3. salavideoclase7

    salavideoclase7

    Joined:
    Jul 8, 2022
    Posts:
    4
    Thank you, Alex! I have tested that API a few days ago, and I confirm that it works fine. One detail is that it adds a #random_number at the end every time I update, but it can be fixed with a Split.
     
  4. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    72
    Will this allow you to get the names of the other players in the Leaderboard?
     
  5. BlindsidedGames

    BlindsidedGames

    Joined:
    Aug 24, 2020
    Posts:
    9
    I would also like to know if there will be functionality for retrieving names.
     
  6. Evil-Otaku

    Evil-Otaku

    Joined:
    Oct 17, 2012
    Posts:
    72
    It does. The PlayerName that's part of LeaderboardEntry is the player name that is set from the Authentication Service for that player.
     
  7. UnityManuJack

    UnityManuJack

    Unity Technologies

    Joined:
    May 30, 2019
    Posts:
    11
    Hi!

    Thank you Alex for the answer.
    This is correct, setting the player name is now available as part of Authentication package 2.5.
    You can now use
    Code (CSharp):
    1. AuthenticationService.Instance.UpdatePlayerNameAsync(playerName)
    to set the player name for Leaderboard.
     
  8. MaxBackcountry

    MaxBackcountry

    Joined:
    Jan 24, 2014
    Posts:
    13
    Hi UnityManuJack,

    could you tell us what the format restrictions for the playername are? Are they the same as for the username

    upload_2023-11-12_10-42-13.png

    or different? Can't find anything about it. Thanks...
     
  9. MiTschMR

    MiTschMR

    Joined:
    Aug 28, 2018
    Posts:
    487
  10. MaxBackcountry

    MaxBackcountry

    Joined:
    Jan 24, 2014
    Posts:
    13
    This means that for example this string "#################################################" would be a valid playername? Weird...
     
    Last edited: Nov 18, 2023
  11. Delcasda

    Delcasda

    Joined:
    Mar 3, 2013
    Posts:
    27
    Hi UnityManuJack,
    the documentation states "Players must be signed in to create or update their player name." but running

    AuthenticationService.Instance.UpdatePlayerNameAsync(playerName)


    gives me :

    Unity.Services.Authentication.AuthenticationException: Invalid state for this operation. The player is already signing in.