mirror of https://github.com/tuyoogame/YooAsset
parent
47f5790507
commit
522ddb5115
|
@ -1,4 +1,5 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -25,6 +26,11 @@ namespace YooAsset
|
|||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
WebPlayMode,
|
||||
|
||||
/// <summary>
|
||||
/// 自定义运行模式
|
||||
/// </summary>
|
||||
CustomPlayMode,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -67,4 +73,16 @@ namespace YooAsset
|
|||
public FileSystemParameters WebServerFileSystemParameters;
|
||||
public FileSystemParameters WebRemoteFileSystemParameters;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自定义运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class CustomPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件系统初始化参数列表
|
||||
/// 注意:列表最后一个元素作为主文件系统!
|
||||
/// </summary>
|
||||
public List<FileSystemParameters> FileSystemParameterList;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public void Initialize(InitializeParameters initializeParameters, IBundleQuery bundleServices)
|
||||
public void Initialize(IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleQuery = bundleServices;
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
|
|
|
@ -27,10 +27,5 @@ namespace YooAsset
|
|||
/// 获取依赖的资源包名称集合
|
||||
/// </summary>
|
||||
string[] GetDependBundleNames(AssetInfo assetInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 清单是否有效
|
||||
/// </summary>
|
||||
bool ManifestValid();
|
||||
}
|
||||
}
|
|
@ -1,144 +1,102 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class ClearCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
internal sealed class ClearCacheFilesImplOperation : ClearCacheFilesOperation
|
||||
public sealed class ClearCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
ClearFileSystemA,
|
||||
ClearFileSystemB,
|
||||
ClearFileSystemC,
|
||||
Prepare,
|
||||
ClearCacheFiles,
|
||||
CheckClearResult,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly IPlayMode _impl;
|
||||
private readonly IFileSystem _fileSystemA;
|
||||
private readonly IFileSystem _fileSystemB;
|
||||
private readonly IFileSystem _fileSystemC;
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly string _clearMode;
|
||||
private readonly object _clearParam;
|
||||
private FSClearCacheFilesOperation _clearCacheFilesOpA;
|
||||
private FSClearCacheFilesOperation _clearCacheFilesOpB;
|
||||
private FSClearCacheFilesOperation _clearCacheFilesOpC;
|
||||
private List<IFileSystem> _cloneList;
|
||||
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal ClearCacheFilesImplOperation(IPlayMode impl, IFileSystem fileSystemA, IFileSystem fileSystemB, IFileSystem fileSystemC, string clearMode, object clearParam)
|
||||
internal ClearCacheFilesOperation(PlayModeImpl impl, string clearMode, object clearParam)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystemA = fileSystemA;
|
||||
_fileSystemB = fileSystemB;
|
||||
_fileSystemC = fileSystemC;
|
||||
_clearMode = clearMode;
|
||||
_clearParam = clearParam;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemA;
|
||||
_steps = ESteps.Prepare;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemA)
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
if (_fileSystemA == null)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemB;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearCacheFilesOpA == null)
|
||||
{
|
||||
_clearCacheFilesOpA = _fileSystemA.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
_clearCacheFilesOpA.StartOperation();
|
||||
AddChildOperation(_clearCacheFilesOpA);
|
||||
}
|
||||
|
||||
_clearCacheFilesOpA.UpdateOperation();
|
||||
Progress = _clearCacheFilesOpA.Progress;
|
||||
if (_clearCacheFilesOpA.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheFilesOpA.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemB;
|
||||
}
|
||||
else
|
||||
var fileSytems = _impl.FileSystems;
|
||||
if (fileSytems == null || fileSytems.Count == 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearCacheFilesOpA.Error;
|
||||
Error = "The file system is empty !";
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var fileSystem in fileSytems)
|
||||
{
|
||||
if (fileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "An empty object exists in the list!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_cloneList = fileSytems.ToList();
|
||||
_steps = ESteps.ClearCacheFiles;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemB)
|
||||
if (_steps == ESteps.ClearCacheFiles)
|
||||
{
|
||||
if (_fileSystemB == null)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearCacheFilesOpB == null)
|
||||
{
|
||||
_clearCacheFilesOpB = _fileSystemB.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
_clearCacheFilesOpB.StartOperation();
|
||||
AddChildOperation(_clearCacheFilesOpB);
|
||||
}
|
||||
|
||||
_clearCacheFilesOpB.UpdateOperation();
|
||||
Progress = _clearCacheFilesOpB.Progress;
|
||||
if (_clearCacheFilesOpB.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheFilesOpB.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearFileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearCacheFilesOpB.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearFileSystemC)
|
||||
{
|
||||
if (_fileSystemC == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_clearCacheFilesOpC == null)
|
||||
{
|
||||
_clearCacheFilesOpC = _fileSystemC.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
_clearCacheFilesOpC.StartOperation();
|
||||
AddChildOperation(_clearCacheFilesOpC);
|
||||
}
|
||||
|
||||
_clearCacheFilesOpC.UpdateOperation();
|
||||
Progress = _clearCacheFilesOpC.Progress;
|
||||
if (_clearCacheFilesOpC.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheFilesOpC.Status == EOperationStatus.Succeed)
|
||||
if (_cloneList.Count == 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileSystem = _cloneList[0];
|
||||
_cloneList.RemoveAt(0);
|
||||
|
||||
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _clearMode, _clearParam);
|
||||
_clearCacheFilesOp.StartOperation();
|
||||
AddChildOperation(_clearCacheFilesOp);
|
||||
_steps = ESteps.CheckClearResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckClearResult)
|
||||
{
|
||||
_clearCacheFilesOp.UpdateOperation();
|
||||
Progress = _clearCacheFilesOp.Progress;
|
||||
if (_clearCacheFilesOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_clearCacheFilesOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.ClearCacheFiles;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _clearCacheFilesOpC.Error;
|
||||
Error = _clearCacheFilesOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,73 +1,108 @@
|
|||
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化操作
|
||||
/// </summary>
|
||||
public abstract class InitializationOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟模式
|
||||
/// </summary>
|
||||
internal sealed class EditorSimulateModeInitializationOperation : InitializationOperation
|
||||
public class InitializationOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateFileSystem,
|
||||
Prepare,
|
||||
ClearOldFileSystem,
|
||||
InitFileSystem,
|
||||
CheckInitResult,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private readonly EditorSimulateModeParameters _parameters;
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly List<FileSystemParameters> _parametersList;
|
||||
private List<FileSystemParameters> _cloneList;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, EditorSimulateModeParameters parameters)
|
||||
internal InitializationOperation(PlayModeImpl impl, List<FileSystemParameters> parametersList)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
_parametersList = parametersList;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
_steps = ESteps.Prepare;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
if (_parameters.EditorFileSystemParameters == null)
|
||||
if (_parametersList == null || _parametersList.Count == 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Editor file system parameters is null";
|
||||
Error = "The file system parameters is empty !";
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.EditorFileSystem = _parameters.EditorFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.EditorFileSystem == null)
|
||||
foreach (var fileSystemParam in _parametersList)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create editor file system";
|
||||
return;
|
||||
if (fileSystemParam == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "An empty object exists in the list!";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_cloneList = _parametersList.ToList();
|
||||
_steps = ESteps.ClearOldFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.ClearOldFileSystem)
|
||||
{
|
||||
// 注意:初始化失败后可能会残存一些旧的文件系统!
|
||||
foreach (var fileSystem in _impl.FileSystems)
|
||||
{
|
||||
fileSystem.OnDestroy();
|
||||
}
|
||||
|
||||
_impl.FileSystems.Clear();
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitFileSystem)
|
||||
{
|
||||
if (_initFileSystemOp == null)
|
||||
if (_cloneList.Count == 0)
|
||||
{
|
||||
_initFileSystemOp = _impl.EditorFileSystem.InitializeFileSystemAsync();
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
var fileSystemParams = _cloneList[0];
|
||||
_cloneList.RemoveAt(0);
|
||||
|
||||
IFileSystem fileSystemInstance = fileSystemParams.CreateFileSystem(_impl.PackageName);
|
||||
if (fileSystemInstance == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create file system instance !";
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.FileSystems.Add(fileSystemInstance);
|
||||
_initFileSystemOp = fileSystemInstance.InitializeFileSystemAsync();
|
||||
_initFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initFileSystemOp);
|
||||
_steps = ESteps.CheckInitResult;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckInitResult)
|
||||
{
|
||||
_initFileSystemOp.UpdateOperation();
|
||||
Progress = _initFileSystemOp.Progress;
|
||||
if (_initFileSystemOp.IsDone == false)
|
||||
|
@ -75,375 +110,15 @@ namespace YooAsset
|
|||
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 离线运行模式
|
||||
/// </summary>
|
||||
internal sealed class OfflinePlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateFileSystem,
|
||||
InitFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
private readonly OfflinePlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal OfflinePlayModeInitializationOperation(OfflinePlayModeImpl impl, OfflinePlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
{
|
||||
if (_parameters.BuildinFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Buildin file system parameters is null";
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitFileSystem)
|
||||
{
|
||||
if (_initFileSystemOp == null)
|
||||
{
|
||||
_initFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
_initFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initFileSystemOp);
|
||||
}
|
||||
|
||||
_initFileSystemOp.UpdateOperation();
|
||||
Progress = _initFileSystemOp.Progress;
|
||||
if (_initFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 联机运行模式
|
||||
/// </summary>
|
||||
internal sealed class HostPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateBuildinFileSystem,
|
||||
InitBuildinFileSystem,
|
||||
CreateCacheFileSystem,
|
||||
InitCacheFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly HostPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal HostPlayModeInitializationOperation(HostPlayModeImpl impl, HostPlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateBuildinFileSystem;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CreateBuildinFileSystem)
|
||||
{
|
||||
if (_parameters.BuildinFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.BuildinFileSystem = _parameters.BuildinFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitBuildinFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitBuildinFileSystem)
|
||||
{
|
||||
if (_initBuildinFileSystemOp == null)
|
||||
{
|
||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
_initBuildinFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initBuildinFileSystemOp);
|
||||
}
|
||||
|
||||
_initBuildinFileSystemOp.UpdateOperation();
|
||||
Progress = _initBuildinFileSystemOp.Progress;
|
||||
if (_initBuildinFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initBuildinFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CreateCacheFileSystem)
|
||||
{
|
||||
if (_parameters.CacheFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Cache file system parameters is null";
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.CacheFileSystem = _parameters.CacheFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.CacheFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create cache file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitCacheFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitCacheFileSystem)
|
||||
{
|
||||
if (_initCacheFileSystemOp == null)
|
||||
{
|
||||
_initCacheFileSystemOp = _impl.CacheFileSystem.InitializeFileSystemAsync();
|
||||
_initCacheFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initCacheFileSystemOp);
|
||||
}
|
||||
|
||||
_initCacheFileSystemOp.UpdateOperation();
|
||||
Progress = _initCacheFileSystemOp.Progress;
|
||||
if (_initCacheFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initCacheFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initCacheFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// WebGL运行模式
|
||||
/// </summary>
|
||||
internal sealed class WebPlayModeInitializationOperation : InitializationOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateWebServerFileSystem,
|
||||
InitWebServerFileSystem,
|
||||
CreateWebRemoteFileSystem,
|
||||
InitWebRemoteFileSystem,
|
||||
CheckResult,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private readonly WebPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initWebServerFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initWebRemoteFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl, WebPlayModeParameters parameters)
|
||||
{
|
||||
_impl = impl;
|
||||
_parameters = parameters;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.CreateWebServerFileSystem;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CreateWebServerFileSystem)
|
||||
{
|
||||
if (_parameters.WebServerFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebServerFileSystem = _parameters.WebServerFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebServerFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web server file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebServerFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitWebServerFileSystem)
|
||||
{
|
||||
if (_initWebServerFileSystemOp == null)
|
||||
{
|
||||
_initWebServerFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||
_initWebServerFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initWebServerFileSystemOp);
|
||||
}
|
||||
|
||||
_initWebServerFileSystemOp.UpdateOperation();
|
||||
Progress = _initWebServerFileSystemOp.Progress;
|
||||
if (_initWebServerFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initWebServerFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebServerFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CreateWebRemoteFileSystem)
|
||||
{
|
||||
if (_parameters.WebRemoteFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebRemoteFileSystem = _parameters.WebRemoteFileSystemParameters.CreateFileSystem(_impl.PackageName);
|
||||
if (_impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web remote file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebRemoteFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitWebRemoteFileSystem)
|
||||
{
|
||||
if (_initWebRemoteFileSystemOp == null)
|
||||
{
|
||||
_initWebRemoteFileSystemOp = _impl.WebRemoteFileSystem.InitializeFileSystemAsync();
|
||||
_initWebRemoteFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initWebRemoteFileSystemOp);
|
||||
}
|
||||
|
||||
_initWebRemoteFileSystemOp.UpdateOperation();
|
||||
Progress = _initWebRemoteFileSystemOp.Progress;
|
||||
if (_initWebRemoteFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initWebRemoteFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebRemoteFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckResult)
|
||||
{
|
||||
if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Not found any file system !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,132 +4,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 预下载内容
|
||||
/// 说明:目前只支持联机模式
|
||||
/// </summary>
|
||||
public abstract class PreDownloadContentOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public abstract ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60);
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public abstract ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60);
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public abstract ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60);
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public abstract ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60);
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="locations">资源定位地址列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public abstract ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60);
|
||||
}
|
||||
|
||||
internal class EditorSimulateModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
{
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
|
||||
public EditorSimulateModePreDownloadContentOperation(EditorSimulateModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
}
|
||||
internal class OfflinePlayModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
{
|
||||
private readonly OfflinePlayModeImpl _impl;
|
||||
|
||||
public OfflinePlayModePreDownloadContentOperation(OfflinePlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
}
|
||||
internal class HostPlayModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
public sealed class PreDownloadContentOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -140,7 +15,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
|
@ -148,7 +23,7 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal HostPlayModePreDownloadContentOperation(HostPlayModeImpl impl, string packageVersion, int timeout)
|
||||
internal PreDownloadContentOperation(PlayModeImpl impl, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_packageVersion = packageVersion;
|
||||
|
@ -196,7 +71,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
{
|
||||
_loadPackageManifestOp = _impl.CacheFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
_loadPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadPackageManifestOp);
|
||||
}
|
||||
|
@ -220,7 +96,13 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -228,11 +110,19 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -240,11 +130,19 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -252,11 +150,19 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -268,11 +174,19 @@ namespace YooAsset
|
|||
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
|
||||
assetInfos.Add(assetInfo);
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="locations">资源定位地址列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
/// <param name="timeout">超时时间</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
|
@ -287,46 +201,9 @@ namespace YooAsset
|
|||
assetInfos.Add(assetInfo);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
internal class WebPlayModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
{
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
|
||||
public WebPlayModePreDownloadContentOperation(WebPlayModeImpl impl)
|
||||
{
|
||||
_impl = impl;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
|
||||
{
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,9 +1,6 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询远端包裹的最新版本
|
||||
/// </summary>
|
||||
public abstract class RequestPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
|
@ -20,15 +17,15 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal RequestPackageVersionImplOperation(IFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
internal RequestPackageVersionImplOperation(PlayModeImpl impl, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_impl = impl;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
|
@ -45,7 +42,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_requestPackageVersionOp == null)
|
||||
{
|
||||
_requestPackageVersionOp = _fileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
_requestPackageVersionOp = mainFileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
||||
_requestPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestPackageVersionOp);
|
||||
}
|
||||
|
|
|
@ -1,13 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 向远端请求并更新清单
|
||||
/// </summary>
|
||||
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
}
|
||||
internal sealed class UpdatePackageManifestImplOperation : UpdatePackageManifestOperation
|
||||
public sealed class UpdatePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -17,19 +11,16 @@ namespace YooAsset
|
|||
LoadPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly IPlayMode _impl;
|
||||
private readonly IFileSystem _fileSystem;
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal UpdatePackageManifestImplOperation(IPlayMode impl, IFileSystem fileSystem, string packageVersion, int timeout)
|
||||
internal UpdatePackageManifestOperation(PlayModeImpl impl, string packageVersion, int timeout)
|
||||
{
|
||||
_impl = impl;
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
|
@ -74,7 +65,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
{
|
||||
_loadPackageManifestOp = _fileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
||||
_loadPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadPackageManifestOp);
|
||||
}
|
||||
|
|
|
@ -1,173 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class EditorSimulateModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem EditorFileSystem { set; get; }
|
||||
|
||||
|
||||
public EditorSimulateModeImpl(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(EditorSimulateModeParameters initParameters)
|
||||
{
|
||||
var operation = new EditorSimulateModeInitializationOperation(this, initParameters);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
{
|
||||
if (EditorFileSystem != null)
|
||||
EditorFileSystem.OnDestroy();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(EditorFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, EditorFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new EditorSimulateModePreDownloadContentOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
||||
{
|
||||
var operation = new ClearCacheFilesImplOperation(this, EditorFileSystem, null, null, clearMode, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, EditorFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, EditorFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload, EditorFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, EditorFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, EditorFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, EditorFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle, AssetInfo assetInfo)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (EditorFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(EditorFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle, assetInfo);
|
||||
}
|
||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return ActiveManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2fb1b9a2a91f1af4a86acfcfac424e0b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,181 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class HostPlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem CacheFileSystem { set; get; }
|
||||
|
||||
|
||||
public HostPlayModeImpl(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(HostPlayModeParameters initParameters)
|
||||
{
|
||||
var operation = new HostPlayModeInitializationOperation(this, initParameters);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
{
|
||||
if (BuildinFileSystem != null)
|
||||
BuildinFileSystem.OnDestroy();
|
||||
if (CacheFileSystem != null)
|
||||
CacheFileSystem.OnDestroy();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(CacheFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, CacheFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new HostPlayModePreDownloadContentOperation(this, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
||||
{
|
||||
var operation = new ClearCacheFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null, clearMode, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle, AssetInfo assetInfo)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (BuildinFileSystem != null && BuildinFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
if (CacheFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(CacheFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle, assetInfo);
|
||||
}
|
||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return ActiveManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 84c10fd3507a1c24a9043aebb72db5f5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,173 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class OfflinePlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem BuildinFileSystem { set; get; }
|
||||
|
||||
|
||||
public OfflinePlayModeImpl(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(OfflinePlayModeParameters initParameters)
|
||||
{
|
||||
var operation = new OfflinePlayModeInitializationOperation(this, initParameters);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
{
|
||||
if (BuildinFileSystem != null)
|
||||
BuildinFileSystem.OnDestroy();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(BuildinFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, BuildinFileSystem, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new OfflinePlayModePreDownloadContentOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
||||
{
|
||||
var operation = new ClearCacheFilesImplOperation(this, BuildinFileSystem, null, null, clearMode, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload, BuildinFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle, AssetInfo assetInfo)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (BuildinFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle, assetInfo);
|
||||
}
|
||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return ActiveManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,276 +0,0 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class PlayModeHelper
|
||||
{
|
||||
public static List<BundleInfo> GetDownloadListByAll(PackageManifest manifest, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
// 如果未带任何标记,则统一下载
|
||||
if (packageBundle.HasAnyTags() == false)
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查询DLC资源
|
||||
if (packageBundle.HasTag(tags))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static List<BundleInfo> GetDownloadListByPaths(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDownload, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
// 获取资源对象的资源包和所有依赖资源包
|
||||
List<PackageBundle> checkList = new List<PackageBundle>();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle mainBundle = manifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
if (checkList.Contains(mainBundle) == false)
|
||||
checkList.Add(mainBundle);
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle[] mainDependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
foreach (var dependBundle in mainDependBundles)
|
||||
{
|
||||
if (checkList.Contains(dependBundle) == false)
|
||||
checkList.Add(dependBundle);
|
||||
}
|
||||
|
||||
// 下载主资源包内所有资源对象依赖的资源包
|
||||
if (recursiveDownload)
|
||||
{
|
||||
foreach (var otherMainAsset in mainBundle.IncludeMainAssets)
|
||||
{
|
||||
var otherMainBundle = manifest.GetMainPackageBundle(otherMainAsset.BundleID);
|
||||
if (checkList.Contains(otherMainBundle) == false)
|
||||
checkList.Add(otherMainBundle);
|
||||
|
||||
PackageBundle[] otherDependBundles = manifest.GetAllDependencies(otherMainAsset);
|
||||
foreach (var dependBundle in otherDependBundles)
|
||||
{
|
||||
if (checkList.Contains(dependBundle) == false)
|
||||
checkList.Add(dependBundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in checkList)
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedDownload(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public static List<BundleInfo> GetUnpackListByAll(PackageManifest manifest, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public static List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedUnpack(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
// 查询DLC资源
|
||||
if (packageBundle.HasTag(tags))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
public static List<BundleInfo> GetImporterListByFilePaths(PackageManifest manifest, string[] filePaths, IFileSystem fileSystemA = null, IFileSystem fileSystemB = null, IFileSystem fileSystemC = null)
|
||||
{
|
||||
List<BundleInfo> result = new List<BundleInfo>();
|
||||
foreach (var filePath in filePaths)
|
||||
{
|
||||
string fileName = System.IO.Path.GetFileName(filePath);
|
||||
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle))
|
||||
{
|
||||
IFileSystem fileSystem = null;
|
||||
if (fileSystemA != null && fileSystemA.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemA.NeedImport(packageBundle))
|
||||
fileSystem = fileSystemA;
|
||||
}
|
||||
else if (fileSystemB != null && fileSystemB.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemB.NeedImport(packageBundle))
|
||||
fileSystem = fileSystemB;
|
||||
}
|
||||
else if (fileSystemC != null && fileSystemC.Belong(packageBundle))
|
||||
{
|
||||
if (fileSystemC.NeedImport(packageBundle))
|
||||
fileSystem = fileSystemC;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle, filePath);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fbbce8ae4b0d0784683413d6466d27f8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,440 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class PlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public readonly List<IFileSystem> FileSystems = new List<IFileSystem>(10);
|
||||
|
||||
|
||||
public PlayModeImpl(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(FileSystemParameters fileSystemParameter)
|
||||
{
|
||||
var fileSystemParamList = new List<FileSystemParameters>();
|
||||
if (fileSystemParameter != null)
|
||||
fileSystemParamList.Add(fileSystemParameter);
|
||||
return InitializeAsync(fileSystemParamList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(FileSystemParameters fileSystemParameterA, FileSystemParameters fileSystemParameterB)
|
||||
{
|
||||
var fileSystemParamList = new List<FileSystemParameters>();
|
||||
if (fileSystemParameterA != null)
|
||||
fileSystemParamList.Add(fileSystemParameterA);
|
||||
if (fileSystemParameterB != null)
|
||||
fileSystemParamList.Add(fileSystemParameterB);
|
||||
return InitializeAsync(fileSystemParamList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(List<FileSystemParameters> fileSystemParameterList)
|
||||
{
|
||||
var operation = new InitializationOperation(this, fileSystemParameterList);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
/// <summary>
|
||||
/// 当前激活的清单
|
||||
/// </summary>
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 销毁文件系统
|
||||
/// </summary>
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
{
|
||||
foreach (var fileSystem in FileSystems)
|
||||
{
|
||||
fileSystem.OnDestroy();
|
||||
}
|
||||
FileSystems.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求最新的资源版本
|
||||
/// </summary>
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(this, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求并更新清单
|
||||
/// </summary>
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new UpdatePackageManifestOperation(this, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预下载指定版本的包裹内容
|
||||
/// </summary>
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new PreDownloadContentOperation(this, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
||||
{
|
||||
var operation = new ClearCacheFilesOperation(this, clearMode, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 下载相关
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(ActiveManifest);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(ActiveManifest, tags);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 解压相关
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(ActiveManifest);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(ActiveManifest, tags);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 导入相关
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = GetImporterListByFilePaths(ActiveManifest, filePaths);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem != null)
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle);
|
||||
}
|
||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取主文件系统
|
||||
/// 说明:文件系统列表里,最后一个属于主文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetMainFileSystem()
|
||||
{
|
||||
int count = FileSystems.Count;
|
||||
if (count == 0)
|
||||
return null;
|
||||
return FileSystems[count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包所属文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetBelongFileSystem(PackageBundle packageBundle)
|
||||
{
|
||||
for (int i = 0; i < FileSystems.Count; i++)
|
||||
{
|
||||
IFileSystem fileSystem = FileSystems[i];
|
||||
if (fileSystem.Belong(packageBundle))
|
||||
{
|
||||
return fileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedDownload(packageBundle))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedDownload(packageBundle))
|
||||
{
|
||||
// 如果未带任何标记,则统一下载
|
||||
if (packageBundle.HasAnyTags() == false)
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查询DLC资源
|
||||
if (packageBundle.HasTag(tags))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetDownloadListByPaths(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDownload)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
// 获取资源对象的资源包和所有依赖资源包
|
||||
List<PackageBundle> checkList = new List<PackageBundle>();
|
||||
foreach (var assetInfo in assetInfos)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
{
|
||||
YooLogger.Warning(assetInfo.Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle mainBundle = manifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
if (checkList.Contains(mainBundle) == false)
|
||||
checkList.Add(mainBundle);
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle[] mainDependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
foreach (var dependBundle in mainDependBundles)
|
||||
{
|
||||
if (checkList.Contains(dependBundle) == false)
|
||||
checkList.Add(dependBundle);
|
||||
}
|
||||
|
||||
// 下载主资源包内所有资源对象依赖的资源包
|
||||
if (recursiveDownload)
|
||||
{
|
||||
foreach (var otherMainAsset in mainBundle.IncludeMainAssets)
|
||||
{
|
||||
var otherMainBundle = manifest.GetMainPackageBundle(otherMainAsset.BundleID);
|
||||
if (checkList.Contains(otherMainBundle) == false)
|
||||
checkList.Add(otherMainBundle);
|
||||
|
||||
PackageBundle[] otherDependBundles = manifest.GetAllDependencies(otherMainAsset);
|
||||
foreach (var dependBundle in otherDependBundles)
|
||||
{
|
||||
if (checkList.Contains(dependBundle) == false)
|
||||
checkList.Add(dependBundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in checkList)
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedDownload(packageBundle))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedUnpack(packageBundle))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedUnpack(packageBundle))
|
||||
{
|
||||
if (packageBundle.HasTag(tags))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetImporterListByFilePaths(PackageManifest manifest, string[] filePaths)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
List<BundleInfo> result = new List<BundleInfo>();
|
||||
foreach (var filePath in filePaths)
|
||||
{
|
||||
string fileName = System.IO.Path.GetFileName(filePath);
|
||||
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle))
|
||||
{
|
||||
var fileSystem = GetBelongFileSystem(packageBundle);
|
||||
if (fileSystem == null)
|
||||
continue;
|
||||
|
||||
if (fileSystem.NeedImport(packageBundle))
|
||||
{
|
||||
var bundleInfo = new BundleInfo(fileSystem, packageBundle, filePath);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fc10550f17aaeb14795135a51444de1c
|
||||
guid: 7fa439f7b3213444290b3df1af1d8140
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -1,201 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class WebPlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem WebServerFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem WebRemoteFileSystem { set; get; } //可以为空!
|
||||
|
||||
|
||||
public WebPlayModeImpl(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(WebPlayModeParameters initParameters)
|
||||
{
|
||||
var operation = new WebPlayModeInitializationOperation(this, initParameters);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
{
|
||||
if (WebServerFileSystem != null)
|
||||
WebServerFileSystem.OnDestroy();
|
||||
|
||||
if (WebRemoteFileSystem != null)
|
||||
WebRemoteFileSystem.OnDestroy();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(WebRemoteFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(WebServerFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebRemoteFileSystem, packageVersion, timeout); ;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebServerFileSystem, packageVersion, timeout); ;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new WebPlayModePreDownloadContentOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(string clearMode, object clearParam)
|
||||
{
|
||||
var operation = new ClearCacheFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null, clearMode, clearParam);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, WebServerFileSystem, WebRemoteFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle, AssetInfo assetInfo)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (WebServerFileSystem != null && WebServerFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(WebServerFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
if (WebRemoteFileSystem != null && WebRemoteFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(WebRemoteFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
throw new Exception($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle, assetInfo);
|
||||
}
|
||||
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<BundleInfo> result = new List<BundleInfo>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
BundleInfo bundleInfo = CreateBundleInfo(packageBundle, assetInfo);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = ActiveManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
List<string> result = new List<string>(depends.Length);
|
||||
foreach (var packageBundle in depends)
|
||||
{
|
||||
result.Add(packageBundle.BundleName);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
bool IBundleQuery.ManifestValid()
|
||||
{
|
||||
return ActiveManifest != null;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fa7d8823ee040534db067e6e2c254267
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -95,48 +95,39 @@ namespace YooAsset
|
|||
_resourceManager = null;
|
||||
}
|
||||
|
||||
// 创建资源管理器
|
||||
InitializationOperation initializeOperation;
|
||||
// 创建资源管理器
|
||||
_resourceManager = new ResourceManager(PackageName);
|
||||
var playModeImpl = new PlayModeImpl(PackageName);
|
||||
_bundleQuery = playModeImpl;
|
||||
_playModeImpl = playModeImpl;
|
||||
_resourceManager.Initialize(_bundleQuery);
|
||||
|
||||
// 初始化资源系统
|
||||
InitializationOperation initializeOperation;
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
|
||||
_bundleQuery = editorSimulateModeImpl;
|
||||
_playModeImpl = editorSimulateModeImpl;
|
||||
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.EditorFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
|
||||
_bundleQuery = offlinePlayModeImpl;
|
||||
_playModeImpl = offlinePlayModeImpl;
|
||||
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||
initializeOperation = offlinePlayModeImpl.InitializeAsync(initializeParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
|
||||
_bundleQuery = hostPlayModeImpl;
|
||||
_playModeImpl = hostPlayModeImpl;
|
||||
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as HostPlayModeParameters;
|
||||
initializeOperation = hostPlayModeImpl.InitializeAsync(initializeParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
|
||||
_bundleQuery = webPlayModeImpl;
|
||||
_playModeImpl = webPlayModeImpl;
|
||||
_resourceManager.Initialize(parameters, _bundleQuery);
|
||||
|
||||
var initializeParameters = parameters as WebPlayModeParameters;
|
||||
initializeOperation = webPlayModeImpl.InitializeAsync(initializeParameters);
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.CustomPlayMode)
|
||||
{
|
||||
var initializeParameters = parameters as CustomPlayModeParameters;
|
||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.FileSystemParameterList);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -179,6 +170,8 @@ namespace YooAsset
|
|||
_playMode = EPlayMode.HostPlayMode;
|
||||
else if (parameters is WebPlayModeParameters)
|
||||
_playMode = EPlayMode.WebPlayMode;
|
||||
else if (parameters is CustomPlayModeParameters)
|
||||
_playMode = EPlayMode.CustomPlayMode;
|
||||
else
|
||||
throw new NotImplementedException();
|
||||
|
||||
|
|
Loading…
Reference in New Issue