/// <summary> /// 更新显示 /// </summary> public void UpdateView(PlayerDto playerDto) { nameText.text = playerDto.Name; lvText.text = playerDto.Lv.ToString(); expBar.value = playerDto.Exp / (playerDto.Lv * 100.0f); //加载好友列表 FriendDto[] friendDtos = playerDto.Friends; friendViews.Clear(); GameObject go = null; foreach (FriendDto friendDto in friendDtos) { go = Instantiate(friendPrefab); go.transform.SetParent(friendSpawn); go.transform.localScale = Vector3.one; FriendView friendView = go.GetComponent <FriendView>(); friendView.InitView(friendDto.ID, friendDto.Name, friendDto.IsOnline); friendViews.Add(friendView); } }
/// <summary> /// 更新显示 /// </summary> public void UpdateView(PlayerDto player) { txtName.text = player.name; barExp.value = (float)player.exp / (player.lv * 100); Friend[] friends = player.friends; friendList.Clear(); for (int i = 0; i < friendTran.childCount; i++) { GameObject children = friendTran.GetChild(i).gameObject; GameObject.Destroy(children); } for (int i = 0; i < friends.Length; i++) { Friend friend = friends[i]; GameObject go = Instantiate(UIFriend); go.transform.SetParent(friendTran, false); FriendView fv = go.GetComponent <FriendView>(); fv.InitView(friend.Id, friend.Name, friend.IsOnLine); friendList.Add(fv); } }
/// <summary> /// 更新显示 /// </summary> public void UpdateView(PlayerDto player) { txtName.text = player.name; barExp.value = (float)player.exp / (player.lv * 100); //加载好友列表 Friend[] friends = player.friends; friendList.Clear(); GameObject go = null; foreach (Friend item in friends) { if (item == null) { continue; } go = Instantiate(UIFriend); go.transform.SetParent(friendTran); FriendView fv = go.GetComponent <FriendView>(); fv.InitView(item.Id, item.Name, item.isOnline); friendList.Add(fv); } }