Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="url"></param>
        /// <param name="webRequestGetEvent"></param>
        /// <param name="SavePath">如果为""则不需要保存</param>
        /// <param name="isReturnPath">默认是返回内容</param>
        /// <returns></returns>
        public IEnumerator RealWebRequest(string url, WebRequestNetTextureEvent webRequestGetEvent, string savePath = "")
        {
            webRequest        = UnityWebRequestTexture.GetTexture(url);
            httpRequestCount += 1;
            yield return(webRequest.SendWebRequest());

            if (webRequest.error == null || webRequest.error == "")
            {
                Texture2D texture2D = DownloadHandlerTexture.GetContent(webRequest);
                if (savePath != null && savePath != "")
                {
                    FileHelper.CreatFile(savePath, texture2D.EncodeToPNG());
                }
                webRequestGetEvent(texture2D, savePath, DownStatus.Sucess, "");
                webRequest = null;
            }
            else
            {
                webRequest = null;
                DownManager.Instance.DebugDownError(httpRequestCount, url, webRequest.error);
                if (httpRequestCount <= 3)
                {
                    IEnumeratorTool.StartCoroutine(RealWebRequest(url, webRequestGetEvent));
                }
                else
                {
                    if (webRequestGetEvent != null)
                    {
                        webRequestGetEvent.Invoke(default(Texture2D), savePath, DownStatus.Fail, webRequest.error);
                    }
                }
            }
        }
Пример #2
0
        private void TryStartNextIEnumeratorTask()
        {
            if (mResInfoTask.Count == 0)
            {
                return;
            }

            if (mCurrentCoroutineCount >= mMaxCoroutineCount)
            {
                return;
            }

            var task = mResInfoTask.First.Value;

            mResInfoTask.RemoveFirst();

            ++mCurrentCoroutineCount;
            IEnumeratorTool.StartCoroutine(task.DoLoadAsync(OnIEnumeratorTaskFinish));
        }
Пример #3
0
 public static void CheckSupport(MonoBehaviour RegisterObject, Action <bool> checkCall)
 {
     IEnumeratorTool.StartCoroutine(CheckSupport(checkCall));
 }
Пример #4
0
 public void StartWebRequest(string url, WebRequestNetTextureEvent webRequestGetEvent, string savePath = "")
 {
     httpRequestCount = 0;
     IEnumeratorTool.StartCoroutine(RealWebRequest(url, webRequestGetEvent));
 }
Пример #5
0
 public void RegisterRequest(IEnumerator enumerator)
 {
     IEnumeratorTool.StartCoroutine(enumerator);
 }
Пример #6
0
 public DownManager()
 {
     AFStart.RegisterUpdate(OnUpdate);
     RequestIEnumID = IEnumeratorTool.StartCoroutine(SendRequstFromList());
 }