85 lines
2.2 KiB
C#
85 lines
2.2 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
|
|
using UnityEngine.Playables;
|
|
|
|
public class FriendPanel : MonoBehaviour
|
|
{
|
|
public GameObject friendinfoPrefab;
|
|
public Transform friendList;
|
|
public GameObject invitefriendsPanel;
|
|
public getInviteList62 getInviteList62=new getInviteList62();
|
|
public InviteInfoList inviteInfoList=new InviteInfoList();
|
|
public List<FriendInfo> friendInfos = new List<FriendInfo>();//好友信息列表
|
|
// Start is called before the first frame update
|
|
async void Start()
|
|
{
|
|
|
|
inviteInfoList= await getInviteList62.queryInviteHigherInfo();
|
|
CreateItem();
|
|
//for(int i=0;i<6;i++)
|
|
//{
|
|
// GameObject slot = GameObject.Instantiate(friendinfoPrefab, friendList);
|
|
//}
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
public void CreateItem()
|
|
{
|
|
foreach (InviteUserInfo item in inviteInfoList.data.dataList)
|
|
{
|
|
|
|
GameObject newItem = Instantiate(friendinfoPrefab, friendList);
|
|
|
|
|
|
FriendInfo ItemComponent = newItem.GetComponent<FriendInfo>();
|
|
|
|
// 设置实例化对象的内容
|
|
ItemComponent.nameTxt.text=item.nickName;
|
|
ItemComponent.phonrNumberTxt.text=item.userName;
|
|
ItemComponent.UserId=item.userId;
|
|
ItemComponent.timeTxt.text =item.bindTime;
|
|
|
|
|
|
|
|
|
|
// 判断是否已存在
|
|
bool exists = false;
|
|
foreach (FriendInfo info in friendInfos)
|
|
{
|
|
if (info.UserId == item.userId)
|
|
{
|
|
exists = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
// 如果不存在,则添加到列表
|
|
if (!exists)
|
|
{
|
|
friendInfos.Add(newItem.GetComponent<FriendInfo>());
|
|
|
|
}
|
|
else
|
|
{
|
|
// 如果已存在,可以根据需求决定是否销毁该实例
|
|
Destroy(newItem);
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public void SetFriendPanel()
|
|
{
|
|
transform.gameObject.SetActive(false);
|
|
invitefriendsPanel.SetActive(true);
|
|
}
|
|
}
|