public void UpdateFriendList() { UnityAction afterGetFriends = () => { Debug.Log("Update Friend List UI"); LayoutElement[] children = this.friendListView.GetComponentsInChildren <LayoutElement> (); for (int z = 0; z < children.Length; z++) { if (children [z].gameObject != this.friendListView.gameObject) { DestroyImmediate(children [z].gameObject); } } foreach (var friend in PF_PlayerData.playerFriends) { Transform item = Instantiate(this.friendItemPrefab); Text txt = item.GetComponentInChildren <Text>(); txt.text = friend.TitleDisplayName; //string id = friend.FriendPlayFabId; Button btn = item.GetComponent <Button>(); FriendInfo friendCaptured = friend; btn.onClick.RemoveAllListeners(); btn.onClick.AddListener(() => { FriendClicked(friendCaptured); }); item.SetParent(this.friendListView, false); } }; PF_PlayerData.GetFriendsList(afterGetFriends); }
public void AddFriendClicked() { UnityAction <int> afterSelect = (int response) => { Action <string> afterInput = (string input) => { PF_PlayerData.AddFriend(input, (PF_PlayerData.AddFriendMethod)response, (bool result) => { if (result) { Dictionary <string, object> eventData = new Dictionary <string, object>(); // no real data to be sent with this event, just sending an empty dict for now... PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_FriendAdded, eventData); PF_PlayerData.GetFriendsList(() => { UpdateFriendList(); }); } }); }; DialogCanvasController.RequestTextInputPrompt(GlobalStrings.ADD_FRIEND_PROMPT, string.Format(GlobalStrings.ADD_FRIEND_MSG, (PF_PlayerData.AddFriendMethod)response), afterInput); }; DialogCanvasController.RequestSelectorPrompt(GlobalStrings.FRIEND_SELECTOR_PROMPT, Enum.GetNames(typeof(PF_PlayerData.AddFriendMethod)).ToList(), afterSelect); }