Advertisement
Fearsoulfire

dasdasd

Oct 3rd, 2014
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class TopScores : MonoBehaviour {
  6. Text text;
  7. float[] topScores = new float[5];
  8. Highscore hiscore;
  9. int cont;
  10.  
  11. // Use this for initialization
  12. void Start () {
  13. text = GetComponent<Text> ();
  14. hiscore = GetComponent<Highscore> (); // get the script component
  15. topScores = hiscore.Hiscores;// get the HiScores array
  16.  
  17.  
  18. }
  19.  
  20. // Update is called once per frame
  21. void Update () {
  22. UpdateScore ();
  23.  
  24. }
  25. void UpdateScore(){
  26. string stringtest = "";
  27. for (cont = 0; cont < topScores.Length; cont++)
  28. {
  29. if(cont ==0)
  30. stringtest += topScores[cont];
  31. else
  32. stringtest += "\n" + topScores[cont];
  33. }
  34. if (text.text != stringtest)
  35. text.text = stringtest;
  36.  
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement