feat(DownloadSystem):支持自定义下载请求

This commit is contained in:
huanggongming
2023-02-24 12:18:18 +08:00
parent 0232e5adec
commit eb16ba8365
7 changed files with 54 additions and 5 deletions
@@ -0,0 +1,28 @@
using JetBrains.Annotations;
using UnityEngine.Networking;
namespace YooAsset
{
public delegate UnityWebRequest DownloadRequestDelegate(string url);
/// <summary>
/// 自定义下载器的请求
/// </summary>
internal static class DownloadRequestUtil
{
[CanBeNull] private static DownloadRequestDelegate _downloadRequestDelegate;
public static void SetRequestDelegate(DownloadRequestDelegate requestDelegate)
{
_downloadRequestDelegate = requestDelegate;
}
public static UnityWebRequest NewRequest(string requestURL)
{
return _downloadRequestDelegate != null
? _downloadRequestDelegate?.Invoke(requestURL)
: new UnityWebRequest(requestURL, UnityWebRequest.kHttpVerbGET);
}
}
}