lvjincheng 3 tahun lalu
induk
melakukan
ef174568e2
1 mengubah file dengan 6 tambahan dan 24 penghapusan
  1. 6 24
      Assets/BowArrow/Scripts/View/FriendView.cs

+ 6 - 24
Assets/BowArrow/Scripts/View/FriendView.cs

@@ -45,14 +45,8 @@ public class FriendView : MonoBehaviour
                         int avatarID = itemInfo.Value<int>("avatarID");
                         string nickname = itemInfo.Value<string>("nickname");
                         bool online = itemInfo.Value<bool>("online");
-                        while (true) {
-                            Transform t = GetMyFriendItemParent().Find(friendID.ToString());
-                            if (t != null) {
-                                t.gameObject.name = "丢弃";
-                                Destroy(t.gameObject);
-                            } else {
-                                break;
-                            }
+                        for (int i = 1; i < GetMyFriendItemParent().childCount; i++) {
+                            Destroy(GetMyFriendItemParent().GetChild(i).gameObject);
                         }
                         GameObject o = GameObject.Instantiate(GetMyFriendItemPrefab(), GetMyFriendItemParent());
                         o.SetActive(true);
@@ -100,14 +94,8 @@ public class FriendView : MonoBehaviour
                         int avatarID = itemInfo.Value<int>("avatarID");
                         string nickname = itemInfo.Value<string>("nickname");
                         bool online = itemInfo.Value<bool>("online");
-                        while (true) {
-                            Transform t = GetFriendRequestItemParent().Find(otherID.ToString());
-                            if (t != null) {
-                                t.gameObject.name = "丢弃";
-                                Destroy(t.gameObject);
-                            } else {
-                                break;
-                            }
+                        for (int i = 1; i < GetFriendRequestItemParent().childCount; i++) {
+                            Destroy(GetFriendRequestItemParent().GetChild(i).gameObject);
                         }
                         GameObject o = GameObject.Instantiate(GetFriendRequestItemPrefab(), GetFriendRequestItemParent());
                         o.SetActive(true);
@@ -172,14 +160,8 @@ public class FriendView : MonoBehaviour
                         int avatarID = itemInfo.Value<int>("avatarID");
                         string nickname = itemInfo.Value<string>("nickname");
                         bool online = itemInfo.Value<bool>("online");
-                        while (true) {
-                            Transform t = GetSearchPlayerItemParent().Find(userID.ToString());
-                            if (t != null) {
-                                t.gameObject.name = "丢弃";
-                                Destroy(t.gameObject);
-                            } else {
-                                break;
-                            }
+                        for (int i = 1; i < GetSearchPlayerItemParent().childCount; i++) {
+                            Destroy(GetSearchPlayerItemParent().GetChild(i).gameObject);
                         }
                         GameObject o = GameObject.Instantiate(GetSearchPlayerItemPrefab(), GetSearchPlayerItemParent());
                         o.SetActive(true);