Ejemplo n.º 1
0
        public IEnumerator RealWebRequest(string url, string SavePath,
                                          WebRequestByteEvent webRequestGetEvent)
        {
            webRequest        = UnityWebRequest.Get(url);
            httpRequestCount += 1;
            yield return(webRequest.SendWebRequest());

            if (webRequest.error == null || webRequest.error == "")
            {
                if (SavePath != null && SavePath != "")
                {
                    FileHelper.CreatFile(SavePath, webRequest.downloadHandler.data, true);
                }
                if (webRequestGetEvent != null)
                {
                    webRequestGetEvent.Invoke(webRequest.downloadHandler.data, DownStatus.Sucess, "");
                }
                webRequest = null;
            }
            else
            {
                webRequest = null;
                DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error);
                if (httpRequestCount <= 3)
                {
                    DownManager.Instance.RegisterRequest(RealWebRequest(url, SavePath, webRequestGetEvent));
                }
                else
                {
                    if (webRequestGetEvent != null)
                    {
                        webRequestGetEvent.Invoke(default(byte[]), DownStatus.Fail, webRequest.error);
                    }
                }
            }
        }