Old school score text

Hi!

First of all, if you know the proper name of this, please tell me! I have no idea what it really is called so I chose this title because it is seen in a lot of old games.

Now for the question.

I want to have a score text that works like most of the score texts did in old games like Tetris or Super Mario Bros. Like when the text is always x amount of characters. Example.

Score is 00000000. Then the player gets 100 points. Then it would change to 00000100.

How could I do something like this?

Any help is very appreciated!

Just like EmreBdgy suggested you could do it the following way:

Javascript:

GUI.Label(Rect(Screen.width-150, Screen.height-80, 300, 80),"<size=20>"+myScore.ToString("00000000")+"</size>");

C#:

GUI.Label(new Rect(Screen.width-150, Screen.height-80, 300, 80),"<size=20>"+myScore.ToString("00000000")+"</size>");

This way you can have myScore be an int and simply add to it and the ToString will format it for you.

In this case the easiest way would be to specify the string format while converting the score from a number to a string.

int score=0;
Debug.Log(score.ToString("00000000"));

score+=100;
Debug.Log(score.ToString("00000000"));

Using string.format is your best bet.
Here is a piece of code that dose what you ask:

public class OldtimeScore : MonoBehaviour
{
    private int Score;

    void Update()
    {
        if(Input.GetKeyDown(KeyCode.Space))
        {
            Score += 100;
            string scoreWithPadding = string.Format("Score is:{0:00000000}", Score);
            print(scoreWithPadding);
        }
    }
}