public void refreshList() { searchList.removeAllElements(); foreach (User user in searchedUsers) { ScrollableList.ListGameObject listObject; if (!LoggedInUser.GetLoggedInUser().HasFriendship(user)) { GameObject go = Instantiate(userSearchItemPrefab); SearchUserNotFriendListItem newItem = go.GetComponent <SearchUserNotFriendListItem> (); newItem.SetSearchedUser(user); newItem.userProfile = userProfile; listObject = (ScrollableList.ListGameObject)newItem; } else { GameObject go = Instantiate(friendSearchItemPrefab); SearchUserIsFriendListItem newItem = go.GetComponent <SearchUserIsFriendListItem> (); newItem.SetSearchedUser(user); newItem.userProfile = userProfile; listObject = (ScrollableList.ListGameObject)newItem; } searchList.addElement(listObject); } searchList.sortList(); }