help with score display concept

hello, i am trying to make a concept for displaying scores without having to utilize the gui system and at the same time trying to be a bit creative… i am getting some problems with converting my pseudocode concept into actual unity jscript and would greatly appreciate as much help as possible on this issue.

i am trying to create the scores for the game using gameobjects which change the sprite image between the numbers 0 and 9 to demonstrate the score. this is the concept that i have :

1.) create the gameobject with the image of the number 0.

2.) add script to gameobject with sprite variables going from 0-9.

3.) create an integer variable called divider, this will be set to 10 which is the cap or maximum. this means that the gameobject’s image can only change from 0-9, or any number under 10, counting down to 0.

4.) constrain the gameobject’s sprite image to the current game score, so if the score = 6, the gameobject’s sprite image would change to 6, and would be the same for all numbers going from 0-9, so if score = 2 the sprite image would be change to 2 etc… .

i am not sure how to constrain the images to the score however, and would like to use the divider var to be able to switch from tens, to hundreds, to thousands, by changing the variable number in the inspector from 10 to 100, or 1000. so if the var divider is 100 in the inspector, the sprites changing from 1-9 would represent 10 to 90.

in order to show the score of 95 for example, i would need the gameobject “0” on the screen twice in a row, and the first 0 gameobject would represent tens because the variable divider would be set to 100, and the other “0” gameobject would represent ones because the var divider would be set to 10. so when the game score changes from 0 to 95, the first zero gameobject would be constained to the tens portion of the score, and will change to 9, which represents 90, and the second gameobject will change to 5, representing the ones portion of the score. (i hope this is clear)

finally, using the divider variable we will have this code to hide the unused gameobjects by making them invisible.

if (score.gameScore >= divider){
	renderer.enabled = true;}
	else {renderer.enabled = false;}

so as an example, the maximum that the score can get to is 9,999. we would then add the prefab “0” into the scene four times, and then in the inspector change the var divider to 10,100,1000, and 10,000 on the four prefabs in the scene. the player would start the game and score 250 points, the score during the gameplay would show as “250” instead of showing as “0250” because the score would be less than the the variable divider for the thousands which would be set to 10,000 in the inspector. however if the score is 1500, it would show as “1500” and the gameobject representing the thousands would be visible.

i really hope i explained this properly, and would greatly appreciate any help with this.

Just make a texture with 0-9 and use UVOffset in the code, to hookup the digits to textures.
And regarding your problem with 0250 and 250, you can just disable the box, when its zero.

var g0 : Sprite;
var g1 : Sprite;
var g2 : Sprite;
var g3 : Sprite;
var g4 : Sprite;
var g5 : Sprite;
var g6 : Sprite;
var g7 : Sprite;
var g8 : Sprite;
var g9 : Sprite;
var numberOnes : Sprite;

function Start () {

}

function LateUpdate () {
Conversion();
}

function Update () {
GetComponent(SpriteRenderer).sprite = numberOnes;
if (score.gameScore >= 10){
renderer.enabled = true;}
else {renderer.enabled = false;}
}

function Conversion () {

var ones: int = score.gameScore /10%10;  
numberOnes = GetDigit(ones);

}

function GetDigit (digit: int): Sprite {

switch (digit){
    case 0: return g0;
    case 1: return g1;
    case 2: return g2;
    case 3: return g3;
    case 4: return g4;
    case 5: return g5;
    case 6: return g6;
    case 7: return g7;
    case 8: return g8;
    case 9: return g9;
}

}

this worked for me.