mirror of https://github.com/tuyoogame/YooAsset
update file system
parent
db8d09d0d6
commit
75511397d6
|
@ -8,8 +8,11 @@ namespace YooAsset.Editor
|
|||
/// <summary>
|
||||
/// 模拟构建
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||
public static SimulateBuildResult SimulateBuild(string buildPipelineName, string packageName)
|
||||
{
|
||||
string packageVersion = "Simulate";
|
||||
BuildResult buildResult;
|
||||
|
||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
||||
{
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
|
@ -19,23 +22,13 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.PackageVersion = packageVersion;
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, false);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
buildResult = pipeline.Run(buildParameters, false);
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
||||
{
|
||||
|
@ -46,23 +39,13 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.PackageVersion = packageVersion;
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
buildResult = pipeline.Run(buildParameters, true);
|
||||
}
|
||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
||||
{
|
||||
|
@ -73,28 +56,35 @@ namespace YooAsset.Editor
|
|||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
buildParameters.PackageVersion = packageVersion;
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
return manifestFilePath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
buildResult = pipeline.Run(buildParameters, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(buildPipelineName);
|
||||
}
|
||||
|
||||
// 返回结果
|
||||
if (buildResult.Success)
|
||||
{
|
||||
SimulateBuildResult reulst = new SimulateBuildResult();
|
||||
string versionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
|
||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
|
||||
string hashFileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
|
||||
reulst.PackageVersionFilePath = $"{buildResult.OutputPackageDirectory}/{versionFileName}";
|
||||
reulst.PackageManifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
||||
reulst.PackageHashFilePath = $"{buildResult.OutputPackageDirectory}/{hashFileName}";
|
||||
return reulst;
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -25,12 +25,9 @@ namespace YooAsset
|
|||
protected readonly Dictionary<string, string> _buildinFilePaths = new Dictionary<string, string>(10000);
|
||||
protected string _packageRoot;
|
||||
|
||||
/// <summary>
|
||||
/// 解压文件系统
|
||||
/// </summary>
|
||||
// 解压文件系统
|
||||
public IFileSystem UnpackFileSystem { private set; get; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
|
@ -110,27 +107,24 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(params object[] args)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var operation = new DBFSRequestPackageVersionOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync(params object[] args)
|
||||
{
|
||||
var operation = new DBFSClearAllBundleFilesOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
return UnpackFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(params object[] args)
|
||||
{
|
||||
PackageManifest manifest = args[0] as PackageManifest;
|
||||
var operation = new DBFSClearUnusedBundleFilesOperation(this, manifest);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
return UnpackFileSystem.ClearUnusedBundleFilesAsync(manifest);
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(params object[] args)
|
||||
{
|
||||
PackageBundle bundle = args[0] as PackageBundle;
|
||||
int failedTryAgain = (int)args[2];
|
||||
int timeout = (int)args[3];
|
||||
|
||||
string buidlinFilePath = GetBuildinFileLoadPath(bundle);
|
||||
return UnpackFileSystem.DownloadFileAsync(bundle, buidlinFilePath, failedTryAgain, timeout);
|
||||
}
|
||||
|
@ -176,7 +170,7 @@ namespace YooAsset
|
|||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
return Belong(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Belong(string bundleGUID)
|
||||
{
|
||||
|
@ -184,7 +178,7 @@ namespace YooAsset
|
|||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundle.BundleGUID);
|
||||
return Exists(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Exists(string bundleGUID)
|
||||
{
|
||||
|
@ -199,7 +193,7 @@ namespace YooAsset
|
|||
{
|
||||
if (Belong(bundle) == false)
|
||||
return false;
|
||||
|
||||
|
||||
#if UNITY_ANDROID
|
||||
return RawFileBuildPipeline || bundle.Encrypted;
|
||||
#else
|
||||
|
@ -230,11 +224,11 @@ namespace YooAsset
|
|||
|
||||
public virtual byte[] ReadFileBytes(PackageBundle bundle)
|
||||
{
|
||||
return UnpackFileSystem.ReadFileBytes(bundle);
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public virtual string ReadFileText(PackageBundle bundle)
|
||||
{
|
||||
return UnpackFileSystem.ReadFileText(bundle);
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
|
|
|
@ -1,45 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DBFSClearAllBundleFilesOperation : FSClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearUnpackFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private FSClearAllBundleFilesOperation _unpackClearAllBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DBFSClearAllBundleFilesOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnpackFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearUnpackFileSystem)
|
||||
{
|
||||
if (_unpackClearAllBundleFilesOp == null)
|
||||
_unpackClearAllBundleFilesOp = _fileSystem.UnpackFileSystem.ClearAllBundleFilesAsync();
|
||||
|
||||
Progress = _unpackClearAllBundleFilesOp.Progress;
|
||||
if (_unpackClearAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = _unpackClearAllBundleFilesOp.Status;
|
||||
Error = _unpackClearAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DBFSClearUnusedBundleFilesOperation : FSClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearUnpackFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly PackageManifest _manifest;
|
||||
private FSClearUnusedBundleFilesOperation _unpackClearUnusedBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DBFSClearUnusedBundleFilesOperation(DefaultBuildinFileSystem fileSystem, PackageManifest manifest)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_manifest = manifest;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnpackFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearUnpackFileSystem)
|
||||
{
|
||||
if (_unpackClearUnusedBundleFilesOp == null)
|
||||
_unpackClearUnusedBundleFilesOp = _fileSystem.UnpackFileSystem.ClearUnusedBundleFilesAsync(_manifest);
|
||||
|
||||
Progress = _unpackClearUnusedBundleFilesOp.Progress;
|
||||
if (_unpackClearUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
_steps = ESteps.Done;
|
||||
Status = _unpackClearUnusedBundleFilesOp.Status;
|
||||
Error = _unpackClearUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e0e1c080b28b3c45b401da4ac06f687
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DBFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DBFSRequestPackageVersionOperation(DefaultBuildinFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.GetPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.GetPackageVersion)
|
||||
{
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
_requestBuildinPackageVersionOp = new RequestBuildinPackageVersionOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestBuildinPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_requestBuildinPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestBuildinPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _requestBuildinPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestBuildinPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a16dae8497d54984daa95a3682a7beb4
|
||||
guid: f0b6ec24639af3741847a6a7ef09986a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -40,7 +40,6 @@ namespace YooAsset
|
|||
protected string _tempFileRoot;
|
||||
protected string _manifestFileRoot;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
|
@ -270,17 +269,16 @@ namespace YooAsset
|
|||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
{
|
||||
// 注意:缓存文件系统保底加载!
|
||||
return true;
|
||||
return Belong(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Belong(string bundleGUID)
|
||||
{
|
||||
// 注意:缓存文件系统保底加载!
|
||||
return true;
|
||||
}
|
||||
public virtual bool Exists(PackageBundle packageBundle)
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return _wrappers.ContainsKey(packageBundle.BundleGUID);
|
||||
return Exists(bundle.BundleGUID);
|
||||
}
|
||||
public virtual bool Exists(string bundleGUID)
|
||||
{
|
||||
|
|
|
@ -19,23 +19,27 @@ namespace YooAsset
|
|||
internal override void InternalOnStart()
|
||||
{
|
||||
_fileSavePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
|
||||
// 注意:检测文件是否存在
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
// 检测文件是否存在
|
||||
if (_steps == ESteps.CheckExists)
|
||||
{
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
|
@ -214,23 +218,27 @@ namespace YooAsset
|
|||
internal override void InternalOnStart()
|
||||
{
|
||||
_fileSavePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
|
||||
// 注意:检测文件是否存在
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
// 检测文件是否存在
|
||||
if (_steps == ESteps.CheckExists)
|
||||
{
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
|
|
|
@ -12,7 +12,6 @@ namespace YooAsset
|
|||
{
|
||||
protected string _packageRoot;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
|
@ -53,9 +52,9 @@ namespace YooAsset
|
|||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 自定义参数:模拟运行的资源清单文件路径
|
||||
/// 自定义参数:模拟构建结果
|
||||
/// </summary>
|
||||
public string SimulateManifestFilePath { private set; get; } = string.Empty;
|
||||
public SimulateBuildResult BuildResult { private set; get; } = null;
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -76,33 +75,32 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(params object[] args)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
var operation = new DEFSRequestPackageVersionOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync(params object[] args)
|
||||
{
|
||||
var operation = new DEFSClearAllBundleFilesOperation(this);
|
||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(params object[] args)
|
||||
{
|
||||
var operation = new DEFSClearUnusedBundleFilesOperation(this);
|
||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(params object[] args)
|
||||
{
|
||||
PackageBundle bundle = args[0] as PackageBundle;
|
||||
var operation = new DEFSDownloadFileOperation(bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == "SIMULATE_MANIFEST_FILE_PATH")
|
||||
if (name == "SIMULATE_BUILD_RESULT")
|
||||
{
|
||||
SimulateManifestFilePath = (string)value;
|
||||
BuildResult = (SimulateBuildResult)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DEFSClearAllBundleFilesOperation : FSClearAllBundleFilesOperation
|
||||
{
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
|
||||
internal DEFSClearAllBundleFilesOperation(DefaultEditorFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DEFSClearUnusedBundleFilesOperation : FSClearUnusedBundleFilesOperation
|
||||
{
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
|
||||
internal DEFSClearUnusedBundleFilesOperation(DefaultEditorFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DEFSDownloadFileOperation : FSDownloadFileOperation
|
||||
{
|
||||
internal DEFSDownloadFileOperation(PackageBundle bundle) : base(bundle)
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 06a8abe71cf3fe64180ec076a79b4b66
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,57 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DEFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
private LoadEditorPackageVersionOperation _loadEditorPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DEFSRequestPackageVersionOperation(DefaultEditorFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.GetPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.GetPackageVersion)
|
||||
{
|
||||
if (_loadEditorPackageVersionOp == null)
|
||||
{
|
||||
_loadEditorPackageVersionOp = new LoadEditorPackageVersionOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadEditorPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_loadEditorPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadEditorPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _loadEditorPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadEditorPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 624ca0ff2f0c7da4bb9c1a1d58e732b1
|
||||
guid: 47293048f9cde3f46a1b297f1c2e3373
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -38,7 +38,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.LoadFileData)
|
||||
{
|
||||
string manifestFilePath = _fileSystem.SimulateManifestFilePath;
|
||||
string manifestFilePath = _fileSystem.BuildResult.PackageManifestFilePath;
|
||||
if (File.Exists(manifestFilePath))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
|
@ -48,7 +48,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Simulation manifest file not found : {manifestFilePath}";
|
||||
Error = $"Simulation package manifest file not found : {manifestFilePath}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadEditorPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
LoadVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultEditorFileSystem _fileSystem;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal LoadEditorPackageVersionOperation(DefaultEditorFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.LoadVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.LoadVersion)
|
||||
{
|
||||
string versionFilePath = _fileSystem.BuildResult.PackageVersionFilePath;
|
||||
if (File.Exists(versionFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = FileUtility.ReadAllText(versionFilePath);
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Simulation package version file not found : {versionFilePath}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1f86d3bce4381694b8c619ceda2e7309
|
||||
guid: a4278d490ca87354ab63b0bece1fdab7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -21,7 +21,6 @@ namespace YooAsset
|
|||
protected readonly Dictionary<string, string> _webFilePaths = new Dictionary<string, string>(10000);
|
||||
protected string _webPackageRoot = string.Empty;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
|
@ -115,13 +114,13 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync(params object[] args)
|
||||
{
|
||||
var operation = new DWFSClearAllBundleFilesOperation(this);
|
||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(params object[] args)
|
||||
{
|
||||
var operation = new DWFSClearUnusedBundleFilesOperation(this);
|
||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DWFSClearAllBundleFilesOperation : FSClearAllBundleFilesOperation
|
||||
{
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
|
||||
internal DWFSClearAllBundleFilesOperation(DefaultWebFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 68578d4c5e39a554aa3df2e7ec5218e9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DWFSClearUnusedBundleFilesOperation : FSClearUnusedBundleFilesOperation
|
||||
{
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
|
||||
internal DWFSClearUnusedBundleFilesOperation(DefaultWebFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1560968379b66d440a94382b2a311a15
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class FSClearAllBundleFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
|
||||
internal sealed class FSClearAllBundleFilesCompleteOperation : FSClearAllBundleFilesOperation
|
||||
{
|
||||
internal FSClearAllBundleFilesCompleteOperation()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class FSClearUnusedBundleFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
|
||||
internal sealed class FSClearUnusedBundleFilesCompleteOperation : FSClearUnusedBundleFilesOperation
|
||||
{
|
||||
internal FSClearUnusedBundleFilesCompleteOperation()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ namespace YooAsset
|
|||
protected enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckExists,
|
||||
CreateRequest,
|
||||
CheckRequest,
|
||||
VerifyTempFile,
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class FSClearAllBundleFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
}
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class FSClearUnusedBundleFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
}
|
|
@ -87,13 +87,13 @@ namespace YooAsset
|
|||
|
||||
/// <summary>
|
||||
/// 创建默认的编辑器文件系统参数
|
||||
/// <param name="simulateManifestFilePath">用于模拟运行的资源清单路径</param>
|
||||
/// <param name="SimulateBuildResult">模拟构建结果</param>
|
||||
/// </summary>
|
||||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(string simulateManifestFilePath)
|
||||
public static FileSystemParameters CreateDefaultEditorFileSystemParameters(SimulateBuildResult simulateBuildResult)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultEditorFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter("SIMULATE_MANIFEST_FILE_PATH", simulateManifestFilePath);
|
||||
fileSystemParams.AddParameter("SIMULATE_BUILD_RESULT", simulateBuildResult);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
|
|
|
@ -9,46 +9,109 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟模式
|
||||
/// 通用类
|
||||
/// </summary>
|
||||
internal sealed class EditorSimulateModeClearAllBundleFilesOperation : ClearAllBundleFilesOperation
|
||||
internal sealed class DefaultClearAllBundleFilesOperation : ClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearAllBundleFiles,
|
||||
ClearFileSystemA,
|
||||
ClearFileSystemB,
|
||||
ClearFileSystemC,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOp;
|
||||
private readonly IPlayMode _impl;
|
||||
private readonly IFileSystem _fileSystemA;
|
||||
private readonly IFileSystem _fileSystemB;
|
||||
private readonly IFileSystem _fileSystemC;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpA;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpB;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOpC;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeClearAllBundleFilesOperation(EditorSimulateModeImpl impl)
|
||||
internal DefaultClearAllBundleFilesOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystemA = fileSystemA;
|
||||
_fileSystemB = fileSystemB;
|
||||
_fileSystemC = fileSystemC;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearAllBundleFiles;
|
||||
_steps = ESteps.ClearFileSystemA;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearAllBundleFiles)
|
||||
if (_steps == ESteps.ClearFileSystemA)
|
||||
{
|
||||
if (_clearAllBundleFilesOp == null)
|
||||
{
|
||||
_clearAllBundleFilesOp = _impl.EditorFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
if (_clearAllBundleFilesOpA == null)
|
||||
_clearAllBundleFilesOpA = _fileSystemA.ClearAllBundleFilesAsync();
|
||||
|
||||
Progress = _clearAllBundleFilesOp.Progress;
|
||||
if (_clearAllBundleFilesOp.IsDone == false)
|
||||
Progress = _clearAllBundleFilesOpA.Progress;
|
||||
if (_clearAllBundleFilesOpA.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
if (_clearAllBundleFilesOpA.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemB;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOpA.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemB)
|
||||
{
|
||||
if (_fileSystemB == null)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearAllBundleFilesOpB == null)
|
||||
_clearAllBundleFilesOpB = _fileSystemB.ClearAllBundleFilesAsync();
|
||||
|
||||
Progress = _clearAllBundleFilesOpB.Progress;
|
||||
if (_clearAllBundleFilesOpB.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOpB.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOpB.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemC)
|
||||
{
|
||||
if (_fileSystemC == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearAllBundleFilesOpC == null)
|
||||
_clearAllBundleFilesOpC = _fileSystemC.ClearAllBundleFilesAsync();
|
||||
|
||||
Progress = _clearAllBundleFilesOpC.Progress;
|
||||
if (_clearAllBundleFilesOpC.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOpC.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
|
@ -57,228 +120,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeClearAllBundleFilesOperation : ClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearAllBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal OfflinePlayModeClearAllBundleFilesOperation(OfflinePlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearAllBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearAllBundleFiles)
|
||||
{
|
||||
if (_clearAllBundleFilesOp == null)
|
||||
{
|
||||
_clearAllBundleFilesOp = _impl.BuildinFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
|
||||
Progress = _clearAllBundleFilesOp.Progress;
|
||||
if (_clearAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeClearAllBundleFilesOperation : ClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearBuildinAllBundleFiles,
|
||||
ClearDeliveryAllBundleFiles,
|
||||
ClearCacheAllBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private FSClearAllBundleFilesOperation _clearBuildinAllBundleFilesOp;
|
||||
private FSClearAllBundleFilesOperation _clearDeliveryAllBundleFilesOp;
|
||||
private FSClearAllBundleFilesOperation _clearCacheAllBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeClearAllBundleFilesOperation(HostPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearBuildinAllBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearBuildinAllBundleFiles)
|
||||
{
|
||||
if (_clearBuildinAllBundleFilesOp == null)
|
||||
{
|
||||
_clearBuildinAllBundleFilesOp = _impl.BuildinFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
|
||||
Progress = _clearBuildinAllBundleFilesOp.Progress;
|
||||
if (_clearBuildinAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearBuildinAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearDeliveryAllBundleFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearBuildinAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearDeliveryAllBundleFiles)
|
||||
{
|
||||
if (_impl.DeliveryFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.ClearCacheAllBundleFiles;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearDeliveryAllBundleFilesOp == null)
|
||||
{
|
||||
_clearDeliveryAllBundleFilesOp = _impl.DeliveryFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
|
||||
Progress = _clearDeliveryAllBundleFilesOp.Progress;
|
||||
if (_clearDeliveryAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearDeliveryAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearCacheAllBundleFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearDeliveryAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearCacheAllBundleFiles)
|
||||
{
|
||||
if (_clearCacheAllBundleFilesOp == null)
|
||||
{
|
||||
_clearCacheAllBundleFilesOp = _impl.CacheFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
|
||||
Progress = _clearCacheAllBundleFilesOp.Progress;
|
||||
if (_clearCacheAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearCacheAllBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal sealed class WebPlayModeClearAllBundleFilesOperation : ClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearAllBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private FSClearAllBundleFilesOperation _clearAllBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeClearAllBundleFilesOperation(WebPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearAllBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearAllBundleFiles)
|
||||
{
|
||||
if (_clearAllBundleFilesOp == null)
|
||||
{
|
||||
_clearAllBundleFilesOp = _impl.WebFileSystem.ClearAllBundleFilesAsync();
|
||||
}
|
||||
|
||||
Progress = _clearAllBundleFilesOp.Progress;
|
||||
if (_clearAllBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearAllBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearAllBundleFilesOp.Error;
|
||||
Error = _clearAllBundleFilesOpC.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,46 +9,110 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟模式
|
||||
/// 通用类
|
||||
/// </summary>
|
||||
internal sealed class EditorSimulateModeClearUnusedBundleFilesOperation : ClearUnusedBundleFilesOperation
|
||||
internal sealed class DefaultClearUnusedBundleFilesOperation : ClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearUnusedBundleFiles,
|
||||
ClearFileSystemA,
|
||||
ClearFileSystemB,
|
||||
ClearFileSystemC,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOp;
|
||||
private readonly IPlayMode _impl;
|
||||
private readonly IFileSystem _fileSystemA;
|
||||
private readonly IFileSystem _fileSystemB;
|
||||
private readonly IFileSystem _fileSystemC;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpA;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpB;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOpC;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeClearUnusedBundleFilesOperation(EditorSimulateModeImpl impl)
|
||||
internal DefaultClearUnusedBundleFilesOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystemA = fileSystemA;
|
||||
_fileSystemB = fileSystemB;
|
||||
_fileSystemC = fileSystemC;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnusedBundleFiles;
|
||||
_steps = ESteps.ClearFileSystemA;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearUnusedBundleFiles)
|
||||
if (_steps == ESteps.ClearFileSystemA)
|
||||
{
|
||||
if (_clearUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearUnusedBundleFilesOp = _impl.EditorFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
if (_clearUnusedBundleFilesOpA == null)
|
||||
_clearUnusedBundleFilesOpA = _fileSystemA.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
|
||||
Progress = _clearUnusedBundleFilesOp.Progress;
|
||||
if (_clearUnusedBundleFilesOp.IsDone == false)
|
||||
Progress = _clearUnusedBundleFilesOpA.Progress;
|
||||
if (_clearUnusedBundleFilesOpA.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
if (_clearUnusedBundleFilesOpA.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemB;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearUnusedBundleFilesOpA.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemB)
|
||||
{
|
||||
if (_fileSystemB == null)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearUnusedBundleFilesOpB == null)
|
||||
_clearUnusedBundleFilesOpB = _fileSystemB.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
|
||||
Progress = _clearUnusedBundleFilesOpB.Progress;
|
||||
if (_clearUnusedBundleFilesOpB.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearUnusedBundleFilesOpB.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearUnusedBundleFilesOpB.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemC)
|
||||
{
|
||||
if (_fileSystemC == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearUnusedBundleFilesOpC == null)
|
||||
_clearUnusedBundleFilesOpC = _fileSystemC.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
|
||||
Progress = _clearUnusedBundleFilesOpC.Progress;
|
||||
if (_clearUnusedBundleFilesOpC.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearUnusedBundleFilesOpC.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
|
@ -57,229 +121,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeClearUnusedBundleFilesOperation : ClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearUnusedBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal OfflinePlayModeClearUnusedBundleFilesOperation(OfflinePlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnusedBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearUnusedBundleFiles)
|
||||
{
|
||||
if (_clearUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearUnusedBundleFilesOp = _impl.BuildinFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
|
||||
Progress = _clearUnusedBundleFilesOp.Progress;
|
||||
if (_clearUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeClearUnusedBundleFilesOperation : ClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearBuildinUnusedBundleFiles,
|
||||
ClearDeliveryUnusedBundleFiles,
|
||||
ClearCacheUnusedBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private FSClearUnusedBundleFilesOperation _clearBuildinUnusedBundleFilesOp;
|
||||
private FSClearUnusedBundleFilesOperation _clearDeliveryUnusedBundleFilesOp;
|
||||
private FSClearUnusedBundleFilesOperation _clearCacheUnusedBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeClearUnusedBundleFilesOperation(HostPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearBuildinUnusedBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearBuildinUnusedBundleFiles)
|
||||
{
|
||||
if (_clearBuildinUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearBuildinUnusedBundleFilesOp = _impl.BuildinFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
|
||||
Progress = _clearBuildinUnusedBundleFilesOp.Progress;
|
||||
if (_clearBuildinUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearBuildinUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearDeliveryUnusedBundleFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearBuildinUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearDeliveryUnusedBundleFiles)
|
||||
{
|
||||
if (_impl.DeliveryFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.ClearCacheUnusedBundleFiles;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearDeliveryUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearDeliveryUnusedBundleFilesOp = _impl.DeliveryFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
|
||||
Progress = _clearDeliveryUnusedBundleFilesOp.Progress;
|
||||
if (_clearDeliveryUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearDeliveryUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearCacheUnusedBundleFiles;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearDeliveryUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearCacheUnusedBundleFiles)
|
||||
{
|
||||
if (_clearCacheUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearCacheUnusedBundleFilesOp = _impl.CacheFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
|
||||
Progress = _clearCacheUnusedBundleFilesOp.Progress;
|
||||
if (_clearCacheUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearCacheUnusedBundleFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal sealed class WebPlayModeClearUnusedBundleFilesOperation : ClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearUnusedBundleFiles,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private FSClearUnusedBundleFilesOperation _clearUnusedBundleFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeClearUnusedBundleFilesOperation(WebPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.ClearUnusedBundleFiles;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearUnusedBundleFiles)
|
||||
{
|
||||
if (_clearUnusedBundleFilesOp == null)
|
||||
{
|
||||
_clearUnusedBundleFilesOp = _impl.WebFileSystem.ClearUnusedBundleFilesAsync(_impl.ActiveManifest);
|
||||
}
|
||||
|
||||
Progress = _clearUnusedBundleFilesOp.Progress;
|
||||
if (_clearUnusedBundleFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearUnusedBundleFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearUnusedBundleFilesOp.Error;
|
||||
Error = _clearUnusedBundleFilesOpC.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,10 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 预下载内容
|
||||
/// 说明:目前只支持联机模式
|
||||
/// </summary>
|
||||
public abstract class PreDownloadContentOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
|
|
|
@ -13,146 +13,57 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行
|
||||
/// 通用类
|
||||
/// </summary>
|
||||
internal class EditorSimulateModeRequestPackageVersionOperation : RequestPackageVersionOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal class OfflinePlayModeRequestPackageVersionOperation : RequestPackageVersionOperation
|
||||
{
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal class HostPlayModeRequestPackageVersionOperation : RequestPackageVersionOperation
|
||||
internal sealed class DefaultRequestPackageVersionOperation : RequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
QueryPackageVersion,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private FSRequestPackageVersionOperation _queryPackageVersionOp;
|
||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeRequestPackageVersionOperation(HostPlayModeImpl impl, bool appendTimeTicks, int timeout)
|
||||
internal DefaultRequestPackageVersionOperation(IFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystem = fileSystem;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.QueryPackageVersion;
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.QueryPackageVersion)
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_queryPackageVersionOp == null)
|
||||
{
|
||||
_queryPackageVersionOp = _impl.CacheFileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
||||
}
|
||||
if (_requestPackageVersionOp == null)
|
||||
_requestPackageVersionOp = _fileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
||||
|
||||
if (_queryPackageVersionOp.IsDone == false)
|
||||
if (_requestPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
if (_requestPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _queryPackageVersionOp.PackageVersion;
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _requestPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _queryPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal class WebPlayModeRequestPackageVersionOperation : RequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
QueryPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private FSRequestPackageVersionOperation _queryPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeRequestPackageVersionOperation(WebPlayModeImpl impl, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.QueryPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.QueryPackageVersion)
|
||||
{
|
||||
if (_queryPackageVersionOp == null)
|
||||
{
|
||||
_queryPackageVersionOp = _impl.WebFileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
||||
}
|
||||
|
||||
if (_queryPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_queryPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _queryPackageVersionOp.PackageVersion;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _queryPackageVersionOp.Error;
|
||||
Error = _requestPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,43 +9,9 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟运行
|
||||
/// 通用类
|
||||
/// </summary>
|
||||
internal sealed class EditorSimulateModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
public EditorSimulateModeUpdatePackageManifestOperation()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
public OfflinePlayModeUpdatePackageManifestOperation()
|
||||
{
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
internal sealed class DefaultUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -56,16 +22,18 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly IPlayMode _impl;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal HostPlayModeUpdatePackageManifestOperation(HostPlayModeImpl impl, string packageVersion, int timeout)
|
||||
internal DefaultUpdatePackageManifestOperation(IPlayMode impl, IFileSystem fileSystem, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
|
@ -109,95 +77,7 @@ namespace YooAsset
|
|||
if (_steps == ESteps.LoadPackageManifest)
|
||||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
_loadPackageManifestOp = _impl.CacheFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
|
||||
if (_loadPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
_impl.ActiveManifest = _loadPackageManifestOp.Result;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadPackageManifestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal sealed class WebPlayModeUpdatePackageManifestOperation : UpdatePackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckParams,
|
||||
CheckActiveManifest,
|
||||
LoadRemoteManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal WebPlayModeUpdatePackageManifestOperation(WebPlayModeImpl impl, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.CheckParams;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckParams)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_packageVersion))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Package version is null or empty.";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CheckActiveManifest;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckActiveManifest)
|
||||
{
|
||||
// 检测当前激活的清单对象
|
||||
if (_impl.ActiveManifest != null && _impl.ActiveManifest.PackageVersion == _packageVersion)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadRemoteManifest;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadRemoteManifest)
|
||||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
_loadPackageManifestOp = _impl.WebFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
_loadPackageManifestOp = _fileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
|
||||
if (_loadPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
|
|
@ -3,6 +3,13 @@ using System.Reflection;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class SimulateBuildResult
|
||||
{
|
||||
public string PackageVersionFilePath;
|
||||
public string PackageManifestFilePath;
|
||||
public string PackageHashFilePath;
|
||||
}
|
||||
|
||||
public static class EditorSimulateModeHelper
|
||||
{
|
||||
private static System.Type _classType;
|
||||
|
@ -10,19 +17,18 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 编辑器下模拟构建清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
||||
public static SimulateBuildResult SimulateBuild(string buildPipelineName, string packageName)
|
||||
{
|
||||
if (_classType == null)
|
||||
_classType = Assembly.Load("YooAsset.Editor").GetType("YooAsset.Editor.AssetBundleSimulateBuilder");
|
||||
|
||||
string manifestFilePath = (string)InvokePublicStaticMethod(_classType, "SimulateBuild", buildPipelineName, packageName);
|
||||
return manifestFilePath;
|
||||
return (SimulateBuildResult)InvokePublicStaticMethod(_classType, "SimulateBuild", buildPipelineName, packageName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟构建清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(EDefaultBuildPipeline buildPipeline, string packageName)
|
||||
public static SimulateBuildResult SimulateBuild(EDefaultBuildPipeline buildPipeline, string packageName)
|
||||
{
|
||||
return SimulateBuild(buildPipeline.ToString(), packageName);
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ namespace YooAsset
|
|||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new EditorSimulateModeRequestPackageVersionOperation();
|
||||
var operation = new DefaultRequestPackageVersionOperation(EditorFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new EditorSimulateModeUpdatePackageManifestOperation();
|
||||
var operation = new DefaultUpdatePackageManifestOperation(this, EditorFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new EditorSimulateModeClearAllBundleFilesOperation(this);
|
||||
var operation = new DefaultClearAllBundleFilesOperation(this, EditorFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new EditorSimulateModeClearUnusedBundleFilesOperation(this);
|
||||
var operation = new DefaultClearUnusedBundleFilesOperation(this, EditorFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -44,13 +44,13 @@ namespace YooAsset
|
|||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||
var operation = new DefaultRequestPackageVersionOperation(CacheFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModeUpdatePackageManifestOperation(this, packageVersion, timeout);
|
||||
var operation = new DefaultUpdatePackageManifestOperation(this, CacheFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -63,13 +63,13 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new HostPlayModeClearAllBundleFilesOperation(this);
|
||||
var operation = new DefaultClearAllBundleFilesOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new HostPlayModeClearUnusedBundleFilesOperation(this);
|
||||
var operation = new DefaultClearUnusedBundleFilesOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ namespace YooAsset
|
|||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new OfflinePlayModeRequestPackageVersionOperation();
|
||||
var operation = new DefaultRequestPackageVersionOperation(BuildinFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new OfflinePlayModeUpdatePackageManifestOperation();
|
||||
var operation = new DefaultUpdatePackageManifestOperation(this, BuildinFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new OfflinePlayModeClearAllBundleFilesOperation(this);
|
||||
var operation = new DefaultClearAllBundleFilesOperation(this, BuildinFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new OfflinePlayModeClearUnusedBundleFilesOperation(this);
|
||||
var operation = new DefaultClearUnusedBundleFilesOperation(this, BuildinFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,13 @@ namespace YooAsset
|
|||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new WebPlayModeRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||
var operation = new DefaultRequestPackageVersionOperation(WebFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new WebPlayModeUpdatePackageManifestOperation(this, packageVersion, timeout);
|
||||
var operation = new DefaultUpdatePackageManifestOperation(this, WebFileSystem, packageVersion, timeout);;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -55,13 +55,13 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new WebPlayModeClearAllBundleFilesOperation(this);
|
||||
var operation = new DefaultClearAllBundleFilesOperation(this, WebFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new WebPlayModeClearUnusedBundleFilesOperation(this);
|
||||
var operation = new DefaultClearUnusedBundleFilesOperation(this, WebFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue