Saving High Scores to a Leaderboard

Usually I try to ask something more specific. IE I have already coded it, it doesn’t work, and I ask for solutions. This time I have a more generic question. This time, I need a nudge to help get me looking in the right direction. A google search reveals what seems like a million different ways to do this. What I am looking to do as the title suggests is save scores in a leader board.

Here is an example mock up using UI Text

The gist of what I want to is, store a 10 entry list that the game calls at some point prior to the game over condition. I currently have my score stored in its own gameObject with script called ScoreKeeper. What I want to do is call that score variable, check it against the table, if it isn’t a new high score I just want to display the table, if the score does place in the top ten I want to replace whatever line the score it placed in with a on screen prompt for text input of up to three letters (initials) and write the current score on the correct line beside, thereby dropping the old tenth entry off the list. I want to do this as GUI element in my current scene, so that the action keeps going on just without the player. Until there are 10 scores recorded, I do want it to display dashes in place of Initials and a 6 digit score of 0.

using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using UnityEngine;

public class ScoreKeeper : MonoBehaviour {

    public Text scoreText;

    public int score;

    private void Start()
    {
        score = 0;
        UpdateScore();
    }
    public void AddScore(int newScoreValue)
    {
        score += newScoreValue;
        UpdateScore();
    }
    void UpdateScore()
    {
        scoreText.text = "Score:" + score;
    }
}

I do apologize I really try to have a more formed question before I come to the forums. I am just a bit overwhelmed with variations on how to do this. Any help as far as how to go about doing this is appreciated.

Game Balance wise I have not decided if I want the ability display the list on the pause screen, but I do know I want to show it in a prior to starting the game when the start menu is left idle. That may be neither here nor there, I can figure that out later, right now I just want to get a working score screen after game over.

You could save the scores in a list and serialize it to a string and then save it in playerprefs. Json can handle this, but there are many ways of doing it. If you plan to use an online service, you’ll have to interact with it. But by doing it in a list, you just have to loop through the list till you find the score it doesn’t beat and then insert it into the list at the point. Then when displaying the score, loop through for 10 scores, or less if you don’t have 10. You can remove any scores beyond the 10th score to keep your list down in size.

You could create a strut or a class that could hold both the initials and the score that goes with it.

Playerprefs will probably work in my case, its a really small game, and its local only, no online component at all. This is my first game, and this just kind of jumped up the difficulty, everything else I have coded is really simple, not that this isn’t a simple thing, but it is completely new to me and not like anything else I have done so far on this project.