using Assets.Scripts; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; namespace Assets.Scenes.Ride.Scripts { public class TopRankingItem : MonoBehaviour { private RawImage Head; private RawImage Country; private Text Name; private Text Rank;//当前排名 private Text Timer; private int _userId = 0; public int UserId { get { return _userId; } } private string _headUrl = string.Empty; private string _countryUrl = string.Empty; private string _name = string.Empty; public int rank { get; set; } CyclingController cyclingController; private void Awake() { cyclingController = FindObjectOfType(); Head = transform.Find("Head").GetComponent(); Country = transform.Find("Country").GetComponent(); Name = transform.Find("Name").GetComponent(); Rank = transform.Find("Rank").GetComponent(); Timer = transform.Find("Timer")?.GetComponent(); } public void setTimer(string timer) { Timer.text = timer; } //设置当前排名 public void SetRank(int rank) { Rank.text = rank.ToString(); this.rank = rank; } public void setHead(string url) { if (!string.IsNullOrEmpty(url)) { Utils.DisplayImage(Head, url, true); var rect = ((RectTransform)Head.transform).rect; Material material = Instantiate(Resources.Load("UI/Material/RoundedCornersTextureMaterial")); material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height, 0)); Head.material = material; } } public void setCountry(Texture texture) { Country.texture = texture; } public void setName(string name) { if (!_name.Equals(name)) Name.text = name; } public void setUserId(int userId) { _userId = userId; } } }