I'm desperate with my scoreboard! (Array, Javascript)

Hi to all

I have a player variables:

var Player1=100;
var Player2=33;
var Player3=48;
var Player4=11;
var Player5=24;

I create an array:

var PlayersScore:Array =[Player1,Player2,Player3,Player4,Player5];

Sort Array:

PlayersScore.Sort();

Draw in screen:

GUI.Label (Rect (0, 0, 400, 26), "Scores: " + PlayersScore);

How I can the name of each player score? Help Me Please ;)

1 Answer

1

You should make a class "Player" that contains the player name and the score. Give this class a method that'll return a string that looks like "Pete : 450". Then you can glue those together to put in your label.

http://answers.unity3d.com/questions/47386/how-i-can-create-a-javascript-object-in-a-unity-script <-- same as this.. except instead of "office" it would be "Player", and the datamembers would be "name" and "score".