예제 #1
0
    IEnumerator CheckUrl(string url)
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(url))
        {
            // Request and wait for the desired page.

            sliderProgress.value = 0;
            this.mainScreen.ShowLoadScreen();
            webRequest.SendWebRequest();
            while (!webRequest.isDone)
            {
                //TxtDownloadProgress.text = "Progresso: " + (int)(webRequest.downloadProgress * 100f) + "%";
                sliderProgress.value = Mathf.Lerp(sliderProgress.value, webRequest.downloadProgress, Time.deltaTime * 3);

                yield return(null);
            }

            if (webRequest.isNetworkError || webRequest.isHttpError)
            {
                Debug.Log("Erro no download url: " + url + "erro: " + webRequest.error);
                //this.ImgBoxError.SetActive(true);
                //yield return new WaitForSeconds(2f);
                this.mainScreen.HideLoadScreen();
            }
            else
            {
                //mainScreen.ShowLoadScreen();
                Debug.Log("Download concluido: " + url);
                yield return(new WaitForSeconds(3f));

                string[] format = url.Split('/');
                string   test   = format[format.Length - 2];
                string   title  = format[format.Length - 1];

                if (test == "Imagem")
                {
                    this.TxtTitleImage.text = title;
                    this.PrepareImageContent(url);
                }
                if (test == "Video")
                {
                    this.TxtTitleVideo.text = title;

                    this.PrepareVideoContent(url);
                }
                if (test == "3d")
                {
                    this.TxtTitle3dModel.text = title;
                    this.PrepareModelContent(url);
                }
                mainScreen.HideLoadScreen();
                mainScreen.Disable();
            }
        }
    }