using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; using Newtonsoft.Json.Linq; public class BoxFriendRequest : MonoBehaviour { void Awake() { GetFriendRequestItemPrefab().SetActive(false); } void OnEnable() { Refresh(); } Transform GetFriendRequestItemParent() { return transform.Find("ScrollView/Viewport/Content"); } GameObject GetFriendRequestItemPrefab() { return GetFriendRequestItemParent().Find("Item").gameObject; } //是否同意过好友添加请求,该记录可帮助提醒homeView的好友栏刷新 bool _hasAcceptAnyFriends = false; void Refresh() { for (int i = 1; i < GetFriendRequestItemParent().childCount; i++) { Destroy(GetFriendRequestItemParent().GetChild(i).gameObject); } Action cb = delegate (JArray list) { if (list.Count > 0) { foreach (var itemInfo in list) { int otherID = itemInfo.Value("otherID"); int avatarID = itemInfo.Value("avatarID"); string avatarUrl = itemInfo.Value("avatarUrl"); string nickname = itemInfo.Value("nickname"); bool online = itemInfo.Value("online"); long offlineTime = itemInfo.Value("offlineTime"); GameObject o = Instantiate(GetFriendRequestItemPrefab(), GetFriendRequestItemParent()); o.SetActive(true); o.name = otherID.ToString(); RoleMgr.SetAvatarToImage( o.transform.Find("Avatar/Sprite").GetComponent(), avatarID, avatarUrl); o.transform.Find("Name").GetComponent().text = nickname; Button btnNo = o.transform.Find("BtnIgnore").GetComponent