Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Can I remove the numbers at the end of a player name?

Discussion in 'Leaderboards' started by Casadev, Aug 30, 2023.

  1. Casadev


    May 16, 2023
    Hey everyone this is my first thread here and i'm a beginner so apologies if I don't make sense somewhere in this thread!

    I've been trying to implement the leaderboard in my first game for the past week and I found out today that upon submitting/posting a score entry to the leaderboard, you can allow the player to set their own player name when submitting a score, an example would be something like this:
    private TMPro.TMP_InputField nameInput;

    public async void PostScore(ScoreType type, float score)
    if (score <= 0) return;
    await LeaderboardsService.Instance.AddPlayerScoreAsync(type.ToString(), score);
    await AuthenticationService.Instance.UpdatePlayerNameAsync(nameInput.text);

    Debug.Log($"Score Posted To Leaderboard - {type}. Score: {score}");

    catch (System.Exception e)
    await Task.Delay(2500);
    PostScore(type, score);

    But when I fetch the leaderboard entries on my leaderboard, whatever I put in the inputfield, for example "TestPlayer", it shows TestPlayer#4382. I'm just wondering if it's possible to remove the digits at the end?
  2. EmilF_Unity


    Unity Technologies

    Jun 10, 2022
    Hi Airtap,

    Welcome to the forum and congrats on making your first game!

    Regarding the player name, the hash and numbers are an integral part of the player management solution and cannot be removed from the service responses (see these docs for more details on player names). However, because the pattern is predictable you can always remove them from the string wherever you need to display the name.
  3. MiTschMR


    Aug 28, 2018
    I remove the last digits this way:

    Code (CSharp):
    1. string playerName = await AuthenticationService.Instance.GetPlayerNameAsync();
    3. playerName = string.Join("", playerName.SkipLast(5));
  4. restush96


    May 28, 2019
    No need to remove because there must be a duplicate name then the hash could help player to distinguish their real account.

    Like would be pain to distinguish these leaderboard.
    1. Carrot
    2. Carrot
    3. ... etc