예제 #1
0
        /// <summary>
        /// 下载资源失败监听
        /// </summary>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        private void OnHttpDownLoadFailure(object sender, IEventArgs e)
        {
            HttpDownloadEventArgs args = (HttpDownloadEventArgs)e;

#if UNITY_EDITOR
            if (args != null)
            {
                UnityEngine.Debug.LogError("下载资源失败! \n Url: " + args.Url + "\n 详细信息: " + args.Error);
            }
#endif
            int count = 0;
            if (_retryRecord.TryGetValue(args.Url, out count))
            {
                _retryRecord[args.Url]++;
                if (count <= _RETRYCOUNT)
                {
#if UNITY_EDITOR
                    Debug.Log("资源: " + args.Url + "第" + count + "次重新下载!");
#endif
                    GameMain.WebRequestMG.StartDownload(args.Url, args.LocalPath);
                }
            }
            else
            {
                //新增
                _retryRecord.Add(args.LocalPath, 0);
            }
        }
예제 #2
0
        /// <summary>
        /// 下载资源成功监听
        /// </summary>
        /// <param name="arg1"></param>
        /// <param name="arg2"></param>
        private void OnHttpDownLoadSuccess(object sender, IEventArgs e)
        {
            HttpDownloadEventArgs args = (HttpDownloadEventArgs)e;

#if UNITY_EDITOR
            if (args != null)
            {
                UnityEngine.Debug.Log("下载资源成功! \n Url: " + args.Url + "\n 详细信息: " + args.Error);
            }
#endif
            _downloadSuccessResources.Add(args.Url);
            if (_downloadResources.ContainsKey(args.Url))
            {
                _downloadResources.Remove(args.Url);
            }
        }
예제 #3
0
        /// <summary>
        /// 回调函数,下载资源
        /// </summary>
        /// <param name="remoteurl">下载资源地址</param>
        /// <param name="localpath">本地存储地址</param>
        /// <param name="result">下载结果</param>
        /// <param name="content">附加信息(包含错误信息等)</param>
        private void StartDownloadCallback(string remoteurl, string localpath, bool result, string content)
        {
            HttpDownloadEventArgs httpDownloadEventArgs = new HttpDownloadEventArgs();

            httpDownloadEventArgs.Url       = remoteurl;
            httpDownloadEventArgs.LocalPath = localpath;
            httpDownloadEventArgs.Error     = content;
            if (result)
            {
                _event.CallEvent(this, EventType.HttpDownLoadSuccess, httpDownloadEventArgs);
            }
            else
            {
                _event.CallEvent(this, EventType.HttpDownLoadFailure, httpDownloadEventArgs);
            }
        }