update download system
新增方法YooAssets.SetDownloadSystemRedirectLimit()mlyDevMerge1.5.7
parent
480325827b
commit
fb28bcc535
|
@ -171,16 +171,16 @@ namespace YooAsset
|
|||
if (CacheSystem.DisableUnityCacheOnWebGL)
|
||||
{
|
||||
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(FileLoadPath);
|
||||
_webRequest.SendWebRequest();
|
||||
_steps = ESteps.CheckLoadWebFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
var hash = Hash128.Parse(MainBundleInfo.Bundle.FileHash);
|
||||
_webRequest = UnityWebRequestAssetBundle.GetAssetBundle(FileLoadPath, hash);
|
||||
_webRequest.SendWebRequest();
|
||||
_steps = ESteps.CheckLoadWebFile;
|
||||
}
|
||||
|
||||
DownloadSystem.SetUnityWebRequest(_webRequest);
|
||||
_webRequest.SendWebRequest();
|
||||
_steps = ESteps.CheckLoadWebFile;
|
||||
}
|
||||
|
||||
// 6. 检测AssetBundle加载结果
|
||||
|
|
|
@ -32,6 +32,11 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static CertificateHandler CertificateHandlerInstance = null;
|
||||
|
||||
/// <summary>
|
||||
/// 网络重定向次数
|
||||
/// </summary>
|
||||
public static int RedirectLimit { set; get; } = -1;
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传功能文件的最小字节数
|
||||
/// </summary>
|
||||
|
@ -128,11 +133,29 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static UnityWebRequest NewRequest(string requestURL)
|
||||
{
|
||||
UnityWebRequest webRequest;
|
||||
if (RequestDelegate != null)
|
||||
return RequestDelegate.Invoke(requestURL);
|
||||
webRequest = RequestDelegate.Invoke(requestURL);
|
||||
else
|
||||
webRequest = new UnityWebRequest(requestURL, UnityWebRequest.kHttpVerbGET);
|
||||
|
||||
var request = new UnityWebRequest(requestURL, UnityWebRequest.kHttpVerbGET);
|
||||
return request;
|
||||
SetUnityWebRequest(webRequest);
|
||||
return webRequest;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置网络请求的自定义参数
|
||||
/// </summary>
|
||||
public static void SetUnityWebRequest(UnityWebRequest webRequest)
|
||||
{
|
||||
if (RedirectLimit >= 0)
|
||||
webRequest.redirectLimit = RedirectLimit;
|
||||
|
||||
if (CertificateHandlerInstance != null)
|
||||
{
|
||||
webRequest.certificateHandler = CertificateHandlerInstance;
|
||||
webRequest.disposeCertificateHandlerOnDispose = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -101,13 +101,6 @@ namespace YooAsset
|
|||
handler.removeFileOnAbort = true;
|
||||
_webRequest.downloadHandler = handler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
|
||||
if (DownloadSystem.CertificateHandlerInstance != null)
|
||||
{
|
||||
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
|
||||
_webRequest.disposeCertificateHandlerOnDispose = false;
|
||||
}
|
||||
|
||||
_webRequest.SendWebRequest();
|
||||
_steps = ESteps.CheckDownload;
|
||||
}
|
||||
|
@ -137,13 +130,6 @@ namespace YooAsset
|
|||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
if (fileLength > 0)
|
||||
_webRequest.SetRequestHeader("Range", $"bytes={fileLength}-");
|
||||
|
||||
if (DownloadSystem.CertificateHandlerInstance != null)
|
||||
{
|
||||
_webRequest.certificateHandler = DownloadSystem.CertificateHandlerInstance;
|
||||
_webRequest.disposeCertificateHandlerOnDispose = false;
|
||||
}
|
||||
|
||||
_webRequest.SendWebRequest();
|
||||
_steps = ESteps.CheckDownload;
|
||||
}
|
||||
|
|
|
@ -217,6 +217,21 @@ namespace YooAsset
|
|||
DownloadSystem.RequestDelegate = requestDelegate;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置下载系统参数,网络重定向次数(Unity引擎默认值32)
|
||||
/// 注意:不支持设置为负值
|
||||
/// </summary>
|
||||
public static void SetDownloadSystemRedirectLimit(int redirectLimit)
|
||||
{
|
||||
if (redirectLimit < 0)
|
||||
{
|
||||
YooLogger.Warning($"Invalid param value : {redirectLimit}");
|
||||
return;
|
||||
}
|
||||
|
||||
DownloadSystem.RedirectLimit = redirectLimit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置异步系统参数,每帧执行消耗的最大时间切片(单位:毫秒)
|
||||
/// </summary>
|
||||
|
|
Loading…
Reference in New Issue