static int QPYX_Dispose_YXQP(IntPtr L_YXQP) { try { ToLua.CheckArgsCount(L_YXQP, 1); UnityEngine.Networking.UnityWebRequest QPYX_obj_YXQP = (UnityEngine.Networking.UnityWebRequest)ToLua.CheckObject <UnityEngine.Networking.UnityWebRequest>(L_YXQP, 1); QPYX_obj_YXQP.Dispose(); return(0); } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static int Dispose(IntPtr L) { try { ToLua.CheckArgsCount(L, 1); UnityEngine.Networking.UnityWebRequest obj = (UnityEngine.Networking.UnityWebRequest)ToLua.CheckObject <UnityEngine.Networking.UnityWebRequest>(L, 1); obj.Dispose(); return(0); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
/// <summary> /// 从远程下载bundle /// ! 测试使用mac本地服务器 url地址配置在GameCanstants中 /// </summary> /// <param name="bundleName"></param> /// <param name="downloadSucceedCallBack"></param> /// <param name="downloadFailedCallBack">范</param> /// <returns></returns> public IEnumerator CheckDownloadBundleFromRemoteServer(BundleCacheItem cacheItem, Action downloadSucceedCallBack = null, Action downloadFailedCallBack = null, Action <float> downloadingCallBack = null) { if (!cacheItem.NeedDownload()) { downloadSucceedCallBack?.Invoke(); yield break; } string _bundleName = cacheItem.BundleName; string downloadUrl = GetBundleRemoteUrl(_bundleName, cacheItem.BundleVersion); if (string.IsNullOrEmpty(downloadUrl)) { yield break; } UnityEngine.Networking.UnityWebRequest request = UnityWebRequest.Get(downloadUrl); request.timeout = 600; bundleWebRequests.Add(_bundleName, request); request.SendWebRequest(); int displayProgress = 1; int toProgress = 0; while (!request.isDone) { toProgress = (int)(100 * request.downloadProgress); while (displayProgress <= toProgress) { downloadingCallBack?.Invoke((float)displayProgress / 100.0f); yield return(GameConstants.Wait1In60Second); displayProgress++; } yield return(GameConstants.Wait1In60Second); } toProgress = 100; while (displayProgress <= toProgress) { downloadingCallBack?.Invoke((float)displayProgress / 100.0f); yield return(GameConstants.Wait1In60Second); displayProgress++; } if (request.isHttpError || request.isNetworkError) { Log.Error(request.error); //TODO display dialog yield break; } string localSavePath = Path.Combine(AssetPathManager.GetAssetBundleOutPutPath(), cacheItem.BundleName); //*删除旧版本bundle */ try { string dicPath = Path.GetDirectoryName(localSavePath); if (!Directory.Exists(dicPath)) { Directory.CreateDirectory(dicPath); File.Delete(localSavePath); } } catch (Exception ex) { Log.Error(ex.Message); } var data = request.downloadHandler.data; try { string dicPath = Path.GetDirectoryName(localSavePath); if (!Directory.Exists(dicPath)) { Directory.CreateDirectory(dicPath); } File.WriteAllBytes(localSavePath, data); } catch (Exception e) { Log.Error(e.Message); } // yield return GameConstants.Wait2In10Second; bundleWebRequests.Remove(_bundleName); request.Dispose(); downloadSucceedCallBack?.Invoke(); }