using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class leaderboard_ze : MonoBehaviour { public Transform playerListParent; // Start is called before the first frame update void Start() { } // Update is called once per frame void Update() { netPlayer[] players= FindObjectsOfType(); for(int i =0; i < players.Length; i++){ Transform listItem = playerListParent.GetChild(i); listItem.GetChild(0).GetComponent().text = players[i].pname; listItem.GetChild(1).GetComponent().text = players[i].latency; if(players[i].latency.Contains("ms")){ int ping = int.Parse(players[i].latency.Replace("ms","")); if(ping < 100){ listItem.GetChild(1).GetComponent().color = Color.green; }else if(ping < 250){ listItem.GetChild(1).GetComponent().color = Color.yellow; }else { listItem.GetChild(1).GetComponent().color = Color.red; } } listItem.gameObject.SetActive(true); } for(int i =players.Length; i < playerListParent.childCount; i++){ playerListParent.GetChild(i).gameObject.SetActive(false); } } }