49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using Assets.Framework.Tool;
|
|
using Assets.MyGame.Scripts.Net;
|
|
using Assets.MyGame.Scripts.Net.APIRequest.Params;
|
|
using Assets.MyGame.Scripts.Net.APIResponses;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
|
|
public class UIHome_BY_RankPanel : SubUIBase
|
|
{
|
|
public RankLineItem obj_LinePrefab;
|
|
public RankLineItem currobj_Line;
|
|
public Transform prefabRankLineItem_parent;
|
|
|
|
protected override void OnShow(object args = null)
|
|
{
|
|
base.OnShow(args);
|
|
LoadRankData();
|
|
}
|
|
|
|
private void LoadRankData()
|
|
{
|
|
APIRequestList.GetRankList(new BaseListPageParam
|
|
{
|
|
keyWord = "",
|
|
pageIndex = 0,
|
|
pageSize = 100
|
|
}, list =>
|
|
{
|
|
if (list == null) return;
|
|
|
|
// 清空旧列表
|
|
for (int i = prefabRankLineItem_parent.childCount - 1; i >= 0; i--)
|
|
Destroy(prefabRankLineItem_parent.GetChild(i).gameObject);
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
{
|
|
var data = list[i];
|
|
var item = Instantiate(obj_LinePrefab, prefabRankLineItem_parent);
|
|
|
|
// 头像走 GameManager 缓存加载(无头像时自动返回默认)
|
|
var sprite = GameManager.Instance.GetAvatarSprite(data.avatarUrl);
|
|
|
|
item.Init(i + 1, data.userName, "—", data.number, sprite, data.avatarUrl);
|
|
}
|
|
});
|
|
}
|
|
}
|