| 123456789101112131415161718192021222324252627282930313233343536373839404142 | 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<netPlayer>();        for(int i =0; i < players.Length; i++){            Transform listItem = playerListParent.GetChild(i);                        listItem.GetChild(0).GetComponent<Text>().text = players[i].pname;            listItem.GetChild(1).GetComponent<Text>().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<Text>().color = Color.green;                }else if(ping < 250){                    listItem.GetChild(1).GetComponent<Text>().color = Color.yellow;                }else {                    listItem.GetChild(1).GetComponent<Text>().color = Color.red;                }            }            listItem.gameObject.SetActive(true);        }        for(int i =players.Length; i < playerListParent.childCount; i++){            playerListParent.GetChild(i).gameObject.SetActive(false);        }    }}
 |