mirror of https://github.com/tuyoogame/YooAsset
parent
644e6655ff
commit
e7907eeaa7
|
@ -77,7 +77,7 @@ namespace YooAsset
|
||||||
/// 自定义参数:拷贝内置清单的目标目录
|
/// 自定义参数:拷贝内置清单的目标目录
|
||||||
/// 注意:该参数为空的时候,会获取默认的沙盒目录!
|
/// 注意:该参数为空的时候,会获取默认的沙盒目录!
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string CopyBuildinPackageManifestDestPath { private set; get; }
|
public string CopyBuildinPackageManifestDestRoot { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义参数:解密方法类
|
/// 自定义参数:解密方法类
|
||||||
|
@ -160,8 +160,11 @@ namespace YooAsset
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST)
|
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST)
|
||||||
{
|
{
|
||||||
CopyBuildinPackageManifest = true;
|
CopyBuildinPackageManifest = (bool)value;
|
||||||
CopyBuildinPackageManifestDestPath = (string)value;
|
}
|
||||||
|
else if (name == FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT)
|
||||||
|
{
|
||||||
|
CopyBuildinPackageManifestDestRoot = (string)value;
|
||||||
}
|
}
|
||||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,12 +8,14 @@ namespace YooAsset
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
|
CopyBuildinManifest,
|
||||||
InitUnpackFileSystem,
|
InitUnpackFileSystem,
|
||||||
LoadCatalogFile,
|
LoadCatalogFile,
|
||||||
Done,
|
Done,
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
|
private CopyBuildinPackageManifestOperation _copyBuildinPackageManifestOp;
|
||||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
||||||
private LoadBuildinCatalogFileOperation _loadCatalogFileOp;
|
private LoadBuildinCatalogFileOperation _loadCatalogFileOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
@ -29,7 +31,10 @@ namespace YooAsset
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
Error = $"{nameof(DefaultBuildinFileSystem)} is not support WEBGL platform !";
|
||||||
#else
|
#else
|
||||||
_steps = ESteps.InitUnpackFileSystem;
|
if (_fileSystem.CopyBuildinPackageManifest)
|
||||||
|
_steps = ESteps.CopyBuildinManifest;
|
||||||
|
else
|
||||||
|
_steps = ESteps.InitUnpackFileSystem;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
internal override void InternalOnUpdate()
|
internal override void InternalOnUpdate()
|
||||||
|
@ -37,6 +42,29 @@ namespace YooAsset
|
||||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.CopyBuildinManifest)
|
||||||
|
{
|
||||||
|
if (_copyBuildinPackageManifestOp == null)
|
||||||
|
{
|
||||||
|
_copyBuildinPackageManifestOp = new CopyBuildinPackageManifestOperation(_fileSystem);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _copyBuildinPackageManifestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_copyBuildinPackageManifestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_copyBuildinPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.InitUnpackFileSystem;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _copyBuildinPackageManifestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (_steps == ESteps.InitUnpackFileSystem)
|
if (_steps == ESteps.InitUnpackFileSystem)
|
||||||
{
|
{
|
||||||
if (_initUnpackFIleSystemOp == null)
|
if (_initUnpackFIleSystemOp == null)
|
||||||
|
|
|
@ -0,0 +1,167 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
internal class CopyBuildinPackageManifestOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
RequestPackageVersion,
|
||||||
|
CheckHashFile,
|
||||||
|
UnpackHashFile,
|
||||||
|
CheckManifestFile,
|
||||||
|
UnpackManifestFile,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||||
|
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||||
|
private UnityWebFileRequestOperation _hashFileRequestOp;
|
||||||
|
private UnityWebFileRequestOperation _manifestFileRequestOp;
|
||||||
|
private string _buildinPackageVersion;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
public CopyBuildinPackageManifestOperation(DefaultBuildinFileSystem fileSystem)
|
||||||
|
{
|
||||||
|
_fileSystem = fileSystem;
|
||||||
|
}
|
||||||
|
internal override void InternalOnStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.RequestPackageVersion;
|
||||||
|
}
|
||||||
|
internal override void InternalOnUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.RequestPackageVersion)
|
||||||
|
{
|
||||||
|
if (_requestBuildinPackageVersionOp == null)
|
||||||
|
{
|
||||||
|
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckHashFile;
|
||||||
|
_buildinPackageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _requestBuildinPackageVersionOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckHashFile)
|
||||||
|
{
|
||||||
|
string hashFilePath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
||||||
|
if (File.Exists(hashFilePath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckManifestFile;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.UnpackHashFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UnpackHashFile)
|
||||||
|
{
|
||||||
|
if (_hashFileRequestOp == null)
|
||||||
|
{
|
||||||
|
string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion);
|
||||||
|
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
||||||
|
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||||
|
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _hashFileRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_hashFileRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_hashFileRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.CheckManifestFile;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _hashFileRequestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckManifestFile)
|
||||||
|
{
|
||||||
|
string manifestFilePath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
||||||
|
if (File.Exists(manifestFilePath))
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.UnpackManifestFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.UnpackManifestFile)
|
||||||
|
{
|
||||||
|
if (_manifestFileRequestOp == null)
|
||||||
|
{
|
||||||
|
string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
|
||||||
|
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
||||||
|
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||||
|
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||||
|
OperationSystem.StartOperation(_fileSystem.PackageName, _manifestFileRequestOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_manifestFileRequestOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_manifestFileRequestOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _manifestFileRequestOp.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetCopyManifestFileRoot()
|
||||||
|
{
|
||||||
|
string destRoot = _fileSystem.CopyBuildinPackageManifestDestRoot;
|
||||||
|
if (string.IsNullOrEmpty(destRoot))
|
||||||
|
{
|
||||||
|
string defaultCacheRoot = YooAssetSettingsData.GetYooDefaultCacheRoot();
|
||||||
|
destRoot = PathUtility.Combine(defaultCacheRoot, _fileSystem.PackageName, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||||
|
}
|
||||||
|
return destRoot;
|
||||||
|
}
|
||||||
|
private string GetCopyPackageHashDestPath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileRoot = GetCopyManifestFileRoot();
|
||||||
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(fileRoot, fileName);
|
||||||
|
}
|
||||||
|
private string GetCopyPackageManifestDestPath(string packageVersion)
|
||||||
|
{
|
||||||
|
string fileRoot = GetCopyManifestFileRoot();
|
||||||
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, packageVersion);
|
||||||
|
return PathUtility.Combine(fileRoot, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 69f62f6b4185d06498f96aa272e9b926
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -16,5 +16,6 @@ namespace YooAsset
|
||||||
public const string ASYNC_SIMULATE_MIN_FRAME = "ASYNC_SIMULATE_MIN_FRAME";
|
public const string ASYNC_SIMULATE_MIN_FRAME = "ASYNC_SIMULATE_MIN_FRAME";
|
||||||
public const string ASYNC_SIMULATE_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME";
|
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 = "COPY_BUILDIN_PACKAGE_MANIFEST";
|
||||||
|
public const string COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT = "COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT";
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue