Leaderboard
This commit is contained in:
@@ -23,6 +23,8 @@ public class GameManager : MonoBehaviour
|
||||
{
|
||||
playerLaps[i] = 1;
|
||||
}
|
||||
|
||||
DontDestroyOnLoad(gameObject);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
|
||||
@@ -5,13 +5,17 @@ using TMPro;
|
||||
public class WinScript : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI MainText;
|
||||
public TextMeshProUGUI MainText2;
|
||||
public List<string> leaderboard;
|
||||
public List<string> time;
|
||||
public GameObject winner;
|
||||
|
||||
void Start()
|
||||
{
|
||||
leaderboard = GameObject.Find("GameManager").GetComponent<GameManager>().playersFinished;
|
||||
time = GameObject.Find("GameManager").GetComponent<GameManager>().playerTimes;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +23,15 @@ public class WinScript : MonoBehaviour
|
||||
private void Update()
|
||||
{
|
||||
MainText.text = "Leaderboard: ";
|
||||
MainText2.text = "\n";
|
||||
for (var i = 0; i < leaderboard.Count; i++){
|
||||
MainText.text += "\n" + (i+1) + "." + leaderboard[i] + "(" + time[i] + ")";
|
||||
MainText.text += "\n" + (i+1) + "." + leaderboard[i];
|
||||
MainText2.text += "\n(" + time[i] + ")";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user