Ejemplo n.º 1
0
        IEnumerator LoadNewMembers(string groupCode, GroupData currGroup)
        {
            uiManagerScript.LoadingNewMemberToggle(true);
            WWWForm form = new WWWForm();

            form.AddField("userID", roomID);
            form.AddField("code", groupCode);
            UnityWebRequest www = UnityWebRequest.Post("https://circles-parellano.herokuapp.com/api/get-group-members", form);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
                uiManagerScript.LoadingNewMemberToggle(false);
            }
            else
            {
                string    response = www.downloadHandler.text;
                GroupData newGroup = JsonUtility.FromJson <GroupData>(response);
                foreach (GroupMember member in newGroup.members)
                {
                    if (username != member.world_user.user.username && (Array.IndexOf(currGroup.members, member) == -1))
                    {
                        GameObject newButton = Instantiate(GroupFriendButton) as GameObject;
                        newButton.transform.GetChild(1).GetChild(1).GetComponent <TMPro.TextMeshProUGUI>().text = "@" + member.world_user.user.username;
                        newButton.GetComponent <Button>().onClick.AddListener(() => { GoToFriendsRoom(member.world_user.id, member.world_user.user.username, member.world_user.world_type); });
                        newButton.transform.SetParent(OpenGroupPanel.transform);
                        newButton.transform.localScale = new Vector3(1, 1, 1);
                        newButton.SetActive(true);
                    }
                }
                uiManagerScript.LoadingNewMemberToggle(false);
                yield return(response);
            }
        }