update download system

remove timeout
This commit is contained in:
何冠峰
2025-07-17 20:59:15 +08:00
parent dd6fab46f9
commit b3622167da
43 changed files with 321 additions and 210 deletions

View File

@@ -94,4 +94,25 @@ namespace YooAsset
/// </summary>
public long FileSize;
}
/// <summary>
/// 导入文件的信息
/// </summary>
public struct ImportFileInfo
{
/// <summary>
/// 本地文件路径
/// </summary>
public string FilePath;
/// <summary>
/// 资源包名称
/// </summary>
public string BundleName;
/// <summary>
/// 资源包GUID
/// </summary>
public string BundleGUID;
}
}

View File

@@ -24,7 +24,7 @@ namespace YooAsset
/// </summary>
public AssetBundle Result { private set; get; }
internal UnityAssetBundleRequestOperation(PackageBundle packageBundle, bool disableUnityWebCache, string url, int timeout = 60) : base(url, timeout)
internal UnityAssetBundleRequestOperation(PackageBundle packageBundle, bool disableUnityWebCache, string url) : base(url)
{
_packageBundle = packageBundle;
_disableUnityWebCache = disableUnityWebCache;
@@ -40,7 +40,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -51,10 +50,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return;
}
if (CheckRequestResult())
{

View File

@@ -0,0 +1,77 @@
using UnityEngine.Networking;
using UnityEngine;
namespace YooAsset
{
internal class UnityWebCacheRequestOperation : UnityWebRequestOperation
{
protected enum ESteps
{
None,
CreateRequest,
Download,
Done,
}
private UnityWebRequestAsyncOperation _requestOperation;
private ESteps _steps = ESteps.None;
internal UnityWebCacheRequestOperation(string url) : base(url)
{
}
internal override void InternalStart()
{
_steps = ESteps.CreateRequest;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CreateRequest)
{
CreateWebRequest();
_steps = ESteps.Download;
}
if (_steps == ESteps.Download)
{
DownloadProgress = _webRequest.downloadProgress;
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
return;
if (CheckRequestResult())
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
}
// 注意:最终释放请求器
DisposeRequest();
}
}
/// <summary>
/// 设置请求头信息
/// </summary>
public void SetRequestHeader(string name, string value)
{
_webRequest.SetRequestHeader(name, value);
}
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 375d88bcf5b9a6146adaf98ceb5369f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -14,17 +14,24 @@ namespace YooAsset
}
private UnityWebRequestAsyncOperation _requestOperation;
private bool _checkTimeout = true;
private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
/// <summary>
/// 请求结果
/// </summary>
public byte[] Result { private set; get; }
internal UnityWebDataRequestOperation(string url, int timeout = 60) : base(url, timeout)
internal UnityWebDataRequestOperation(string url, int timeout) : base(url)
{
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -37,7 +44,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -48,11 +54,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
{
if (_checkTimeout)
CheckRequestTimeout();
return;
}
if (CheckRequestResult())
{
@@ -81,18 +83,11 @@ namespace YooAsset
}
}
/// <summary>
/// 不检测超时
/// </summary>
public void DontCheckTimeout()
{
_checkTimeout = false;
}
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest();

View File

@@ -17,10 +17,18 @@ namespace YooAsset
private readonly string _fileSavePath;
private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout = 60) : base(url, timeout)
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout) : base(url)
{
_fileSavePath = fileSavePath;
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -33,7 +41,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -44,10 +51,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return;
}
if (CheckRequestResult())
{
@@ -67,9 +71,10 @@ namespace YooAsset
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_fileSavePath);
handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest();

View File

