Esempio n. 1
0
        /// <summary>
        /// Gets the cloud list.
        /// </summary>
        /// <returns>The cloud list.</returns>
        IEnumerator GetCloudList()
        {
            loaderText.text = "Loading Maps...";
            UnityWebRequest www = UnityWebRequest.Get(m_Sdk.ContentServer + EndPoint.CLOUD_LIST);

            www.SetRequestHeader("dev-token", m_Sdk.developerToken);
            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log("****************\t" + www.error + "\t****************");
            }
            else
            {
                try
                {
                    string jsonResult = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);

                    CloudListItem cloudListItem = JsonUtility.FromJson <CloudListItem>(jsonResult);

                    for (int i = 0; i < cloudListItem.cloudMapList.Length; i++)
                    {
                        string map_name = UnityWebRequest.UnEscapeURL(cloudListItem.cloudMapList[cloudListItem.cloudMapList.Length - (i + 1)].map_name);
                        cloudDropdown.options.Add(new TMP_Dropdown.OptionData(map_name + "  " + cloudListItem.cloudMapList[cloudListItem.cloudMapList.Length - (i + 1)].id));
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e, this);
                }
            }
        }
Esempio n. 2
0
        private string GetAnchorId(string cloud_id)
        {
            CloudListItem cloudListItem = JsonUtility.FromJson <CloudListItem>(jsonResult);

            for (int i = 0; i < cloudListItem.cloudMapList.Length; i++)
            {
                if (cloudListItem.cloudMapList[cloudListItem.cloudMapList.Length - (i + 1)].id == cloud_id)
                {
                    return(cloudListItem.cloudMapList[cloudListItem.cloudMapList.Length - (i + 1)].AnchorId);
                }
            }

            return("");
        }
        IEnumerator GetMapList()
        {
            using (UnityWebRequest www = UnityWebRequest.Get(cloudListURL))
            {
                www.SetRequestHeader("dev-token", devToken);
                yield return(www.SendWebRequest());

                if (www.isNetworkError || www.isHttpError)
                {
                    mLoader.SetActive(false);
                    Debug.Log("****************\t" + www.error + "\t****************");
                }
                else
                {
                    try
                    {
                        mLoader.SetActive(false);
                        string jsonResult = System.Text.Encoding.UTF8.GetString(www.downloadHandler.data);
                        Debug.Log("JSON_OUTPUT:" + jsonResult);

                        CloudListItem cloudListItem = JsonUtility.FromJson <CloudListItem>(jsonResult);
                        int           totalMaps     = cloudListItem.cloudMapList.Length;

                        Debug.Log(">>>>   Total maps: " + totalMaps + "   <<<<");
                        created_maps.text = "Created (" + totalMaps + ")";


                        for (int i = 0; i < totalMaps; i++)
                        {
                            GameObject item = Instantiate(Resources.Load("prefabs/CloudItem")) as GameObject;
                            items.Add(item);
                            item.SetActive(true);
                            item.transform.SetParent(listHolder.transform, false);
                            item.transform.localScale = Vector3.one;

                            string map_name = UnityWebRequest.UnEscapeURL(cloudListItem.cloudMapList[totalMaps - (i + 1)].map_name);

                            item.transform.Find("MapName").GetComponent <TextMeshProUGUI>().text = map_name + " (" + cloudListItem.cloudMapList[totalMaps - (i + 1)].id + ")";
                            item.transform.Find("Updated").GetComponent <TextMeshProUGUI>().text = cloudListItem.cloudMapList[totalMaps - (i + 1)].uploaded;
                        }
                    }
                    catch (Exception e)
                    {
                        mLoader.SetActive(false);
                        Debug.LogException(e, this);
                    }
                }
            }
        }