44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class RankLineItem : MonoBehaviour
|
|
{
|
|
public GameObject obj_rankNum;
|
|
public TextMeshProUGUI userName;
|
|
public TextMeshProUGUI userLevel;
|
|
public TextMeshProUGUI userScore;
|
|
public Image avatar;
|
|
public void Init(int rankNum,string name,string level,string score,Sprite sprite)
|
|
{
|
|
foreach (Transform item in obj_rankNum.transform)
|
|
{
|
|
item.gameObject.SetActive(false);
|
|
}
|
|
switch (rankNum)
|
|
{
|
|
case 1:
|
|
obj_rankNum.transform.GetChild(0).gameObject.SetActive(true);
|
|
break;
|
|
case 2:
|
|
obj_rankNum.transform.GetChild(1).gameObject.SetActive(true);
|
|
break;
|
|
case 3:
|
|
obj_rankNum.transform.GetChild(2).gameObject.SetActive(true);
|
|
break;
|
|
default:
|
|
GameObject obj = obj_rankNum.transform.GetChild(3).gameObject;
|
|
obj.SetActive(true);
|
|
obj.GetComponent<TextMeshProUGUI>().text= rankNum.ToString();
|
|
break;
|
|
}
|
|
userName.text = name;
|
|
userLevel.text = level;
|
|
userScore.text = score;
|
|
avatar.sprite = sprite;
|
|
|
|
}
|
|
}
|