void CreateRoomListItems(RoomListData rooms) { RoomListItem[] roomListItems = roomList.GetComponentsInChildren <RoomListItem>(); if (roomListItems != null) { for (int i = 0; i < roomListItems.Length; i++) { bool remain = false; for (int j = 0; j < rooms.rooms.Length; j++) { if (roomListItems[i].room.roomID == rooms.rooms[j].roomID) { remain = true; break; } } if (!remain) { GameObject.Destroy(roomListItems[i].gameObject); } } } roomListItems = roomList.GetComponentsInChildren <RoomListItem>(); for (int i = 0; i < rooms.rooms.Length; i++) { RoomListItem roomListItem = null; if (roomListItems != null) { for (int j = 0; j < roomListItems.Length; j++) { if (roomListItems[j].room.roomID == rooms.rooms[i].roomID) { roomListItem = roomListItems[j]; break; } } } if (roomListItem == null) { roomListItem = Instantiate(roomListItemPrefab) as RoomListItem; roomListItem.transform.SetParent(roomList, false); } roomListItem.SetRoom(rooms.rooms[i]); } }