_TheStrongestSnail/TheStrongestSnail/Assets/Scripts/LqUiScripts/FriendPanel.cs

85 lines
2.2 KiB
C#
Raw Normal View History

2024-11-25 22:18:57 +08:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
2024-11-27 02:04:37 +08:00
using static Unity.IO.LowLevel.Unsafe.AsyncReadManagerMetrics;
using UnityEngine.Playables;
2024-11-25 22:18:57 +08:00
public class FriendPanel : MonoBehaviour
{
public GameObject friendinfoPrefab;
public Transform friendList;
public GameObject invitefriendsPanel;
2024-11-27 02:04:37 +08:00
public getInviteList62 getInviteList62=new getInviteList62();
public InviteInfoList inviteInfoList=new InviteInfoList();
public List<FriendInfo> friendInfos = new List<FriendInfo>();//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD>б<EFBFBD>
2024-11-25 22:18:57 +08:00
// Start is called before the first frame update
2024-11-27 02:04:37 +08:00
async void Start()
2024-11-25 22:18:57 +08:00
{
2024-11-27 02:04:37 +08:00
inviteInfoList= await getInviteList62.queryInviteHigherInfo();
CreateItem();
//for(int i=0;i<6;i++)
//{
// GameObject slot = GameObject.Instantiate(friendinfoPrefab, friendList);
//}
2024-11-25 22:18:57 +08:00
}
// Update is called once per frame
void Update()
{
}
2024-11-27 02:04:37 +08:00
public void CreateItem()
{
foreach (InviteUserInfo item in inviteInfoList.data.dataList)
{
GameObject newItem = Instantiate(friendinfoPrefab, friendList);
FriendInfo ItemComponent = newItem.GetComponent<FriendInfo>();
// <20><><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
ItemComponent.nameTxt.text=item.nickName;
ItemComponent.phonrNumberTxt.text=item.userName;
ItemComponent.UserId=item.userId;
ItemComponent.timeTxt.text =item.bindTime;
// <20>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>Ѵ<EFBFBD><D1B4><EFBFBD>
bool exists = false;
foreach (FriendInfo info in friendInfos)
{
if (info.UserId == item.userId)
{
exists = true;
break;
}
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD><D3B5>б<EFBFBD>
if (!exists)
{
friendInfos.Add(newItem.GetComponent<FriendInfo>());
}
else
{
// <20><><EFBFBD><EFBFBD><EFBFBD>Ѵ<EFBFBD><D1B4>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD>Ը<EFBFBD><D4B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD>ٸ<EFBFBD>ʵ<EFBFBD><CAB5>
Destroy(newItem);
}
}
}
2024-11-25 22:18:57 +08:00
public void SetFriendPanel()
{
transform.gameObject.SetActive(false);
invitefriendsPanel.SetActive(true);
}
}