@@ -8,11 +8,6 @@ namespace YooAsset
{
protected UnityWebRequest _webRequest;
protected readonly string _requestURL;
// 超时相关
private readonly float _timeout;
private ulong _latestDownloadBytes;
private float _latestDownloadRealtime;
private bool _isAbort = false;
/// <summary>
@@ -38,10 +33,9 @@ namespace YooAsset
get { return _requestURL; }
}
internal UnityWebRequestOperation(string url, int timeout)
internal UnityWebRequestOperation(string url)
{
_requestURL = url;
_timeout = timeout;
}
internal override void InternalAbort()
{
@@ -71,42 +65,6 @@ namespace YooAsset
}
}
/// <summary>
/// 重置超时计时
/// </summary>
protected void ResetTimeout()
{
_latestDownloadBytes = 0;
_latestDownloadRealtime = Time.realtimeSinceStartup;
}
/// <summary>
/// 检测超时
/// </summary>
protected void CheckRequestTimeout()
{
if (_webRequest.isDone)
return;
// 注意:在连续时间段内无新增下载数据及判定为超时
if (_isAbort == false)
{
if (_latestDownloadBytes != _webRequest.downloadedBytes)
{
_latestDownloadBytes = _webRequest.downloadedBytes;
_latestDownloadRealtime = Time.realtimeSinceStartup;
}
float offset = Time.realtimeSinceStartup - _latestDownloadRealtime;
if (offset > _timeout)
{
YooLogger.Warning($"Web request timeout : {_requestURL}");
_webRequest.Abort();
_isAbort = true;
}
}
}
/// <summary>
/// 检测请求结果
/// </summary>

View File

@@ -16,14 +16,22 @@ namespace YooAsset
private UnityWebRequestAsyncOperation _requestOperation;
private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
/// <summary>
/// 请求结果
/// </summary>
public string Result { private set; get; }
internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout)
internal UnityWebTextRequestOperation(string url, int timeout) : base(url)
{
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -36,7 +44,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -47,10 +54,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return;
}
if (CheckRequestResult())
{
@@ -81,8 +85,9 @@ namespace YooAsset
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest();

View File

@@ -83,7 +83,7 @@ namespace YooAsset
string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion);
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
_hashFileRequestOp.StartOperation();
AddChildOperation(_hashFileRequestOp);
}
@@ -124,7 +124,7 @@ namespace YooAsset
string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
_manifestFileRequestOp.StartOperation();
AddChildOperation(_manifestFileRequestOp);
}

View File

@@ -35,7 +35,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url);
_webDataRequestOp = new UnityWebDataRequestOperation(url, 60);
_webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
}

View File

@@ -46,7 +46,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url);
_webDataRequestOp = new UnityWebDataRequestOperation(url, 60);
_webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
}

View File

@@ -41,7 +41,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url);
_webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
_webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp);
}

View File

@@ -39,7 +39,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url);
_webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
_webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp);
}

View File

@@ -57,7 +57,7 @@ namespace YooAsset
{
if (_downloadFileOp == null)
{
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
_downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp);
@@ -304,7 +304,7 @@ namespace YooAsset
{
if (_downloadFileOp == null)
{
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
_downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp);

View File

@@ -85,7 +85,7 @@ namespace YooAsset
/// <summary>
/// 创建下载任务
/// </summary>
public UnityDownloadFileOperation DownloadFileAsync(PackageBundle bundle, string url, int timeout)
public UnityDownloadFileOperation DownloadFileAsync(PackageBundle bundle, string url)
{
// 查询旧的下载器
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
@@ -99,7 +99,7 @@ namespace YooAsset
bool isRequestLocalFile = DownloadSystemHelper.IsRequestLocalFile(url);
if (isRequestLocalFile)
{
newDownloader = new UnityDownloadLocalFileOperation(_fileSystem, bundle, url, timeout);
newDownloader = new UnityDownloadLocalFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader);
}
@@ -107,13 +107,13 @@ namespace YooAsset
{
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
{
newDownloader = new UnityDownloadResumeFileOperation(_fileSystem, bundle, url, timeout);
newDownloader = new UnityDownloadResumeFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader);
}
else
{
newDownloader = new UnityDownloadNormalFileOperation(_fileSystem, bundle, url, timeout);
newDownloader = new UnityDownloadNormalFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader);
}

View File

@@ -67,7 +67,7 @@ namespace YooAsset
}
string url = GetRequestURL();
_unityDownloadFileOp = _fileSystem.DownloadCenter.DownloadFileAsync(Bundle, url, _options.Timeout);
_unityDownloadFileOp = _fileSystem.DownloadCenter.DownloadFileAsync(Bundle, url);
_steps = ESteps.CheckRequest;
}

View File

@@ -22,7 +22,7 @@ namespace YooAsset
/// </summary>
public int RefCount { private set; get; }
internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout) : base(url, timeout)
internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url) : base(url)
{
_fileSystem = fileSystem;
_bundle = bundle;

View File

@@ -9,8 +9,8 @@ namespace YooAsset
private VerifyTempFileOperation _verifyOperation;
private ESteps _steps = ESteps.None;
internal UnityDownloadLocalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60)
: base(fileSystem, bundle, url, timeout)
internal UnityDownloadLocalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url)
{
}
internal override void InternalStart()
@@ -32,7 +32,6 @@ namespace YooAsset
if (File.Exists(_tempFilePath))
File.Delete(_tempFilePath);
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -44,10 +43,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress;
if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return;
}
// 检查网络错误
if (CheckRequestResult())
@@ -161,9 +157,9 @@ namespace YooAsset
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest();

View File

@@ -9,8 +9,8 @@ namespace YooAsset
private VerifyTempFileOperation _verifyOperation;
private ESteps _steps = ESteps.None;
internal UnityDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60)
: base(fileSystem, bundle, url, timeout)
internal UnityDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url)
{
}
internal override void InternalStart()
@@ -29,7 +29,6 @@ namespace YooAsset
if (File.Exists(_tempFilePath))
File.Delete(_tempFilePath);
ResetTimeout();
CreateWebRequest();
_steps = ESteps.Download;
}
@@ -41,10 +40,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress;
if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return;
}
// 检查网络错误
if (CheckRequestResult())
@@ -115,9 +111,9 @@ namespace YooAsset
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest();

View File

@@ -10,8 +10,8 @@ namespace YooAsset
private long _fileOriginLength = 0;
private ESteps _steps = ESteps.None;
internal UnityDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60)
: base(fileSystem, bundle, url, timeout)
internal UnityDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url)
{
}
internal override void InternalStart()
@@ -46,7 +46,6 @@ namespace YooAsset
}
}
ResetTimeout();
CreateWebRequest(fileBeginLength);
_steps = ESteps.Download;
}
@@ -58,10 +57,7 @@ namespace YooAsset
DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes;
Progress = DownloadProgress;
if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return;
}
// 检查网络错误
if (CheckRequestResult())
@@ -147,9 +143,9 @@ namespace YooAsset
}
private void CreateWebRequest(long fileBeginLength)
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
var handler = new DownloadHandlerFile(_tempFilePath, true);
handler.removeFileOnAbort = false;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true;
if (fileBeginLength > 0)

View File

@@ -64,7 +64,7 @@ namespace YooAsset
if (_loadWebPackageManifestOp == null)
{
string packageHash = _requestWebPackageHashOp.PackageHash;
_loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash);
_loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash, _timeout);
_loadWebPackageManifestOp.StartOperation();
AddChildOperation(_loadWebPackageManifestOp);
}

View File

@@ -15,6 +15,7 @@ namespace YooAsset
private readonly DefaultWebRemoteFileSystem _fileSystem;
private readonly string _packageVersion;
private readonly string _packageHash;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp;
private DeserializeManifestOperation _deserializer;
private int _requestCount = 0;
@@ -26,11 +27,12 @@ namespace YooAsset
public PackageManifest Manifest { private set; get; }
internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash)
internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash, int timeout)
{
_fileSystem = fileSystem;
_packageVersion = packageVersion;
_packageHash = packageHash;
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -48,7 +50,7 @@ namespace YooAsset
{
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
string url = GetWebRequestURL(fileName);
_webDataRequestOp = new UnityWebDataRequestOperation(url);
_webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
}

View File

@@ -48,7 +48,7 @@ namespace YooAsset
*/
#endif
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem, 60);
_loadCatalogFileOp.StartOperation();
AddChildOperation(_loadCatalogFileOp);
}

View File

@@ -64,7 +64,7 @@ namespace YooAsset
if (_loadWebPackageManifestOp == null)
{
string packageHash = _requestWebPackageHashOp.PackageHash;
_loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
_loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash, _timeout);
_loadWebPackageManifestOp.StartOperation();
AddChildOperation(_loadWebPackageManifestOp);
}

View File

@@ -16,12 +16,14 @@ namespace YooAsset
}
private readonly DefaultWebServerFileSystem _fileSystem;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp;
private ESteps _steps = ESteps.None;
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem, int timeout)
{
_fileSystem = fileSystem;
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -38,7 +40,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url);
_webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
}

View File

@@ -15,6 +15,7 @@ namespace YooAsset
private readonly DefaultWebServerFileSystem _fileSystem;
private readonly string _packageVersion;
private readonly string _packageHash;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp;
private DeserializeManifestOperation _deserializer;
private ESteps _steps = ESteps.None;
@@ -25,11 +26,12 @@ namespace YooAsset
public PackageManifest Manifest { private set; get; }
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash)
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash, int timeout)
{
_fileSystem = fileSystem;
_packageVersion = packageVersion;
_packageHash = packageHash;
_timeout = timeout;
}
internal override void InternalStart()
{
@@ -46,7 +48,7 @@ namespace YooAsset
{
string filePath = _fileSystem.GetWebPackageManifestFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url);
_webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp);
}

View File

@@ -8,11 +8,6 @@ namespace YooAsset
/// </summary>
public readonly int FailedTryAgain;
/// <summary>
/// 超时时间
/// </summary>
public readonly int Timeout;
/// <summary>
/// 主资源地址
/// </summary>
@@ -28,10 +23,9 @@ namespace YooAsset
/// </summary>
public string ImportFilePath { set; get; }
public DownloadFileOptions(int failedTryAgain, int timeout)
public DownloadFileOptions(int failedTryAgain)
{
FailedTryAgain = failedTryAgain;
Timeout = timeout;
}
/// <summary>

View File

@@ -2,7 +2,7 @@
namespace YooAsset
{
internal abstract class DownloadAssetBundleOperation : AsyncOperationBase
internal abstract class LoadWebAssetBundleOperation : AsyncOperationBase
{
/// <summary>
/// AssetBundle对象

View File

@@ -2,7 +2,7 @@
namespace YooAsset
{
internal class DownloadEncryptAssetBundleOperation : DownloadAssetBundleOperation
internal class LoadWebEncryptAssetBundleOperation : LoadWebAssetBundleOperation
{
protected enum ESteps
{
@@ -16,7 +16,6 @@ namespace YooAsset
private UnityWebDataRequestOperation _unityWebDataRequestOp;
private readonly PackageBundle _bundle;
private readonly DownloadFileOptions _options;
private readonly bool _checkTimeout;
private readonly IWebDecryptionServices _decryptionServices;
protected int _requestCount = 0;
@@ -24,11 +23,10 @@ namespace YooAsset
protected int _failedTryAgain;
private ESteps _steps = ESteps.None;
internal DownloadEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool checkTimeout, IWebDecryptionServices decryptionServices)
internal LoadWebEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, IWebDecryptionServices decryptionServices)
{
_bundle = bundle;
_options = options;
_checkTimeout = checkTimeout;
_decryptionServices = decryptionServices;
}
internal override void InternalStart()
@@ -53,10 +51,8 @@ namespace YooAsset
}
string url = GetRequestURL();
_unityWebDataRequestOp = new UnityWebDataRequestOperation(url, _options.Timeout);
_unityWebDataRequestOp = new UnityWebDataRequestOperation(url, 0);
_unityWebDataRequestOp.StartOperation();
if (_checkTimeout == false)
_unityWebDataRequestOp.DontCheckTimeout();
_steps = ESteps.CheckRequest;
}

View File

@@ -2,7 +2,7 @@
namespace YooAsset
{
internal class DownloadNormalAssetBundleOperation : DownloadAssetBundleOperation
internal class LoadWebNormalAssetBundleOperation : LoadWebAssetBundleOperation
{
protected enum ESteps
{
@@ -13,18 +13,18 @@ namespace YooAsset
Done,
}
private UnityAssetBundleRequestOperation _unityAssetBundleRequestOp;
private readonly PackageBundle _bundle;
private readonly DownloadFileOptions _options;
private readonly bool _disableUnityWebCache;
private UnityAssetBundleRequestOperation _unityAssetBundleRequestOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected int _failedTryAgain;
private ESteps _steps = ESteps.None;
internal DownloadNormalAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool disableUnityWebCache)
internal LoadWebNormalAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool disableUnityWebCache)
{
_bundle = bundle;
_options = options;
@@ -43,7 +43,7 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest)
{
string url = GetRequestURL();
_unityAssetBundleRequestOp = new UnityAssetBundleRequestOperation(_bundle, _disableUnityWebCache, url, _options.Timeout);
_unityAssetBundleRequestOp = new UnityAssetBundleRequestOperation(_bundle, _disableUnityWebCache, url);
_unityAssetBundleRequestOp.StartOperation();
_steps = ESteps.CheckRequest;
}

View File

@@ -36,9 +36,9 @@ namespace YooAsset
/// <summary>
/// 创建下载器
/// </summary>
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
public FSDownloadFileOperation CreateDownloader(int failedTryAgain)
{
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout);
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain);
options.ImportFilePath = _importFilePath;
return _fileSystem.DownloadFileAsync(Bundle, options);
}

View File

@@ -34,15 +34,16 @@ namespace YooAsset
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
// 下载相关
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout);
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain);
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain);
ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain);
// 解压相关
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain);
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain);
// 导入相关
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout);
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain);
ResourceImporterOperation CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain);
}
}

View File

@@ -40,7 +40,6 @@ namespace YooAsset
private readonly string _packageName;
private readonly int _downloadingMaxNumber;
private readonly int _failedTryAgain;
private readonly int _timeout;
private readonly List<BundleInfo> _bundleInfoList;
private readonly List<FSDownloadFileOperation> _downloaders = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT);
private readonly List<FSDownloadFileOperation> _removeList = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT);
@@ -102,13 +101,12 @@ namespace YooAsset
public DownloadFileBegin DownloadFileBeginCallback { set; get; }
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
{
_packageName = packageName;
_bundleInfoList = downloadList;
_downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ;
_failedTryAgain = failedTryAgain;
_timeout = timeout;
// 设置包裹名称 (fix #210)
SetPackageName(packageName);
@@ -203,7 +201,7 @@ namespace YooAsset
{
int index = _bundleInfoList.Count - 1;
var bundleInfo = _bundleInfoList[index];
var downloader = bundleInfo.CreateDownloader(_failedTryAgain, _timeout);
var downloader = bundleInfo.CreateDownloader(_failedTryAgain);
downloader.StartOperation();
this.AddChildOperation(downloader);
@@ -374,52 +372,52 @@ namespace YooAsset
public sealed class ResourceDownloaderOperation : DownloaderOperation
{
internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout)
internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{
}
/// <summary>
/// 创建空的下载器
/// </summary>
internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int downloadingMaxNumber, int failedTryAgain, int timeout)
internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int downloadingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceDownloaderOperation(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(packageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
}
public sealed class ResourceUnpackerOperation : DownloaderOperation
{
internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout)
internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{
}
/// <summary>
/// 创建空的解压器
/// </summary>
internal static ResourceUnpackerOperation CreateEmptyUnpacker(string packageName, int upackingMaxNumber, int failedTryAgain, int timeout)
internal static ResourceUnpackerOperation CreateEmptyUnpacker(string packageName, int upackingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceUnpackerOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
var operation = new ResourceUnpackerOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain);
return operation;
}
}
public sealed class ResourceImporterOperation : DownloaderOperation
{
internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout)
internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{
}
/// <summary>
/// 创建空的导入器
/// </summary>
internal static ResourceImporterOperation CreateEmptyImporter(string packageName, int upackingMaxNumber, int failedTryAgain, int timeout)
internal static ResourceImporterOperation CreateEmptyImporter(string packageName, int upackingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceImporterOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
var operation = new ResourceImporterOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain);
return operation;
}
}

View File

@@ -107,11 +107,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
@@ -127,11 +127,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
@@ -147,11 +147,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
}
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
@@ -167,7 +167,7 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
}
List<AssetInfo> assetInfos = new List<AssetInfo>();
@@ -175,7 +175,7 @@ namespace YooAsset
assetInfos.Add(assetInfo);
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
@@ -191,7 +191,7 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
}
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -202,7 +202,7 @@ namespace YooAsset
}
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
}

View File

