Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class TopScores : MonoBehaviour {
- Text text;
- float[] topScores = new float[5];
- Highscore hiscore;
- int cont;
- // Use this for initialization
- void Start () {
- text = GetComponent<Text> ();
- hiscore = GetComponent<Highscore> (); // get the script component
- topScores = hiscore.Hiscores;// get the HiScores array
- }
- // Update is called once per frame
- void Update () {
- UpdateScore ();
- }
- void UpdateScore(){
- string stringtest = "";
- for (cont = 0; cont < topScores.Length; cont++)
- {
- if(cont ==0)
- stringtest += topScores[cont];
- else
- stringtest += "\n" + topScores[cont];
- }
- if (text.text != stringtest)
- text.text = stringtest;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement