mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 08:20:18 +00:00
Compare commits
6 Commits
1.5.5-prev
...
1.5.7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8ab0a43dd | ||
|
|
9457a804b4 | ||
|
|
880d498618 | ||
|
|
ca89113c67 | ||
|
|
29d840b168 | ||
|
|
41d1586109 |
@@ -2,6 +2,18 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [1.5.7] - 2023-10-07
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- WebGL平台支持创建下载器。
|
||||||
|
|
||||||
|
## [1.5.6-preview] - 2023-09-26
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#172) 修复包裹初始化后,package的状态不正确的问题。
|
||||||
|
|
||||||
## [1.5.5-preview] - 2023-09-25
|
## [1.5.5-preview] - 2023-09-25
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -95,9 +95,6 @@ namespace YooAsset
|
|||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EStatus.Succeed;
|
Status = EStatus.Succeed;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:释放下载句柄
|
|
||||||
_downloader.DisposeHandler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ namespace YooAsset
|
|||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool _keepDownloadHandleLife = false;
|
|
||||||
private DownloadHandlerAssetBundle _downloadhandler;
|
private DownloadHandlerAssetBundle _downloadhandler;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
private bool _getAssetBundle = false;
|
||||||
|
private AssetBundle _cacheAssetBundle;
|
||||||
|
|
||||||
public WebDownloader(BundleInfo bundleInfo, int failedTryAgain, int timeout) : base(bundleInfo, failedTryAgain, timeout)
|
public WebDownloader(BundleInfo bundleInfo, int failedTryAgain, int timeout) : base(bundleInfo, failedTryAgain, timeout)
|
||||||
{
|
{
|
||||||
@@ -34,7 +34,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_steps == ESteps.None)
|
if (_steps == ESteps.None)
|
||||||
{
|
{
|
||||||
_keepDownloadHandleLife = (bool)param[0];
|
if (param.Length > 0)
|
||||||
|
{
|
||||||
|
_getAssetBundle = (bool)param[0];
|
||||||
|
}
|
||||||
_steps = ESteps.PrepareDownload;
|
_steps = ESteps.PrepareDownload;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -135,11 +138,18 @@ namespace YooAsset
|
|||||||
_lastCode = 0;
|
_lastCode = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 最终释放请求
|
if (_getAssetBundle)
|
||||||
DisposeRequest();
|
{
|
||||||
|
_cacheAssetBundle = _downloadhandler.assetBundle;
|
||||||
|
if (_cacheAssetBundle == null)
|
||||||
|
{
|
||||||
|
_lastError = "assetBundle is null";
|
||||||
|
_steps = ESteps.TryAgain;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_keepDownloadHandleLife == false)
|
// 最终释放请求
|
||||||
DisposeHandler();
|
DisposeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新尝试下载
|
// 重新尝试下载
|
||||||
@@ -148,7 +158,6 @@ namespace YooAsset
|
|||||||
if (_failedTryAgain <= 0)
|
if (_failedTryAgain <= 0)
|
||||||
{
|
{
|
||||||
DisposeRequest();
|
DisposeRequest();
|
||||||
DisposeHandler();
|
|
||||||
ReportError();
|
ReportError();
|
||||||
_status = EStatus.Failed;
|
_status = EStatus.Failed;
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
@@ -175,7 +184,6 @@ namespace YooAsset
|
|||||||
_lastCode = 0;
|
_lastCode = 0;
|
||||||
|
|
||||||
DisposeRequest();
|
DisposeRequest();
|
||||||
DisposeHandler();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void DisposeRequest()
|
private void DisposeRequest()
|
||||||
@@ -185,6 +193,11 @@ namespace YooAsset
|
|||||||
_webRequest.Dispose();
|
_webRequest.Dispose();
|
||||||
_webRequest = null;
|
_webRequest = null;
|
||||||
}
|
}
|
||||||
|
if (_downloadhandler != null)
|
||||||
|
{
|
||||||
|
_downloadhandler.Dispose();
|
||||||
|
_downloadhandler = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -192,22 +205,7 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public AssetBundle GetAssetBundle()
|
public AssetBundle GetAssetBundle()
|
||||||
{
|
{
|
||||||
if (_downloadhandler != null)
|
return _cacheAssetBundle;
|
||||||
return _downloadhandler.assetBundle;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 释放下载句柄
|
|
||||||
/// </summary>
|
|
||||||
public void DisposeHandler()
|
|
||||||
{
|
|
||||||
if (_downloadhandler != null)
|
|
||||||
{
|
|
||||||
_downloadhandler.Dispose();
|
|
||||||
_downloadhandler = null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,9 +77,9 @@ namespace YooAsset
|
|||||||
internal void SetFinish()
|
internal void SetFinish()
|
||||||
{
|
{
|
||||||
Progress = 1f;
|
Progress = 1f;
|
||||||
|
_callback?.Invoke(this); //注意:如果完成回调内发生异常,会导致Task无限期等待
|
||||||
if (_taskCompletionSource != null)
|
if (_taskCompletionSource != null)
|
||||||
_taskCompletionSource.TrySetResult(null);
|
_taskCompletionSource.TrySetResult(null);
|
||||||
_callback?.Invoke(this);
|
|
||||||
}
|
}
|
||||||
internal void SetStart()
|
internal void SetStart()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -33,6 +33,16 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
|
private List<BundleInfo> ConvertToDownloadList(List<PackageBundle> downloadList)
|
||||||
|
{
|
||||||
|
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
|
||||||
|
foreach (var packageBundle in downloadList)
|
||||||
|
{
|
||||||
|
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
||||||
|
result.Add(bundleInfo);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
||||||
{
|
{
|
||||||
string remoteMainURL = _remoteServices.GetRemoteMainURL(packageBundle.FileName);
|
string remoteMainURL = _remoteServices.GetRemoteMainURL(packageBundle.FileName);
|
||||||
@@ -84,15 +94,101 @@ namespace YooAsset
|
|||||||
|
|
||||||
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
List<BundleInfo> downloadList = GetDownloadListByAll(_activeManifest);
|
||||||
|
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
|
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||||
|
{
|
||||||
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
// 忽略APP资源
|
||||||
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
downloadList.Add(packageBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToDownloadList(downloadList);
|
||||||
|
}
|
||||||
|
|
||||||
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
List<BundleInfo> downloadList = GetDownloadListByTags(_activeManifest, tags);
|
||||||
|
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
}
|
}
|
||||||
|
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||||
|
{
|
||||||
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
|
{
|
||||||
|
// 忽略APP资源
|
||||||
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 如果未带任何标记,则统一下载
|
||||||
|
if (packageBundle.HasAnyTags() == false)
|
||||||
|
{
|
||||||
|
downloadList.Add(packageBundle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 查询DLC资源
|
||||||
|
if (packageBundle.HasTag(tags))
|
||||||
|
{
|
||||||
|
downloadList.Add(packageBundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToDownloadList(downloadList);
|
||||||
|
}
|
||||||
|
|
||||||
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
List<BundleInfo> downloadList = GetDownloadListByPaths(_activeManifest, assetInfos);
|
||||||
|
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
public List<BundleInfo> GetDownloadListByPaths(PackageManifest manifest, AssetInfo[] assetInfos)
|
||||||
|
{
|
||||||
|
// 获取资源对象的资源包和所有依赖资源包
|
||||||
|
List<PackageBundle> checkList = new List<PackageBundle>();
|
||||||
|
foreach (var assetInfo in assetInfos)
|
||||||
|
{
|
||||||
|
if (assetInfo.IsInvalid)
|
||||||
|
{
|
||||||
|
YooLogger.Warning(assetInfo.Error);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
PackageBundle mainBundle = manifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||||
|
if (checkList.Contains(mainBundle) == false)
|
||||||
|
checkList.Add(mainBundle);
|
||||||
|
|
||||||
|
// 注意:如果清单里未找到资源包会抛出异常!
|
||||||
|
PackageBundle[] dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||||
|
foreach (var dependBundle in dependBundles)
|
||||||
|
{
|
||||||
|
if (checkList.Contains(dependBundle) == false)
|
||||||
|
checkList.Add(dependBundle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||||
|
foreach (var packageBundle in checkList)
|
||||||
|
{
|
||||||
|
// 忽略APP资源
|
||||||
|
if (IsBuildinPackageBundle(packageBundle))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
downloadList.Add(packageBundle);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ConvertToDownloadList(downloadList);
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "1.5.5-preview",
|
"version": "1.5.7",
|
||||||
"unity": "2019.4",
|
"unity": "2019.4",
|
||||||
"description": "unity3d resources management system.",
|
"description": "unity3d resources management system.",
|
||||||
"author": {
|
"author": {
|
||||||
|
|||||||
Reference in New Issue
Block a user