public void ShowFriendOnLine() { foreach (var item in FriendManager.Instance.RoomInvite) { OnLineFriend olf = null; if (!OnLineNickName.TryGetValue(item.Key, out olf)) { ResourceItem objUnit = ResourcesManager.Instance.loadImmediate(GameConstDefine.LoadInvitationUI, ResourceType.PREFAB); GameObject obj = GameObject.Instantiate(objUnit.Asset) as GameObject; obj.transform.parent = mOnLineGrid.transform; obj.transform.localPosition = Vector3.zero; obj.transform.localScale = Vector3.one; olf = new OnLineFriend(); olf.mHeroHeadIcon = obj.transform.Find("Portrait/Head").GetComponent <UISprite>(); olf.mHeadName = obj.transform.Find("Name/Label").GetComponent <UILabel>(); olf.mSelect = obj.GetComponent <UIToggle>(); OnLineNickName.Add(item.Key, olf); EventDelegate.Add(olf.mSelect.onChange, OnSelectName); } olf.SGUID = item.Key; olf.mHeadName.text = olf.nickName = item.Value.nickName; olf.mHeroHeadIcon.spriteName = item.Value.ToString(); OnLineNickName[item.Key] = olf; } }
//窗口控件初始化 protected override void InitWidget() { ToggleFriend = mRoot.Find("FriendListBtn").GetComponent <UIToggle>(); ToggleLobby = mRoot.Find("LobbyListBtn").GetComponent <UIToggle>(); mOnLineGrid = mRoot.Find("ShowList/Panel/Grid").GetComponent <UIGrid>(); InviteBtn = mRoot.Find("InviteBtn").GetComponent <UIButton>(); CloseBtn = mRoot.Find("CloseBtn").GetComponent <UIButton>(); nickName.Clear(); OnLineNickName.Clear(); InviteBtn.isEnabled = (bool)(nickName.Count != 0); UIEventListener.Get(InviteBtn.gameObject).onClick += InviteList; UIEventListener.Get(CloseBtn.gameObject).onClick += CloseButton; }