mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-17 21:30:13 +00:00
fix #585
This commit is contained in:
@@ -93,6 +93,11 @@ namespace YooAsset
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestServices ManifestServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件服务类
|
||||
/// </summary>
|
||||
public ICopyBuildinBundleServices CopyBuildinBundleServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -183,6 +188,10 @@ namespace YooAsset
|
||||
{
|
||||
ManifestServices = (IManifestServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_BUNDLE_SERVICES)
|
||||
{
|
||||
CopyBuildinBundleServices = (ICopyBuildinBundleServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
@@ -205,6 +214,7 @@ namespace YooAsset
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.INSTALL_CLEAR_MODE, InstallClearMode);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_BUILDIN_BUNDLE_SERVICES, CopyBuildinBundleServices);
|
||||
_unpackFileSystem.OnCreate(packageName, null);
|
||||
}
|
||||
public virtual void OnDestroy()
|
||||
|
||||
@@ -104,6 +104,11 @@ namespace YooAsset
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestServices ManifestServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件服务类
|
||||
/// </summary>
|
||||
public ICopyBuildinBundleServices CopyBuildinBundleServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -230,6 +235,10 @@ namespace YooAsset
|
||||
{
|
||||
ManifestServices = (IManifestServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_BUNDLE_SERVICES)
|
||||
{
|
||||
CopyBuildinBundleServices = (ICopyBuildinBundleServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
|
||||
@@ -37,7 +37,10 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
if (_isReuqestLocalFile && _fileSystem.CopyBuildinBundleServices != null)
|
||||
_steps = ESteps.CopyBuildinBundle;
|
||||
else
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +87,42 @@ namespace YooAsset
|
||||
DisposeWebRequest();
|
||||
}
|
||||
|
||||
// 拷贝内置文件
|
||||
if (_steps == ESteps.CopyBuildinBundle)
|
||||
{
|
||||
FileUtility.CreateFileDirectory(_tempFilePath);
|
||||
|
||||
// 删除临时文件
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
|
||||
// 获取请求地址
|
||||
_requestURL = GetRequestURL();
|
||||
|
||||
try
|
||||
{
|
||||
//TODO 团结引擎,在某些机型(红米),拷贝包内文件会小概率失败!需要借助其它方式来拷贝包内文件。
|
||||
_fileSystem.CopyBuildinBundleServices.CopyBuildinFile(_requestURL, _tempFilePath);
|
||||
if (File.Exists(_tempFilePath))
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = Bundle.FileSize;
|
||||
Progress = DownloadProgress;
|
||||
_steps = ESteps.VerifyTempFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = $"Failed copy buildin bundle : {_requestURL}";
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Error = $"Failed copy buildin bundle : {ex.Message}";
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
}
|
||||
|
||||
// 验证下载文件
|
||||
if (_steps == ESteps.VerifyTempFile)
|
||||
{
|
||||
|
||||
@@ -40,7 +40,10 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
if (_isReuqestLocalFile && _fileSystem.CopyBuildinBundleServices != null)
|
||||
_steps = ESteps.CopyBuildinBundle;
|
||||
else
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,6 +107,42 @@ namespace YooAsset
|
||||
DisposeWebRequest();
|
||||
}
|
||||
|
||||
// 拷贝内置文件
|
||||
if (_steps == ESteps.CopyBuildinBundle)
|
||||
{
|
||||
FileUtility.CreateFileDirectory(_tempFilePath);
|
||||
|
||||
// 删除临时文件(不支持断点续传)
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
|
||||
// 获取请求地址
|
||||
_requestURL = GetRequestURL();
|
||||
|
||||
try
|
||||
{
|
||||
//TODO 团结引擎,在某些机型(红米),拷贝包内文件会小概率失败!需要借助其它方式来拷贝包内文件。
|
||||
_fileSystem.CopyBuildinBundleServices.CopyBuildinFile(_requestURL, _tempFilePath);
|
||||
if (File.Exists(_tempFilePath))
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = Bundle.FileSize;
|
||||
Progress = DownloadProgress;
|
||||
_steps = ESteps.VerifyTempFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
Error = $"Failed copy buildin bundle : {_requestURL}";
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Error = $"Failed copy buildin bundle : {ex.Message}";
|
||||
_steps = ESteps.TryAgain;
|
||||
}
|
||||
}
|
||||
|
||||
// 验证下载文件
|
||||
if (_steps == ESteps.VerifyTempFile)
|
||||
{
|
||||
|
||||
@@ -19,5 +19,6 @@ namespace YooAsset
|
||||
public const string ASYNC_SIMULATE_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME";
|
||||
public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST";
|
||||
public const string COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT = "COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT";
|
||||
public const string COPY_BUILDIN_BUNDLE_SERVICES = "COPY_BUILDIN_BUNDLE_SERVICES";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 拷贝内置文件服务类
|
||||
/// </summary>
|
||||
public interface ICopyBuildinBundleServices
|
||||
{
|
||||
void CopyBuildinFile(string buildinFileURL, string destFilePath);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e2eb3bd510fd41c48a01dcc26dd9b985
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,6 +11,7 @@ namespace YooAsset
|
||||
CheckExists,
|
||||
CreateRequest,
|
||||
CheckRequest,
|
||||
CopyBuildinBundle,
|
||||
VerifyTempFile,
|
||||
CheckVerifyTempFile,
|
||||
TryAgain,
|
||||
|
||||
Reference in New Issue
Block a user