mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-23 09:10:11 +00:00
Compare commits
16 Commits
2.3.6
...
927400b669
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
927400b669 | ||
|
|
c0d42e79d8 | ||
|
|
b843c6b0ed | ||
|
|
9fb7f8bbfe | ||
|
|
b0382afad0 | ||
|
|
1ab7689174 | ||
|
|
29d456c065 | ||
|
|
b0dc829b04 | ||
|
|
b3ead90832 | ||
|
|
7bf00d4ff6 | ||
|
|
030e94d8ff | ||
|
|
cf05254121 | ||
|
|
3f786bca3b | ||
|
|
98719d212f | ||
|
|
3409f7ce4d | ||
|
|
f57b354e9b |
@@ -2,6 +2,62 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [2.3.7] - 2025-04-01
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- (#526) 运行时资源清单的哈希值验证兼容了MD5和CRC32两种方式。
|
||||||
|
- (#515) 优化了资源路径大小写不敏感的逻辑代码,减少字符串操作产生的GC。
|
||||||
|
- (#523) UnloadUnusedAssetsOperation方法支持了分帧处理。
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#520) 修复了UWP平台获取WWW加载路径未适配的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了文件系统初始化参数:INSTALL_CLEAR_MODE
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 覆盖安装清理模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EOverwriteInstallClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不做任何处理
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||||
|
/// </summary>
|
||||||
|
ClearAllCacheFiles = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的清单文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllManifestFiles = 3,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增了初始化参数:BundleLoadingMaxConcurrency
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public abstract class InitializeParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同时加载Bundle文件的最大并发数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## [2.3.6] - 2025-03-25
|
## [2.3.6] - 2025-03-25
|
||||||
|
|
||||||
### Improvements
|
### Improvements
|
||||||
|
|||||||
@@ -1,30 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
|
||||||
{
|
|
||||||
internal class DownloadParam
|
|
||||||
{
|
|
||||||
public readonly int FailedTryAgain;
|
|
||||||
public readonly int Timeout;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 导入的本地文件路径
|
|
||||||
/// </summary>
|
|
||||||
public string ImportFilePath { set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 主资源地址
|
|
||||||
/// </summary>
|
|
||||||
public string MainURL { set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 备用资源地址
|
|
||||||
/// </summary>
|
|
||||||
public string FallbackURL { set; get; }
|
|
||||||
|
|
||||||
public DownloadParam(int failedTryAgain, int timeout)
|
|
||||||
{
|
|
||||||
FailedTryAgain = failedTryAgain;
|
|
||||||
Timeout = timeout;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -67,7 +67,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#elif UNITY_STANDALONE_OSX
|
#elif UNITY_STANDALONE_OSX
|
||||||
url = new System.Uri(path).ToString();
|
url = new System.Uri(path).ToString();
|
||||||
#elif UNITY_STANDALONE
|
#elif UNITY_STANDALONE || UNITY_WSA
|
||||||
url = StringUtility.Format("file:///{0}", path);
|
url = StringUtility.Format("file:///{0}", path);
|
||||||
#else
|
#else
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
|
|||||||
@@ -58,6 +58,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -104,15 +109,15 @@ namespace YooAsset
|
|||||||
var operation = new DBFSRequestPackageVersionOperation(this);
|
var operation = new DBFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
return _unpackFileSystem.ClearCacheFilesAsync(manifest, clearMode, clearParam);
|
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options);
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
// 注意:业务层的解压下载器会依赖内置文件系统的下载方法
|
// 注意:业务层的解压下载器会依赖内置文件系统的下载方法
|
||||||
param.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
options.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
||||||
return _unpackFileSystem.DownloadFileAsync(bundle, param);
|
return _unpackFileSystem.DownloadFileAsync(bundle, options);
|
||||||
}
|
}
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
{
|
{
|
||||||
@@ -145,6 +150,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = Convert.ToBoolean(value);
|
AppendFileExtension = Convert.ToBoolean(value);
|
||||||
@@ -184,6 +193,7 @@ namespace YooAsset
|
|||||||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||||
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||||
_unpackFileSystem.OnCreate(packageName, null);
|
_unpackFileSystem.OnCreate(packageName, null);
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,6 +65,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
public EFileVerifyLevel FileVerifyLevel { private set; get; } = EFileVerifyLevel.Middle;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义参数:覆盖安装缓存清理模式
|
||||||
|
/// </summary>
|
||||||
|
public EOverwriteInstallClearMode InstallClearMode { private set; get; } = EOverwriteInstallClearMode.ClearAllManifestFiles;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:数据文件追加文件格式
|
/// 自定义参数:数据文件追加文件格式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -115,43 +120,43 @@ namespace YooAsset
|
|||||||
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearAllCacheBundleFilesOperation(this);
|
var operation = new ClearAllCacheBundleFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, clearParam);
|
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearAllCacheManifestFilesOperation(this);
|
var operation = new ClearAllCacheManifestFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string error = $"Invalid clear mode : {clearMode}";
|
string error = $"Invalid clear mode : {options.ClearMode}";
|
||||||
var operation = new FSClearCacheFilesCompleteOperation(error);
|
var operation = new FSClearCacheFilesCompleteOperation(error);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
var downloader = DownloadCenter.DownloadFileAsync(bundle, param);
|
var downloader = DownloadCenter.DownloadFileAsync(bundle, options);
|
||||||
downloader.Reference(); //增加下载器的引用计数
|
downloader.Reference(); //增加下载器的引用计数
|
||||||
|
|
||||||
// 注意:将下载器进行包裹,可以避免父类任务终止的时候,连带子任务里的下载器也一起被终止!
|
// 注意:将下载器进行包裹,可以避免父类任务终止的时候,连带子任务里的下载器也一起被终止!
|
||||||
@@ -188,6 +193,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
FileVerifyLevel = (EFileVerifyLevel)value;
|
FileVerifyLevel = (EFileVerifyLevel)value;
|
||||||
}
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.INSTALL_CLEAR_MODE)
|
||||||
|
{
|
||||||
|
InstallClearMode = (EOverwriteInstallClearMode)value;
|
||||||
|
}
|
||||||
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
|
||||||
{
|
{
|
||||||
AppendFileExtension = Convert.ToBoolean(value);
|
AppendFileExtension = Convert.ToBoolean(value);
|
||||||
@@ -227,8 +236,8 @@ namespace YooAsset
|
|||||||
_packageRoot = packageRoot;
|
_packageRoot = packageRoot;
|
||||||
|
|
||||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.BundleFilesFolderName);
|
||||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
|
||||||
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||||
|
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||||
}
|
}
|
||||||
public virtual void OnDestroy()
|
public virtual void OnDestroy()
|
||||||
{
|
{
|
||||||
@@ -500,7 +509,18 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除所有清单文件
|
/// 删除所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
public void DeleteAllBundleFiles()
|
||||||
|
{
|
||||||
|
if (Directory.Exists(_cacheBundleFilesRoot))
|
||||||
|
{
|
||||||
|
Directory.Delete(_cacheBundleFilesRoot, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除所有缓存的清单文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void DeleteAllManifestFiles()
|
public void DeleteAllManifestFiles()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 覆盖安装清理模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EOverwriteInstallClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不做任何处理
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||||
|
/// </summary>
|
||||||
|
ClearAllCacheFiles = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的资源文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有缓存的清单文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllManifestFiles = 3,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 56ea224b45d314e4a86b558404e9b6c8
|
guid: c61fdc079dca97548a0158b8100ec258
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -46,9 +46,32 @@ namespace YooAsset
|
|||||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||||
if (appFootPrint.IsDirty())
|
if (appFootPrint.IsDirty())
|
||||||
{
|
{
|
||||||
_fileSystem.DeleteAllManifestFiles();
|
if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.None)
|
||||||
|
{
|
||||||
|
YooLogger.Warning("Do nothing when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllCacheFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllBundleFiles();
|
||||||
|
_fileSystem.DeleteAllManifestFiles();
|
||||||
|
YooLogger.Warning("Delete all cache files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllBundleFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllBundleFiles();
|
||||||
|
YooLogger.Warning("Delete all bundle files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else if (_fileSystem.InstallClearMode == EOverwriteInstallClearMode.ClearAllManifestFiles)
|
||||||
|
{
|
||||||
|
_fileSystem.DeleteAllManifestFiles();
|
||||||
|
YooLogger.Warning("Delete all manifest files when overwrite install application !");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException(_fileSystem.InstallClearMode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
appFootPrint.Coverage(_fileSystem.PackageName);
|
appFootPrint.Coverage(_fileSystem.PackageName);
|
||||||
YooLogger.Warning("Delete manifest files when application foot print dirty !");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.SearchCacheFiles;
|
_steps = ESteps.SearchCacheFiles;
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ namespace YooAsset
|
|||||||
// 注意:边玩边下下载器引用计数没有Release
|
// 注意:边玩边下下载器引用计数没有Release
|
||||||
if (_downloadFileOp == null)
|
if (_downloadFileOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
|
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||||
_downloadFileOp.StartOperation();
|
_downloadFileOp.StartOperation();
|
||||||
AddChildOperation(_downloadFileOp);
|
AddChildOperation(_downloadFileOp);
|
||||||
}
|
}
|
||||||
@@ -297,8 +297,8 @@ namespace YooAsset
|
|||||||
// 注意:边玩边下下载器引用计数没有Release
|
// 注意:边玩边下下载器引用计数没有Release
|
||||||
if (_downloadFileOp == null)
|
if (_downloadFileOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, downloadParam);
|
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||||
_downloadFileOp.StartOperation();
|
_downloadFileOp.StartOperation();
|
||||||
AddChildOperation(_downloadFileOp);
|
AddChildOperation(_downloadFileOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建下载任务
|
/// 创建下载任务
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
// 查询旧的下载器
|
// 查询旧的下载器
|
||||||
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
|
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
|
||||||
@@ -83,29 +83,29 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 设置请求URL
|
// 设置请求URL
|
||||||
if (string.IsNullOrEmpty(param.ImportFilePath))
|
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||||
{
|
{
|
||||||
param.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName);
|
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||||
param.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 注意:把本地文件路径指定为远端下载地址
|
// 注意:把本地文件路径指定为远端下载地址
|
||||||
param.MainURL = DownloadSystemHelper.ConvertToWWWPath(param.ImportFilePath);
|
options.MainURL = DownloadSystemHelper.ConvertToWWWPath(options.ImportFilePath);
|
||||||
param.FallbackURL = param.MainURL;
|
options.FallbackURL = options.MainURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建新的下载器
|
// 创建新的下载器
|
||||||
DefaultDownloadFileOperation newDownloader;
|
DefaultDownloadFileOperation newDownloader;
|
||||||
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
|
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
|
||||||
{
|
{
|
||||||
newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, param);
|
newDownloader = new DownloadResumeFileOperation(_fileSystem, bundle, options);
|
||||||
AddChildOperation(newDownloader);
|
AddChildOperation(newDownloader);
|
||||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, param);
|
newDownloader = new DownloadNormalFileOperation(_fileSystem, bundle, options);
|
||||||
AddChildOperation(newDownloader);
|
AddChildOperation(newDownloader);
|
||||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ namespace YooAsset
|
|||||||
private string _tempFilePath;
|
private string _tempFilePath;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
|
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Options.MainURL);
|
||||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||||
_steps = ESteps.CheckExists;
|
_steps = ESteps.CheckExists;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal DownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
|
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Options.MainURL);
|
||||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||||
_steps = ESteps.CheckExists;
|
_steps = ESteps.CheckExists;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,12 +66,12 @@ namespace YooAsset
|
|||||||
var operation = new DEFSRequestPackageVersionOperation(this);
|
var operation = new DEFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -59,8 +59,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_fileData);
|
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,8 @@ namespace YooAsset
|
|||||||
base.OnCreate(packageName, rootDirectory);
|
base.OnCreate(packageName, rootDirectory);
|
||||||
|
|
||||||
// 注意:重写保存根目录和临时目录
|
// 注意:重写保存根目录和临时目录
|
||||||
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
_cacheBundleFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveBundleFilesFolderName);
|
||||||
|
_cacheManifestFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveManifestFilesFolderName);
|
||||||
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
_tempFilesRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,8 +11,13 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 保存的资源文件的文件夹名称
|
/// 保存的资源文件的文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const string SaveFilesFolderName = "UnpackFiles";
|
public const string SaveBundleFilesFolderName = "UnpackBundleFiles";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存的清单文件的文件夹名称
|
||||||
|
/// </summary>
|
||||||
|
public const string SaveManifestFilesFolderName = "UnpackManifestFiles";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载的临时文件的文件夹名称
|
/// 下载的临时文件的文件夹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -73,12 +73,12 @@ namespace YooAsset
|
|||||||
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,19 +34,19 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_downloadAssetBundleOp == null)
|
if (_downloadAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||||
downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
|
|
||||||
if (_bundle.Encrypted)
|
if (_bundle.Encrypted)
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,8 +72,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,12 +82,12 @@ namespace YooAsset
|
|||||||
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
throw new System.NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,20 +34,20 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
if (_downloadAssetBundleOp == null)
|
if (_downloadAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
||||||
downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
options.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
||||||
downloadParam.FallbackURL = downloadParam.MainURL;
|
options.FallbackURL = options.MainURL;
|
||||||
|
|
||||||
if (_bundle.Encrypted)
|
if (_bundle.Encrypted)
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(true, _fileSystem.DecryptionServices, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebNormalAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,8 +69,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.VerifyFileData)
|
if (_steps == ESteps.VerifyFileData)
|
||||||
{
|
{
|
||||||
string fileHash = HashUtility.BytesCRC32(_webDataRequestOp.Result);
|
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||||
if (fileHash == _packageHash)
|
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadManifest;
|
_steps = ESteps.LoadManifest;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ namespace YooAsset
|
|||||||
public class FileSystemParametersDefine
|
public class FileSystemParametersDefine
|
||||||
{
|
{
|
||||||
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||||
|
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
||||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||||
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
||||||
|
|||||||
@@ -37,13 +37,13 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam);
|
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 下载Bundle文件
|
/// 下载Bundle文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param);
|
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载Bundle文件
|
/// 加载Bundle文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,6 +1,19 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
internal class ClearCacheFilesOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理模式
|
||||||
|
/// </summary>
|
||||||
|
public string ClearMode;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 附加参数
|
||||||
|
/// </summary>
|
||||||
|
public object ClearParam;
|
||||||
|
}
|
||||||
|
|
||||||
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,40 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
|
internal class DownloadFileOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 失败后重试次数
|
||||||
|
/// </summary>
|
||||||
|
public readonly int FailedTryAgain;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 超时时间
|
||||||
|
/// </summary>
|
||||||
|
public readonly int Timeout;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 主资源地址
|
||||||
|
/// </summary>
|
||||||
|
public string MainURL { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 备用资源地址
|
||||||
|
/// </summary>
|
||||||
|
public string FallbackURL { set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 导入的本地文件路径
|
||||||
|
/// </summary>
|
||||||
|
public string ImportFilePath { set; get; }
|
||||||
|
|
||||||
|
public DownloadFileOptions(int failedTryAgain, int timeout)
|
||||||
|
{
|
||||||
|
FailedTryAgain = failedTryAgain;
|
||||||
|
Timeout = timeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
internal abstract class FSDownloadFileOperation : AsyncOperationBase
|
internal abstract class FSDownloadFileOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
public PackageBundle Bundle { private set; get; }
|
public PackageBundle Bundle { private set; get; }
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 下载参数
|
// 下载参数
|
||||||
protected readonly DownloadParam Param;
|
protected readonly DownloadFileOptions Options;
|
||||||
|
|
||||||
// 请求相关
|
// 请求相关
|
||||||
protected UnityWebRequest _webRequest;
|
protected UnityWebRequest _webRequest;
|
||||||
@@ -35,10 +35,10 @@ namespace YooAsset
|
|||||||
protected int FailedTryAgain;
|
protected int FailedTryAgain;
|
||||||
|
|
||||||
|
|
||||||
internal DefaultDownloadFileOperation(PackageBundle bundle, DownloadParam param) : base(bundle)
|
internal DefaultDownloadFileOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||||
{
|
{
|
||||||
Param = param;
|
Options = options;
|
||||||
FailedTryAgain = param.FailedTryAgain;
|
FailedTryAgain = options.FailedTryAgain;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -49,9 +49,9 @@ namespace YooAsset
|
|||||||
// 轮流返回请求地址
|
// 轮流返回请求地址
|
||||||
_requestCount++;
|
_requestCount++;
|
||||||
if (_requestCount % 2 == 0)
|
if (_requestCount % 2 == 0)
|
||||||
return Param.FallbackURL;
|
return Options.FallbackURL;
|
||||||
else
|
else
|
||||||
return Param.MainURL;
|
return Options.MainURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -87,7 +87,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
float offset = UnityEngine.Time.realtimeSinceStartup - _latestDownloadRealtime;
|
float offset = UnityEngine.Time.realtimeSinceStartup - _latestDownloadRealtime;
|
||||||
if (offset > Param.Timeout)
|
if (offset > Options.Timeout)
|
||||||
{
|
{
|
||||||
YooLogger.Warning($"Download request timeout : {_requestURL}");
|
YooLogger.Warning($"Download request timeout : {_requestURL}");
|
||||||
if (_webRequest != null)
|
if (_webRequest != null)
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal abstract class DownloadAssetBundleOperation : DefaultDownloadFileOperation
|
internal abstract class DownloadAssetBundleOperation : DefaultDownloadFileOperation
|
||||||
{
|
{
|
||||||
internal DownloadAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset
|
|||||||
private DownloadHandlerBuffer _downloadhandler;
|
private DownloadHandlerBuffer _downloadhandler;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadWebEncryptAssetBundleOperation(bool checkTimeout, IWebDecryptionServices decryptionServices, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_checkTimeout = checkTimeout;
|
_checkTimeout = checkTimeout;
|
||||||
_decryptionServices = decryptionServices;
|
_decryptionServices = decryptionServices;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset
|
|||||||
private DownloadHandlerAssetBundle _downloadhandler;
|
private DownloadHandlerAssetBundle _downloadhandler;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadWebNormalAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadWebNormalAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_disableUnityWebCache = disableUnityWebCache;
|
_disableUnityWebCache = disableUnityWebCache;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,10 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InitializeParameters
|
public abstract class InitializeParameters
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同时加载Bundle文件的最大并发数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace YooAsset
|
|||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
LoadFile,
|
CheckConcurrency,
|
||||||
|
LoadBundleFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,17 +58,32 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.LoadFile;
|
_steps = ESteps.CheckConcurrency;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (_steps == ESteps.LoadFile)
|
if (_steps == ESteps.CheckConcurrency)
|
||||||
|
{
|
||||||
|
if (IsWaitForAsyncComplete)
|
||||||
|
{
|
||||||
|
_steps = ESteps.LoadBundleFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_resourceManager.BundleLoadingIsBusy())
|
||||||
|
return;
|
||||||
|
_steps = ESteps.LoadBundleFile;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.LoadBundleFile)
|
||||||
{
|
{
|
||||||
if (_loadBundleOp == null)
|
if (_loadBundleOp == null)
|
||||||
{
|
{
|
||||||
|
_resourceManager.BundleLoadingCounter++;
|
||||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||||
_loadBundleOp.StartOperation();
|
_loadBundleOp.StartOperation();
|
||||||
AddChildOperation(_loadBundleOp);
|
AddChildOperation(_loadBundleOp);
|
||||||
@@ -103,6 +119,9 @@ namespace YooAsset
|
|||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = _loadBundleOp.Error;
|
Error = _loadBundleOp.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 统计计数减少
|
||||||
|
_resourceManager.BundleLoadingCounter--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void InternalWaitForAsyncComplete()
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
private readonly ResourceManager _resManager;
|
private readonly ResourceManager _resManager;
|
||||||
private readonly int _loopCount;
|
private readonly int _loopCount;
|
||||||
|
private int _loopCounter = 0;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
||||||
@@ -25,6 +26,7 @@ namespace YooAsset
|
|||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
_steps = ESteps.UnloadUnused;
|
_steps = ESteps.UnloadUnused;
|
||||||
|
_loopCounter = _loopCount;
|
||||||
}
|
}
|
||||||
internal override void InternalUpdate()
|
internal override void InternalUpdate()
|
||||||
{
|
{
|
||||||
@@ -33,13 +35,23 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.UnloadUnused)
|
if (_steps == ESteps.UnloadUnused)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _loopCount; i++)
|
while (_loopCounter > 0)
|
||||||
{
|
{
|
||||||
|
_loopCounter--;
|
||||||
LoopUnloadUnused();
|
LoopUnloadUnused();
|
||||||
|
|
||||||
|
if (IsWaitForAsyncComplete == false)
|
||||||
|
{
|
||||||
|
if (OperationSystem.IsBusy)
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_steps = ESteps.Done;
|
if (_loopCounter <= 0)
|
||||||
Status = EOperationStatus.Succeed;
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override void InternalWaitForAsyncComplete()
|
internal override void InternalWaitForAsyncComplete()
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ namespace YooAsset
|
|||||||
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
|
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
|
||||||
private long _sceneCreateIndex = 0;
|
private long _sceneCreateIndex = 0;
|
||||||
private IBundleQuery _bundleQuery;
|
private IBundleQuery _bundleQuery;
|
||||||
|
private int _bundleLoadingMaxConcurrency;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 所属包裹
|
/// 所属包裹
|
||||||
@@ -25,6 +26,11 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool LockLoadOperation = false;
|
public bool LockLoadOperation = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 统计正在加载的Bundle文件数量
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingCounter = 0;
|
||||||
|
|
||||||
|
|
||||||
public ResourceManager(string packageName)
|
public ResourceManager(string packageName)
|
||||||
{
|
{
|
||||||
@@ -34,8 +40,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化
|
/// 初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(IBundleQuery bundleServices)
|
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||||
{
|
{
|
||||||
|
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||||
_bundleQuery = bundleServices;
|
_bundleQuery = bundleServices;
|
||||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||||
}
|
}
|
||||||
@@ -310,6 +317,10 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
return LoaderDic.Count > 0;
|
return LoaderDic.Count > 0;
|
||||||
}
|
}
|
||||||
|
internal bool BundleLoadingIsBusy()
|
||||||
|
{
|
||||||
|
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
|
||||||
|
}
|
||||||
|
|
||||||
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
|
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(failedTryAgain, timeout);
|
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout);
|
||||||
downloadParam.ImportFilePath = _importFilePath;
|
options.ImportFilePath = _importFilePath;
|
||||||
return _fileSystem.DownloadFileAsync(Bundle, downloadParam);
|
return _fileSystem.DownloadFileAsync(Bundle, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 补丁包内的文件样式
|
|
||||||
/// </summary>
|
|
||||||
public enum EFileNameStyle
|
public enum EFileNameStyle
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 84c5eff5dedf53343897e83f6b10eea6
|
guid: 5e81f00e510f07947873055518f5d1c6
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -31,8 +31,8 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam);
|
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||||
|
|||||||
@@ -8,6 +8,30 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
internal static class ManifestTools
|
internal static class ManifestTools
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 验证清单文件的二进制数据
|
||||||
|
/// </summary>
|
||||||
|
public static bool VerifyManifestData(byte[] fileData, string hashValue)
|
||||||
|
{
|
||||||
|
if (fileData == null || fileData.Length == 0)
|
||||||
|
return false;
|
||||||
|
if (string.IsNullOrEmpty(hashValue))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// 注意:兼容俩种验证方式
|
||||||
|
// 注意:计算MD5的哈希值通常为32个字符
|
||||||
|
string fileHash;
|
||||||
|
if (hashValue.Length == 32)
|
||||||
|
fileHash = HashUtility.BytesMD5(fileData);
|
||||||
|
else
|
||||||
|
fileHash = HashUtility.BytesCRC32(fileData);
|
||||||
|
|
||||||
|
if (fileHash == hashValue)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 序列化(JSON文件)
|
/// 序列化(JSON文件)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -197,9 +221,16 @@ namespace YooAsset
|
|||||||
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
|
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
|
||||||
|
|
||||||
if (manifest.EnableAddressable)
|
if (manifest.EnableAddressable)
|
||||||
|
{
|
||||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
|
{
|
||||||
|
if (manifest.LocationToLower)
|
||||||
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2, StringComparer.OrdinalIgnoreCase);
|
||||||
|
else
|
||||||
|
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
|
||||||
|
}
|
||||||
|
|
||||||
if (manifest.IncludeAssetGUID)
|
if (manifest.IncludeAssetGUID)
|
||||||
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
|
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
|
||||||
@@ -221,8 +252,6 @@ namespace YooAsset
|
|||||||
// 填充AssetPathMapping1
|
// 填充AssetPathMapping1
|
||||||
{
|
{
|
||||||
string location = packageAsset.AssetPath;
|
string location = packageAsset.AssetPath;
|
||||||
if (manifest.LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
// 添加原生路径的映射
|
// 添加原生路径的映射
|
||||||
if (manifest.AssetPathMapping1.ContainsKey(location))
|
if (manifest.AssetPathMapping1.ContainsKey(location))
|
||||||
@@ -285,27 +314,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 注意:该类拷贝自编辑器
|
|
||||||
/// </summary>
|
|
||||||
private enum EFileNameStyle
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 哈希值名称
|
|
||||||
/// </summary>
|
|
||||||
HashName = 0,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名称(不推荐)
|
|
||||||
/// </summary>
|
|
||||||
BundleName = 1,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包名称 + 哈希值名称
|
|
||||||
/// </summary>
|
|
||||||
BundleName_HashName = 2,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源文件的后缀名
|
/// 获取资源文件的后缀名
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -15,17 +15,15 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly PlayModeImpl _impl;
|
private readonly PlayModeImpl _impl;
|
||||||
private readonly string _clearMode;
|
private readonly ClearCacheFilesOptions _options;
|
||||||
private readonly object _clearParam;
|
|
||||||
private List<IFileSystem> _cloneList;
|
private List<IFileSystem> _cloneList;
|
||||||
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal ClearCacheFilesOperation(PlayModeImpl impl, string clearMode, object clearParam)
|
internal ClearCacheFilesOperation(PlayModeImpl impl, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_clearMode = clearMode;
|
_options = options;
|
||||||
_clearParam = clearParam;
|
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
@@ -74,7 +72,7 @@ namespace YooAsset
|
|||||||
var fileSystem = _cloneList[0];
|
var fileSystem = _cloneList[0];
|
||||||
_cloneList.RemoveAt(0);
|
_cloneList.RemoveAt(0);
|
||||||
|
|
||||||
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _options);
|
||||||
_clearCacheFilesOp.StartOperation();
|
_clearCacheFilesOp.StartOperation();
|
||||||
AddChildOperation(_clearCacheFilesOp);
|
AddChildOperation(_clearCacheFilesOp);
|
||||||
_steps = ESteps.CheckClearResult;
|
_steps = ESteps.CheckClearResult;
|
||||||
@@ -102,7 +100,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override string InternalGetDesc()
|
internal override string InternalGetDesc()
|
||||||
{
|
{
|
||||||
return $"ClearMode : {_clearMode}";
|
return $"ClearMode : {_options.ClearMode}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,9 +138,6 @@ namespace YooAsset
|
|||||||
if (string.IsNullOrEmpty(location))
|
if (string.IsNullOrEmpty(location))
|
||||||
return string.Empty;
|
return string.Empty;
|
||||||
|
|
||||||
if (LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
return assetPath;
|
return assetPath;
|
||||||
else
|
else
|
||||||
@@ -307,9 +304,6 @@ namespace YooAsset
|
|||||||
return string.Empty;
|
return string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LocationToLower)
|
|
||||||
location = location.ToLower();
|
|
||||||
|
|
||||||
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
if (AssetPathMapping1.TryGetValue(location, out string assetPath))
|
||||||
{
|
{
|
||||||
return assetPath;
|
return assetPath;
|
||||||
|
|||||||
@@ -97,9 +97,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new ClearCacheFilesOperation(this, clearMode, clearParam);
|
var operation = new ClearCacheFilesOperation(this, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
|||||||
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
|
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
|
||||||
_bundleQuery = playModeImpl;
|
_bundleQuery = playModeImpl;
|
||||||
_playModeImpl = playModeImpl;
|
_playModeImpl = playModeImpl;
|
||||||
_resourceManager.Initialize(_bundleQuery);
|
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||||
|
|
||||||
// 初始化资源系统
|
// 初始化资源系统
|
||||||
InitializationOperation initializeOperation;
|
InitializationOperation initializeOperation;
|
||||||
@@ -162,6 +162,10 @@ namespace YooAsset
|
|||||||
throw new Exception($"Editor simulate mode only support unity editor.");
|
throw new Exception($"Editor simulate mode only support unity editor.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// 检测初始化参数
|
||||||
|
if (parameters.BundleLoadingMaxConcurrency <= 0)
|
||||||
|
throw new Exception($"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
|
||||||
|
|
||||||
// 鉴定运行模式
|
// 鉴定运行模式
|
||||||
if (parameters is EditorSimulateModeParameters)
|
if (parameters is EditorSimulateModeParameters)
|
||||||
_playMode = EPlayMode.EditorSimulateMode;
|
_playMode = EPlayMode.EditorSimulateMode;
|
||||||
@@ -264,7 +268,10 @@ namespace YooAsset
|
|||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode.ToString(), clearParam);
|
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
||||||
|
options.ClearMode = clearMode.ToString();
|
||||||
|
options.ClearParam = clearParam;
|
||||||
|
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -277,7 +284,10 @@ namespace YooAsset
|
|||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(clearMode, clearParam);
|
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
||||||
|
options.ClearMode = clearMode;
|
||||||
|
options.ClearParam = clearParam;
|
||||||
|
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ internal class TTFSDownloadFileOperation : DefaultDownloadFileOperation
|
|||||||
private TiktokFileSystem _fileSystem;
|
private TiktokFileSystem _fileSystem;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal TTFSDownloadFileOperation(TiktokFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal TTFSDownloadFileOperation(TiktokFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,19 +35,19 @@ internal class TTFSLoadBundleOperation : FSLoadBundleOperation
|
|||||||
{
|
{
|
||||||
if (_downloadAssetBundleOp == null)
|
if (_downloadAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
|
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
|
||||||
downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
|
|
||||||
if (_bundle.Encrypted)
|
if (_bundle.Encrypted)
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadTiktokAssetBundleOperation(_bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadTiktokAssetBundleOperation(_bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadTiktokAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadTiktokAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
|
|||||||
@@ -124,16 +124,16 @@ internal class TiktokFileSystem : IFileSystem
|
|||||||
var operation = new TTFSRequestPackageVersionOperation(this, timeout);
|
var operation = new TTFSRequestPackageVersionOperation(this, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
param.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
options.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||||
param.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
options.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||||
var operation = new TTFSDownloadFileOperation(this, bundle, param);
|
var operation = new TTFSDownloadFileOperation(this, bundle, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ internal class WXFSDownloadFileOperation : DefaultDownloadFileOperation
|
|||||||
private WechatFileSystem _fileSystem;
|
private WechatFileSystem _fileSystem;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal WXFSDownloadFileOperation(WechatFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal WXFSDownloadFileOperation(WechatFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
_fileSystem = fileSystem;
|
_fileSystem = fileSystem;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,19 +33,19 @@ internal class WXFSLoadBundleOperation : FSLoadBundleOperation
|
|||||||
{
|
{
|
||||||
if (_downloadAssetBundleOp == null)
|
if (_downloadAssetBundleOp == null)
|
||||||
{
|
{
|
||||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60);
|
||||||
downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
|
options.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); ;
|
||||||
downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
options.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||||
|
|
||||||
if (_bundle.Encrypted)
|
if (_bundle.Encrypted)
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWebEncryptAssetBundleOperation(false, _fileSystem.DecryptionServices, _bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_downloadAssetBundleOp = new DownloadWechatAssetBundleOperation(_bundle, downloadParam);
|
_downloadAssetBundleOp = new DownloadWechatAssetBundleOperation(_bundle, options);
|
||||||
_downloadAssetBundleOp.StartOperation();
|
_downloadAssetBundleOp.StartOperation();
|
||||||
AddChildOperation(_downloadAssetBundleOp);
|
AddChildOperation(_downloadAssetBundleOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal DownloadWechatAssetBundleOperation(PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
internal DownloadWechatAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options) : base(bundle, options)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
|
|||||||
@@ -125,30 +125,30 @@ internal class WechatFileSystem : IFileSystem
|
|||||||
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new WXFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, string clearMode, object clearParam)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
if (clearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new WXFSClearAllBundleFilesOperation(this);
|
var operation = new WXFSClearAllBundleFilesOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else if (clearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||||
{
|
{
|
||||||
var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest);
|
var operation = new WXFSClearUnusedBundleFilesAsync(this, manifest);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
string error = $"Invalid clear mode : {clearMode}";
|
string error = $"Invalid clear mode : {options.ClearMode}";
|
||||||
var operation = new FSClearCacheFilesCompleteOperation(error);
|
var operation = new FSClearCacheFilesCompleteOperation(error);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||||
{
|
{
|
||||||
param.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
options.MainURL = RemoteServices.GetRemoteMainURL(bundle.FileName);
|
||||||
param.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
options.FallbackURL = RemoteServices.GetRemoteFallbackURL(bundle.FileName);
|
||||||
var operation = new WXFSDownloadFileOperation(this, bundle, param);
|
var operation = new WXFSDownloadFileOperation(this, bundle, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ public class PatchWindow : MonoBehaviour
|
|||||||
{
|
{
|
||||||
UserEventDefine.UserTryRequestPackageVersion.SendEventMessage();
|
UserEventDefine.UserTryRequestPackageVersion.SendEventMessage();
|
||||||
};
|
};
|
||||||
ShowMessageBox($"Failed to update static version, please check the network status.", callback);
|
ShowMessageBox($"Failed to request package version, please check the network status.", callback);
|
||||||
}
|
}
|
||||||
else if (message is PatchEventDefine.PackageManifestUpdateFailed)
|
else if (message is PatchEventDefine.PackageManifestUpdateFailed)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public static class TestPackageBuilder
|
|||||||
buildParameters.ClearBuildCacheFiles = true;
|
buildParameters.ClearBuildCacheFiles = true;
|
||||||
buildParameters.UseAssetDependencyDB = true;
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||||
|
|
||||||
var pipeline = new ScriptableBuildPipeline();
|
var pipeline = new ScriptableBuildPipeline();
|
||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
@@ -108,7 +108,7 @@ public static class TestPackageBuilder
|
|||||||
buildParameters.CompressOption = ECompressOption.LZ4;
|
buildParameters.CompressOption = ECompressOption.LZ4;
|
||||||
buildParameters.ClearBuildCacheFiles = true;
|
buildParameters.ClearBuildCacheFiles = true;
|
||||||
buildParameters.UseAssetDependencyDB = true;
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
buildParameters.EncryptionServices = new FileStreamEncryption();
|
buildParameters.EncryptionServices = new FileStreamTestEncryption();
|
||||||
|
|
||||||
var pipeline = new BuiltinBuildPipeline();
|
var pipeline = new BuiltinBuildPipeline();
|
||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new OfflinePlayModeParameters();
|
var initParams = new OfflinePlayModeParameters();
|
||||||
var decryption = new FileStreamDecryption();
|
var decryption = new FileStreamTestDecryption();
|
||||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(decryption, packageRoot);
|
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(decryption, packageRoot);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializeAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class TestBundleEncryption
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件流加密方式
|
/// 文件流加密方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileStreamEncryption : IEncryptionServices
|
public class FileStreamTestEncryption : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
@@ -64,7 +64,7 @@ public class FileStreamEncryption : IEncryptionServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件偏移加密方式
|
/// 文件偏移加密方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileOffsetEncryption : IEncryptionServices
|
public class FileOffsetTestEncryption : IEncryptionServices
|
||||||
{
|
{
|
||||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
@@ -119,7 +119,7 @@ public class BundleStream : FileStream
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件流解密类
|
/// 资源文件流解密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileStreamDecryption : IDecryptionServices
|
public class FileStreamTestDecryption : IDecryptionServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步方式获取解密的资源包对象
|
/// 同步方式获取解密的资源包对象
|
||||||
@@ -172,7 +172,7 @@ public class FileStreamDecryption : IDecryptionServices
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源文件偏移解密类
|
/// 资源文件偏移解密类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class FileOffsetDecryption : IDecryptionServices
|
public class FileOffsetTestDecryption : IDecryptionServices
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同步方式获取解密的资源包对象
|
/// 同步方式获取解密的资源包对象
|
||||||
@@ -224,7 +224,7 @@ public class FileOffsetDecryption : IDecryptionServices
|
|||||||
/// WebGL平台解密类
|
/// WebGL平台解密类
|
||||||
/// 注意:WebGL平台支持内存解密
|
/// 注意:WebGL平台支持内存解密
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WebFileStreamDecryption : IWebDecryptionServices
|
public class WebFileStreamTestDecryption : IWebDecryptionServices
|
||||||
{
|
{
|
||||||
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
|
public WebDecryptResult LoadAssetBundle(WebDecryptFileInfo fileInfo)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "com.tuyoogame.yooasset",
|
"name": "com.tuyoogame.yooasset",
|
||||||
"displayName": "YooAsset",
|
"displayName": "YooAsset",
|
||||||
"version": "2.3.6",
|
"version": "2.3.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