@@ -104,44 +104,50 @@ namespace YooAsset
}
// 下载相关
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = GetDownloadListByAll(ActiveManifest);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = GetDownloadListByTags(ActiveManifest, tags);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
{
List<BundleInfo> downloadList = GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation;
}
// 解压相关
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain)
{
List<BundleInfo> unpcakList = GetUnpackListByAll(ActiveManifest);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
return operation;
}
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain)
{
List<BundleInfo> unpcakList = GetUnpackListByTags(ActiveManifest, tags);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
return operation;
}
// 导入相关
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain)
{
List<BundleInfo> importerList = GetImporterListByFilePaths(ActiveManifest, filePaths);
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
var operation = new ResourceImporterOperation(PackageName, importerList, importingMaxNumber, failedTryAgain);
return operation;
}
ResourceImporterOperation IPlayMode.CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain)
{
List<BundleInfo> importerList = GetImporterListByFileInfos(ActiveManifest, fileInfos);
var operation = new ResourceImporterOperation(PackageName, importerList, importingMaxNumber, failedTryAgain);
return operation;
}
#endregion
@@ -419,11 +425,56 @@ namespace YooAsset
if (manifest == null)
return new List<BundleInfo>();
List<BundleInfo> result = new List<BundleInfo>();
foreach (var filePath in filePaths)
ImportFileInfo[] fileInfos = new ImportFileInfo[filePaths.Length];
for (int i = 0; i < filePaths.Length; i++)
{
string fileName = System.IO.Path.GetFileName(filePath);
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle))
ImportFileInfo fileInfo = new ImportFileInfo();
fileInfo.FilePath = filePaths[i];
fileInfos[i] = fileInfo;
}
return GetImporterListByFileInfos(manifest, fileInfos);
}
public List<BundleInfo> GetImporterListByFileInfos(PackageManifest manifest, ImportFileInfo[] fileInfos)
{
if (manifest == null)
return new List<BundleInfo>();
List<BundleInfo> result = new List<BundleInfo>();
foreach (var fileInfo in fileInfos)
{
string filePath = fileInfo.FilePath;
if (string.IsNullOrEmpty(filePath))
continue;
PackageBundle packageBundle = null;
if (string.IsNullOrEmpty(fileInfo.BundleName) == false)
{
if (manifest.TryGetPackageBundleByBundleName(fileInfo.BundleName, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, bundle name : {fileInfo.BundleName}");
continue;
}
}
else if (string.IsNullOrEmpty(fileInfo.BundleGUID) == false)
{
if (manifest.TryGetPackageBundleByBundleGUID(fileInfo.BundleGUID, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, bundle guid : {fileInfo.BundleGUID}");
continue;
}
}
else
{
string fileName = System.IO.Path.GetFileName(filePath);
if (manifest.TryGetPackageBundleByFileName(fileName, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, file name : {fileName}");
continue;
}
}
if (packageBundle != null)
{
var fileSystem = GetBelongFileSystem(packageBundle);
if (fileSystem == null)
@@ -435,10 +486,6 @@ namespace YooAsset
result.Add(bundleInfo);
}
}
else
{
YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
}
}
return result;
}

View File

@@ -969,7 +969,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -982,7 +982,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -995,7 +995,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1011,11 +1011,11 @@ namespace YooAsset
DebugCheckInitialize();
var assetInfo = ConvertLocationToAssetInfo(location, null);
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
}
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain, timeout);
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1035,11 +1035,11 @@ namespace YooAsset
var assetInfo = ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
}
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain);
}
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain, timeout);
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1054,11 +1054,11 @@ namespace YooAsset
{
DebugCheckInitialize();
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
}
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain, timeout);
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1072,11 +1072,11 @@ namespace YooAsset
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
}
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain, timeout);
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain);
}
#endregion
@@ -1089,7 +1089,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
return _playModeImpl.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1101,7 +1101,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
return _playModeImpl.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
}
/// <summary>
@@ -1113,7 +1113,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
return _playModeImpl.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
}
#endregion
@@ -1128,7 +1128,20 @@ namespace YooAsset
public ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceImporterByFilePaths(filePaths, importerMaxNumber, failedTryAgain, int.MaxValue);
return _playModeImpl.CreateResourceImporterByFilePaths(filePaths, importerMaxNumber, failedTryAgain);
}
/// <summary>
/// 创建资源导入器
/// 注意资源信息里需要指定BundleName或BundleGUID
/// </summary>
/// <param name="fileInfos">资源信息列表</param>
/// <param name="importerMaxNumber">同时导入的最大文件数</param>
/// <param name="failedTryAgain">导入失败的重试次数</param>
public ResourceImporterOperation CreateResourceImporter(ImportFileInfo[] fileInfos, int importerMaxNumber, int failedTryAgain)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceImporterByFileInfos(fileInfos, importerMaxNumber, failedTryAgain);
}
#endregion