public override IEnumerator RunJob()
        {
            Debug.Log("*************************** CoroutineLoadMap ***************************");
            SDKMapRequest r = new SDKMapRequest();

            r.token = this.token;
            r.id    = this.id;

            string jsonString2 = JsonUtility.ToJson(r);

            using (UnityWebRequest request = UnityWebRequest.Put(string.Format(Endpoint.URL_FORMAT, this.server, Endpoint.LOAD_MAP), jsonString2))
            {
                request.method          = UnityWebRequest.kHttpVerbPOST;
                request.useHttpContinue = false;
                request.SetRequestHeader("Content-Type", "application/json");
                request.SetRequestHeader("Accept", "application/json");
                yield return(request.SendWebRequest());

                if (request.isNetworkError || request.isHttpError)
                {
                    Debug.Log(request.error);
                }
                else if (request.responseCode == (long)HttpStatusCode.OK)
                {
                    SDKMapResult result = JsonUtility.FromJson <SDKMapResult>(request.downloadHandler.text);
                    if (result.error == "none")
                    {
                        byte[] mapData = Convert.FromBase64String(result.b64);
                        Debug.Log("Load map " + this.id + " (" + mapData.Length + " bytes)");

                        arMap.LoadMap(mapData);
                    }
                }
            }
        }
Exemplo n.º 2
0
        public void OnValueChanged(TMP_Dropdown dropdown)
        {
            int value = dropdown.value - 1;

            // use embedded map
            if (m_EmbeddedMap != null && value == -1)
            {
                m_ARMap.mapFile = m_EmbeddedMap;
                m_ARMap.LoadMap();
            }
            else
            {
                if (value >= 0)
                {
                    SDKJob map = m_Maps[value];
                    LoadMap(map);
                }
            }
        }