mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-30 13:38:46 +00:00
Compare commits
4 Commits
c8c74b8c20
...
2b6e7856e7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b6e7856e7 | ||
|
|
8d461056e4 | ||
|
|
f188cc715a | ||
|
|
329cae1441 |
@@ -129,16 +129,16 @@ namespace YooAsset
|
|||||||
var operation = new DBFSInitializeOperation(this);
|
var operation = new DBFSInitializeOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
|
||||||
var operation = new DBFSLoadPackageManifestOperation(this, packageVersion);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
|
||||||
{
|
{
|
||||||
var operation = new DBFSRequestPackageVersionOperation(this);
|
var operation = new DBFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
|
{
|
||||||
|
var operation = new DBFSLoadPackageManifestOperation(this, options.PackageVersion);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options);
|
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options);
|
||||||
|
|||||||
@@ -151,14 +151,14 @@ namespace YooAsset
|
|||||||
var operation = new DCFSInitializeOperation(this);
|
var operation = new DCFSInitializeOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DCFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
var operation = new DCFSRequestPackageVersionOperation(this, options.AppendTimeTicks, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DCFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DCFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
|
|||||||
@@ -83,16 +83,16 @@ namespace YooAsset
|
|||||||
var operation = new DEFSInitializeOperation(this);
|
var operation = new DEFSInitializeOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
|
||||||
var operation = new DEFSLoadPackageManifestOperation(this, packageVersion);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
|
||||||
{
|
{
|
||||||
var operation = new DEFSRequestPackageVersionOperation(this);
|
var operation = new DEFSRequestPackageVersionOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
|
{
|
||||||
|
var operation = new DEFSLoadPackageManifestOperation(this, options.PackageVersion);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
{
|
{
|
||||||
var operation = new FSClearCacheFilesCompleteOperation();
|
var operation = new FSClearCacheFilesCompleteOperation();
|
||||||
|
|||||||
@@ -78,14 +78,14 @@ namespace YooAsset
|
|||||||
var operation = new DWRFSInitializeOperation(this);
|
var operation = new DWRFSInitializeOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DWRFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
var operation = new DWRFSRequestPackageVersionOperation(this, options.AppendTimeTicks, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
var operation = new DWRFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
|
|||||||
@@ -87,14 +87,14 @@ namespace YooAsset
|
|||||||
var operation = new DWSFSInitializeOperation(this);
|
var operation = new DWSFSInitializeOperation(this);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DWSFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
var operation = new DWSFSRequestPackageVersionOperation(this, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
{
|
{
|
||||||
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
var operation = new DWSFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||||
|
|||||||
@@ -24,15 +24,15 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
FSInitializeFileSystemOperation InitializeFileSystemAsync();
|
FSInitializeFileSystemOperation InitializeFileSystemAsync();
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 加载包裹清单
|
|
||||||
/// </summary>
|
|
||||||
FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 查询包裹版本
|
/// 查询包裹版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
|
FSRequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载包裹清单
|
||||||
|
/// </summary>
|
||||||
|
FSLoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
@@ -43,7 +43,7 @@ namespace YooAsset
|
|||||||
/// 下载Bundle文件
|
/// 下载Bundle文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options);
|
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载Bundle文件
|
/// 加载Bundle文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -1,19 +1,6 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
internal class ClearCacheFilesOptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 清理模式
|
|
||||||
/// </summary>
|
|
||||||
public string ClearMode;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 附加参数
|
|
||||||
/// </summary>
|
|
||||||
public object ClearParam;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
internal abstract class FSClearCacheFilesOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,19 +3,6 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public sealed class UnloadAllAssetsOptions
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
|
||||||
/// </summary>
|
|
||||||
public bool ReleaseAllHandles = false;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
|
||||||
/// </summary>
|
|
||||||
public bool LockLoadOperation = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public sealed class UnloadAllAssetsOperation : AsyncOperationBase
|
public sealed class UnloadAllAssetsOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
@@ -49,14 +36,6 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckOptions)
|
if (_steps == ESteps.CheckOptions)
|
||||||
{
|
{
|
||||||
if (_options == null)
|
|
||||||
{
|
|
||||||
_steps = ESteps.Done;
|
|
||||||
Status = EOperationStatus.Failed;
|
|
||||||
Error = $"{nameof(UnloadAllAssetsOptions)} is null.";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 设置锁定状态
|
// 设置锁定状态
|
||||||
if (_options.LockLoadOperation)
|
if (_options.LockLoadOperation)
|
||||||
_resManager.LockLoadOperation = true;
|
_resManager.LockLoadOperation = true;
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public struct UnloadAllAssetsOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
||||||
|
/// </summary>
|
||||||
|
public bool ReleaseAllHandles { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
||||||
|
/// </summary>
|
||||||
|
public bool LockLoadOperation { private set; get; }
|
||||||
|
|
||||||
|
public UnloadAllAssetsOptions(bool releaseAllHandles, bool lockLoadOperation)
|
||||||
|
{
|
||||||
|
ReleaseAllHandles = releaseAllHandles;
|
||||||
|
LockLoadOperation = lockLoadOperation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dc733fff9ba8d5747b556fb6cdb2b9e2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -44,11 +44,11 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化
|
/// 初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
public void Initialize(InitializePackageOptions options, IBundleQuery bundleServices)
|
||||||
{
|
{
|
||||||
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
_bundleLoadingMaxConcurrency = options.BundleLoadingMaxConcurrency;
|
||||||
AutoUnloadBundleWhenUnused = parameters.AutoUnloadBundleWhenUnused;
|
AutoUnloadBundleWhenUnused = options.AutoUnloadBundleWhenUnused;
|
||||||
WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
|
WebGLForceSyncLoadAsset = options.WebGLForceSyncLoadAsset;
|
||||||
_bundleQuery = bundleServices;
|
_bundleQuery = bundleServices;
|
||||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||||
}
|
}
|
||||||
|
|||||||
34
Assets/YooAsset/Runtime/ResourcePackage/EPlayMode.cs
Normal file
34
Assets/YooAsset/Runtime/ResourcePackage/EPlayMode.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 运行模式
|
||||||
|
/// </summary>
|
||||||
|
public enum EPlayMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下的模拟模式
|
||||||
|
/// </summary>
|
||||||
|
EditorSimulateMode,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 离线运行模式
|
||||||
|
/// </summary>
|
||||||
|
OfflinePlayMode,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联机运行模式
|
||||||
|
/// </summary>
|
||||||
|
HostPlayMode,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WebGL运行模式
|
||||||
|
/// </summary>
|
||||||
|
WebPlayMode,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 自定义运行模式
|
||||||
|
/// </summary>
|
||||||
|
CustomPlayMode,
|
||||||
|
}
|
||||||
|
}
|
||||||
11
Assets/YooAsset/Runtime/ResourcePackage/EPlayMode.cs.meta
Normal file
11
Assets/YooAsset/Runtime/ResourcePackage/EPlayMode.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c870af6a4c0efe444af84f4c3ba8c2c9
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -14,25 +14,25 @@ namespace YooAsset
|
|||||||
void DestroyFileSystem();
|
void DestroyFileSystem();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求最新的资源版本
|
/// 请求最新的资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
RequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout);
|
RequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新清单
|
/// 请求并加载资源清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout);
|
LoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预下载指定版本的包裹内容
|
/// 预下载指定版本的包裹内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout);
|
PreDownloadContentOperation PreDownloadContentAsync(PreDownloadContentOptions options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
||||||
|
|
||||||
// 下载相关
|
// 下载相关
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain);
|
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain);
|
||||||
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain);
|
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain);
|
||||||
@@ -41,7 +41,7 @@ namespace YooAsset
|
|||||||
// 解压相关
|
// 解压相关
|
||||||
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain);
|
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain);
|
||||||
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain);
|
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain);
|
||||||
|
|
||||||
// 导入相关
|
// 导入相关
|
||||||
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain);
|
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain);
|
||||||
ResourceImporterOperation CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain);
|
ResourceImporterOperation CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain);
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public struct ClearCacheFilesOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理模式
|
||||||
|
/// </summary>
|
||||||
|
public string ClearMode { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 附加参数
|
||||||
|
/// </summary>
|
||||||
|
public object ClearParam { private set; get; }
|
||||||
|
|
||||||
|
public ClearCacheFilesOptions(EFileClearMode clearMode)
|
||||||
|
{
|
||||||
|
ClearMode = clearMode.ToString();
|
||||||
|
ClearParam = null;
|
||||||
|
}
|
||||||
|
public ClearCacheFilesOptions(EFileClearMode clearMode, object clearParam)
|
||||||
|
{
|
||||||
|
ClearMode = clearMode.ToString();
|
||||||
|
ClearParam = clearParam;
|
||||||
|
}
|
||||||
|
public ClearCacheFilesOptions(string clearMode, object clearParam)
|
||||||
|
{
|
||||||
|
ClearMode = clearMode;
|
||||||
|
ClearParam = clearParam;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4213bf1907101944b88f32ff19367b6f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class DestroyOperation : AsyncOperationBase
|
public class DestroyPackageOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -18,7 +18,7 @@ namespace YooAsset
|
|||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
public DestroyOperation(ResourcePackage resourcePackage, UnloadAllAssetsOptions options)
|
public DestroyPackageOperation(ResourcePackage resourcePackage, UnloadAllAssetsOptions options)
|
||||||
{
|
{
|
||||||
_resourcePackage = resourcePackage;
|
_resourcePackage = resourcePackage;
|
||||||
_options = options;
|
_options = options;
|
||||||
@@ -90,7 +90,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.DestroyPackage)
|
if (_steps == ESteps.DestroyPackage)
|
||||||
{
|
{
|
||||||
// 销毁包裹
|
// 销毁包裹
|
||||||
_resourcePackage.DestroyPackage();
|
_resourcePackage.InternalDestroy();
|
||||||
|
|
||||||
// 最后清理该包裹的异步任务
|
// 最后清理该包裹的异步任务
|
||||||
// 注意:对于有线程操作的异步任务,需要保证线程安全释放。
|
// 注意:对于有线程操作的异步任务,需要保证线程安全释放。
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public class InitializePackageOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private enum ESteps
|
||||||
|
{
|
||||||
|
None,
|
||||||
|
SetPlayMode,
|
||||||
|
CheckOptions,
|
||||||
|
CheckPlatform,
|
||||||
|
CreateCore,
|
||||||
|
InitFileSystem,
|
||||||
|
Done,
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly ResourcePackage _package;
|
||||||
|
private readonly InitializePackageOptions _options;
|
||||||
|
private PlayModeImpl _playModeImpl;
|
||||||
|
private InitializeFileSystemOperation _initializeFileSystemOp;
|
||||||
|
private EPlayMode _playMode;
|
||||||
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
internal InitializePackageOperation(ResourcePackage package, InitializePackageOptions options)
|
||||||
|
{
|
||||||
|
_package = package;
|
||||||
|
_options = options;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
_steps = ESteps.SetPlayMode;
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_steps == ESteps.SetPlayMode)
|
||||||
|
{
|
||||||
|
if (_options is EditorSimulateModeOptions)
|
||||||
|
_playMode = EPlayMode.EditorSimulateMode;
|
||||||
|
else if (_options is OfflinePlayModeOptions)
|
||||||
|
_playMode = EPlayMode.OfflinePlayMode;
|
||||||
|
else if (_options is HostPlayModeOptions)
|
||||||
|
_playMode = EPlayMode.HostPlayMode;
|
||||||
|
else if (_options is WebPlayModeOptions)
|
||||||
|
_playMode = EPlayMode.WebPlayMode;
|
||||||
|
else if (_options is CustomPlayModeOptions)
|
||||||
|
_playMode = EPlayMode.CustomPlayMode;
|
||||||
|
else
|
||||||
|
throw new NotImplementedException($"{_options.GetType().Name}");
|
||||||
|
|
||||||
|
_package._playMode = _playMode;
|
||||||
|
_steps = ESteps.CheckOptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckOptions)
|
||||||
|
{
|
||||||
|
// 检测初始化参数
|
||||||
|
if (_options.BundleLoadingMaxConcurrency <= 0)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"{nameof(_options.BundleLoadingMaxConcurrency)} value must be greater than zero.";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_steps = ESteps.CheckPlatform;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CheckPlatform)
|
||||||
|
{
|
||||||
|
#if !UNITY_EDITOR
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"Editor simulate mode only support unity editor.";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if UNITY_WEBGL
|
||||||
|
if (_playMode != EPlayMode.EditorSimulateMode)
|
||||||
|
{
|
||||||
|
if (_playMode != EPlayMode.WebPlayMode)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"{_playMode} can not support WebGL plateform !";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !UNITY_WEBGL
|
||||||
|
if (_playMode != EPlayMode.EditorSimulateMode)
|
||||||
|
{
|
||||||
|
if (_playMode == EPlayMode.WebPlayMode)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = $"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !";
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
_steps = ESteps.CreateCore;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.CreateCore)
|
||||||
|
{
|
||||||
|
string packageName = _package.PackageName;
|
||||||
|
var resourceManager = new ResourceManager(packageName);
|
||||||
|
var playModeImpl = new PlayModeImpl(packageName);
|
||||||
|
resourceManager.Initialize(_options, playModeImpl);
|
||||||
|
|
||||||
|
_playModeImpl = playModeImpl;
|
||||||
|
_package._bundleQuery = playModeImpl;
|
||||||
|
_package._playModeImpl = playModeImpl;
|
||||||
|
_package._resourceManager = resourceManager;
|
||||||
|
_steps = ESteps.InitFileSystem;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_steps == ESteps.InitFileSystem)
|
||||||
|
{
|
||||||
|
if (_initializeFileSystemOp == null)
|
||||||
|
{
|
||||||
|
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||||
|
{
|
||||||
|
var initializeParameters = _options as EditorSimulateModeOptions;
|
||||||
|
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.EditorFileSystemParameters);
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||||
|
{
|
||||||
|
var initializeParameters = _options as OfflinePlayModeOptions;
|
||||||
|
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.HostPlayMode)
|
||||||
|
{
|
||||||
|
var initializeParameters = _options as HostPlayModeOptions;
|
||||||
|
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.WebPlayMode)
|
||||||
|
{
|
||||||
|
var initializeParameters = _options as WebPlayModeOptions;
|
||||||
|
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
|
||||||
|
}
|
||||||
|
else if (_playMode == EPlayMode.CustomPlayMode)
|
||||||
|
{
|
||||||
|
var initializeParameters = _options as CustomPlayModeOptions;
|
||||||
|
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.FileSystemParameterList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new NotImplementedException(_playMode.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
_initializeFileSystemOp.StartOperation();
|
||||||
|
AddChildOperation(_initializeFileSystemOp);
|
||||||
|
}
|
||||||
|
|
||||||
|
_initializeFileSystemOp.UpdateOperation();
|
||||||
|
if (_initializeFileSystemOp.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (_initializeFileSystemOp.Status == EOperationStatus.Succeed)
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Succeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_steps = ESteps.Done;
|
||||||
|
Status = EOperationStatus.Failed;
|
||||||
|
Error = _initializeFileSystemOp.Error;
|
||||||
|
YooLogger.Error(Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
internal override string InternalGetDesc()
|
||||||
|
{
|
||||||
|
return $"PlayMode : {_playMode}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ecb6fb1cbab9e0242849d2657f438478
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -2,41 +2,10 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// 运行模式
|
|
||||||
/// </summary>
|
|
||||||
public enum EPlayMode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 编辑器下的模拟模式
|
|
||||||
/// </summary>
|
|
||||||
EditorSimulateMode,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 离线运行模式
|
|
||||||
/// </summary>
|
|
||||||
OfflinePlayMode,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 联机运行模式
|
|
||||||
/// </summary>
|
|
||||||
HostPlayMode,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// WebGL运行模式
|
|
||||||
/// </summary>
|
|
||||||
WebPlayMode,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 自定义运行模式
|
|
||||||
/// </summary>
|
|
||||||
CustomPlayMode,
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 初始化参数
|
/// 初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public abstract class InitializeParameters
|
public abstract class InitializePackageOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 同时加载Bundle文件的最大并发数
|
/// 同时加载Bundle文件的最大并发数
|
||||||
@@ -57,7 +26,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 编辑器下模拟运行模式的初始化参数
|
/// 编辑器下模拟运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class EditorSimulateModeParameters : InitializeParameters
|
public class EditorSimulateModeOptions : InitializePackageOptions
|
||||||
{
|
{
|
||||||
public FileSystemParameters EditorFileSystemParameters;
|
public FileSystemParameters EditorFileSystemParameters;
|
||||||
}
|
}
|
||||||
@@ -65,7 +34,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 离线运行模式的初始化参数
|
/// 离线运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class OfflinePlayModeParameters : InitializeParameters
|
public class OfflinePlayModeOptions : InitializePackageOptions
|
||||||
{
|
{
|
||||||
public FileSystemParameters BuildinFileSystemParameters;
|
public FileSystemParameters BuildinFileSystemParameters;
|
||||||
}
|
}
|
||||||
@@ -73,7 +42,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 联机运行模式的初始化参数
|
/// 联机运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class HostPlayModeParameters : InitializeParameters
|
public class HostPlayModeOptions : InitializePackageOptions
|
||||||
{
|
{
|
||||||
public FileSystemParameters BuildinFileSystemParameters;
|
public FileSystemParameters BuildinFileSystemParameters;
|
||||||
public FileSystemParameters CacheFileSystemParameters;
|
public FileSystemParameters CacheFileSystemParameters;
|
||||||
@@ -82,7 +51,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// WebGL运行模式的初始化参数
|
/// WebGL运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class WebPlayModeParameters : InitializeParameters
|
public class WebPlayModeOptions : InitializePackageOptions
|
||||||
{
|
{
|
||||||
public FileSystemParameters WebServerFileSystemParameters;
|
public FileSystemParameters WebServerFileSystemParameters;
|
||||||
public FileSystemParameters WebRemoteFileSystemParameters;
|
public FileSystemParameters WebRemoteFileSystemParameters;
|
||||||
@@ -91,7 +60,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自定义运行模式的初始化参数
|
/// 自定义运行模式的初始化参数
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class CustomPlayModeParameters : InitializeParameters
|
public class CustomPlayModeOptions : InitializePackageOptions
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 文件系统初始化参数列表
|
/// 文件系统初始化参数列表
|
||||||
@@ -3,13 +3,12 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public class InitializationOperation : AsyncOperationBase
|
public class InitializeFileSystemOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
None,
|
None,
|
||||||
Prepare,
|
Prepare,
|
||||||
ClearOldFileSystem,
|
|
||||||
InitFileSystem,
|
InitFileSystem,
|
||||||
CheckInitResult,
|
CheckInitResult,
|
||||||
Done,
|
Done,
|
||||||
@@ -20,8 +19,8 @@ namespace YooAsset
|
|||||||
private List<FileSystemParameters> _cloneList;
|
private List<FileSystemParameters> _cloneList;
|
||||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal InitializationOperation(PlayModeImpl impl, List<FileSystemParameters> parametersList)
|
internal InitializeFileSystemOperation(PlayModeImpl impl, List<FileSystemParameters> parametersList)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_parametersList = parametersList;
|
_parametersList = parametersList;
|
||||||
@@ -57,18 +56,6 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
_cloneList = _parametersList.ToList();
|
_cloneList = _parametersList.ToList();
|
||||||
_steps = ESteps.ClearOldFileSystem;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_steps == ESteps.ClearOldFileSystem)
|
|
||||||
{
|
|
||||||
// 注意:初始化失败后可能会残存一些旧的文件系统!
|
|
||||||
foreach (var fileSystem in _impl.FileSystems)
|
|
||||||
{
|
|
||||||
fileSystem.OnDestroy();
|
|
||||||
}
|
|
||||||
|
|
||||||
_impl.FileSystems.Clear();
|
|
||||||
_steps = ESteps.InitFileSystem;
|
_steps = ESteps.InitFileSystem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +108,5 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal override string InternalGetDesc()
|
|
||||||
{
|
|
||||||
return $"PlayMode : {_impl.PlayMode}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
{
|
{
|
||||||
public sealed class UpdatePackageManifestOperation : AsyncOperationBase
|
public sealed class LoadPackageManifestOperation : AsyncOperationBase
|
||||||
{
|
{
|
||||||
private enum ESteps
|
private enum ESteps
|
||||||
{
|
{
|
||||||
@@ -13,16 +13,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly PlayModeImpl _impl;
|
private readonly PlayModeImpl _impl;
|
||||||
private readonly string _packageVersion;
|
private readonly LoadPackageManifestOptions _options;
|
||||||
private readonly int _timeout;
|
|
||||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal UpdatePackageManifestOperation(PlayModeImpl impl, string packageVersion, int timeout)
|
internal LoadPackageManifestOperation(PlayModeImpl impl, LoadPackageManifestOptions options)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageVersion = packageVersion;
|
_options = options;
|
||||||
_timeout = timeout;
|
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
@@ -35,7 +33,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckParams)
|
if (_steps == ESteps.CheckParams)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageVersion))
|
if (string.IsNullOrEmpty(_options.PackageVersion))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
@@ -50,7 +48,7 @@ namespace YooAsset
|
|||||||
if (_steps == ESteps.CheckActiveManifest)
|
if (_steps == ESteps.CheckActiveManifest)
|
||||||
{
|
{
|
||||||
// 检测当前激活的清单对象
|
// 检测当前激活的清单对象
|
||||||
if (_impl.ActiveManifest != null && _impl.ActiveManifest.PackageVersion == _packageVersion)
|
if (_impl.ActiveManifest != null && _impl.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Succeed;
|
Status = EOperationStatus.Succeed;
|
||||||
@@ -66,7 +64,7 @@ namespace YooAsset
|
|||||||
if (_loadPackageManifestOp == null)
|
if (_loadPackageManifestOp == null)
|
||||||
{
|
{
|
||||||
var mainFileSystem = _impl.GetMainFileSystem();
|
var mainFileSystem = _impl.GetMainFileSystem();
|
||||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_options);
|
||||||
_loadPackageManifestOp.StartOperation();
|
_loadPackageManifestOp.StartOperation();
|
||||||
AddChildOperation(_loadPackageManifestOp);
|
AddChildOperation(_loadPackageManifestOp);
|
||||||
}
|
}
|
||||||
@@ -91,7 +89,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
internal override string InternalGetDesc()
|
internal override string InternalGetDesc()
|
||||||
{
|
{
|
||||||
return $"PackageVersion : {_packageVersion}";
|
return $"PackageVersion : {_options.PackageVersion}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public struct LoadPackageManifestOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 超时时间
|
||||||
|
/// </summary>
|
||||||
|
public int Timeout { private set; get; }
|
||||||
|
|
||||||
|
public LoadPackageManifestOptions(string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
PackageVersion = packageVersion;
|
||||||
|
Timeout = timeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 02958c7c4e947ae4b95472741e166cb6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -16,18 +16,17 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly PlayModeImpl _impl;
|
private readonly PlayModeImpl _impl;
|
||||||
private readonly string _packageVersion;
|
private readonly PreDownloadContentOptions _options;
|
||||||
private readonly int _timeout;
|
private readonly int _timeout;
|
||||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||||
private PackageManifest _manifest;
|
private PackageManifest _manifest;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
internal PreDownloadContentOperation(PlayModeImpl impl, string packageVersion, int timeout)
|
internal PreDownloadContentOperation(PlayModeImpl impl, PreDownloadContentOptions options)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_packageVersion = packageVersion;
|
_options = options;
|
||||||
_timeout = timeout;
|
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
@@ -40,7 +39,7 @@ namespace YooAsset
|
|||||||
|
|
||||||
if (_steps == ESteps.CheckParams)
|
if (_steps == ESteps.CheckParams)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_packageVersion))
|
if (string.IsNullOrEmpty(_options.PackageVersion))
|
||||||
{
|
{
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
Status = EOperationStatus.Failed;
|
Status = EOperationStatus.Failed;
|
||||||
@@ -56,7 +55,7 @@ namespace YooAsset
|
|||||||
// 检测当前激活的清单对象
|
// 检测当前激活的清单对象
|
||||||
if (_impl.ActiveManifest != null)
|
if (_impl.ActiveManifest != null)
|
||||||
{
|
{
|
||||||
if (_impl.ActiveManifest.PackageVersion == _packageVersion)
|
if (_impl.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||||
{
|
{
|
||||||
_manifest = _impl.ActiveManifest;
|
_manifest = _impl.ActiveManifest;
|
||||||
_steps = ESteps.Done;
|
_steps = ESteps.Done;
|
||||||
@@ -72,7 +71,8 @@ namespace YooAsset
|
|||||||
if (_loadPackageManifestOp == null)
|
if (_loadPackageManifestOp == null)
|
||||||
{
|
{
|
||||||
var mainFileSystem = _impl.GetMainFileSystem();
|
var mainFileSystem = _impl.GetMainFileSystem();
|
||||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_packageVersion, _timeout);
|
var options = new LoadPackageManifestOptions(_options.PackageVersion, _options.Timeout);
|
||||||
|
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(options);
|
||||||
_loadPackageManifestOp.StartOperation();
|
_loadPackageManifestOp.StartOperation();
|
||||||
AddChildOperation(_loadPackageManifestOp);
|
AddChildOperation(_loadPackageManifestOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public struct PreDownloadContentOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 预下载的包裹版本
|
||||||
|
/// </summary>
|
||||||
|
public string PackageVersion { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单请求超时时间
|
||||||
|
/// </summary>
|
||||||
|
public int Timeout { private set; get; }
|
||||||
|
|
||||||
|
public PreDownloadContentOptions(string packageVersion, int timeout)
|
||||||
|
{
|
||||||
|
PackageVersion = packageVersion;
|
||||||
|
Timeout = timeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e6ccb056c8ca90c49a01cc15aa75a513
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -18,16 +18,14 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly PlayModeImpl _impl;
|
private readonly PlayModeImpl _impl;
|
||||||
private readonly bool _appendTimeTicks;
|
private readonly RequestPackageVersionOptions _options;
|
||||||
private readonly int _timeout;
|
|
||||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
internal RequestPackageVersionImplOperation(PlayModeImpl impl, bool appendTimeTicks, int timeout)
|
internal RequestPackageVersionImplOperation(PlayModeImpl impl, RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
_impl = impl;
|
_impl = impl;
|
||||||
_appendTimeTicks = appendTimeTicks;
|
_options = options;
|
||||||
_timeout = timeout;
|
|
||||||
}
|
}
|
||||||
internal override void InternalStart()
|
internal override void InternalStart()
|
||||||
{
|
{
|
||||||
@@ -43,7 +41,7 @@ namespace YooAsset
|
|||||||
if (_requestPackageVersionOp == null)
|
if (_requestPackageVersionOp == null)
|
||||||
{
|
{
|
||||||
var mainFileSystem = _impl.GetMainFileSystem();
|
var mainFileSystem = _impl.GetMainFileSystem();
|
||||||
_requestPackageVersionOp = mainFileSystem.RequestPackageVersionAsync(_appendTimeTicks, _timeout);
|
_requestPackageVersionOp = mainFileSystem.RequestPackageVersionAsync(_options);
|
||||||
_requestPackageVersionOp.StartOperation();
|
_requestPackageVersionOp.StartOperation();
|
||||||
AddChildOperation(_requestPackageVersionOp);
|
AddChildOperation(_requestPackageVersionOp);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
|
||||||
|
namespace YooAsset
|
||||||
|
{
|
||||||
|
public struct RequestPackageVersionOptions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 在URL末尾添加时间戳
|
||||||
|
/// </summary>
|
||||||
|
public bool AppendTimeTicks { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 超时时间
|
||||||
|
/// </summary>
|
||||||
|
public int Timeout { private set; get; }
|
||||||
|
|
||||||
|
public RequestPackageVersionOptions(bool appendTimeTicks, int timeout)
|
||||||
|
{
|
||||||
|
AppendTimeTicks = appendTimeTicks;
|
||||||
|
Timeout = timeout;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e89594016c3fa69499adf8d642490ed6
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -7,19 +7,17 @@ namespace YooAsset
|
|||||||
internal class PlayModeImpl : IPlayMode, IBundleQuery
|
internal class PlayModeImpl : IPlayMode, IBundleQuery
|
||||||
{
|
{
|
||||||
public readonly string PackageName;
|
public readonly string PackageName;
|
||||||
public readonly EPlayMode PlayMode;
|
|
||||||
public readonly List<IFileSystem> FileSystems = new List<IFileSystem>(10);
|
public readonly List<IFileSystem> FileSystems = new List<IFileSystem>(10);
|
||||||
|
|
||||||
public PlayModeImpl(string packageName, EPlayMode playMode)
|
public PlayModeImpl(string packageName)
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
PlayMode = playMode;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(FileSystemParameters fileSystemParameter)
|
public InitializeFileSystemOperation InitializeAsync(FileSystemParameters fileSystemParameter)
|
||||||
{
|
{
|
||||||
var fileSystemParamList = new List<FileSystemParameters>();
|
var fileSystemParamList = new List<FileSystemParameters>();
|
||||||
if (fileSystemParameter != null)
|
if (fileSystemParameter != null)
|
||||||
@@ -30,7 +28,7 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(FileSystemParameters fileSystemParameterA, FileSystemParameters fileSystemParameterB)
|
public InitializeFileSystemOperation InitializeAsync(FileSystemParameters fileSystemParameterA, FileSystemParameters fileSystemParameterB)
|
||||||
{
|
{
|
||||||
var fileSystemParamList = new List<FileSystemParameters>();
|
var fileSystemParamList = new List<FileSystemParameters>();
|
||||||
if (fileSystemParameterA != null)
|
if (fileSystemParameterA != null)
|
||||||
@@ -43,9 +41,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步初始化
|
/// 异步初始化
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public InitializationOperation InitializeAsync(List<FileSystemParameters> fileSystemParameterList)
|
public InitializeFileSystemOperation InitializeAsync(List<FileSystemParameters> fileSystemParameterList)
|
||||||
{
|
{
|
||||||
var operation = new InitializationOperation(this, fileSystemParameterList);
|
var operation = new InitializeFileSystemOperation(this, fileSystemParameterList);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -70,27 +68,27 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求最新的资源版本
|
/// 向网络端请求最新的资源版本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
var operation = new RequestPackageVersionImplOperation(this, appendTimeTicks, timeout);
|
var operation = new RequestPackageVersionImplOperation(this, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 向网络端请求并更新清单
|
/// 向网络端请求并更新清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
LoadPackageManifestOperation IPlayMode.LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
{
|
{
|
||||||
var operation = new UpdatePackageManifestOperation(this, packageVersion, timeout);
|
var operation = new LoadPackageManifestOperation(this, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预下载指定版本的包裹内容
|
/// 预下载指定版本的包裹内容
|
||||||
/// </summary>
|
/// </summary>
|
||||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(PreDownloadContentOptions options)
|
||||||
{
|
{
|
||||||
var operation = new PreDownloadContentOperation(this, packageVersion, timeout);
|
var operation = new PreDownloadContentOperation(this, options);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,11 @@ namespace YooAsset
|
|||||||
{
|
{
|
||||||
public class ResourcePackage
|
public class ResourcePackage
|
||||||
{
|
{
|
||||||
private bool _isInitialize = false;
|
private InitializePackageOperation _initializeOp;
|
||||||
private string _initializeError = string.Empty;
|
internal ResourceManager _resourceManager;
|
||||||
private EOperationStatus _initializeStatus = EOperationStatus.None;
|
internal IBundleQuery _bundleQuery;
|
||||||
private EPlayMode _playMode;
|
internal IPlayMode _playModeImpl;
|
||||||
|
internal EPlayMode _playMode;
|
||||||
// 管理器
|
|
||||||
private ResourceManager _resourceManager;
|
|
||||||
private IBundleQuery _bundleQuery;
|
|
||||||
private IPlayMode _playModeImpl;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名
|
/// 包裹名
|
||||||
@@ -28,7 +24,12 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public EOperationStatus InitializeStatus
|
public EOperationStatus InitializeStatus
|
||||||
{
|
{
|
||||||
get { return _initializeStatus; }
|
get
|
||||||
|
{
|
||||||
|
if (_initializeOp == null)
|
||||||
|
return EOperationStatus.None;
|
||||||
|
return _initializeOp.Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -52,7 +53,7 @@ namespace YooAsset
|
|||||||
get { return OperationSystem.GetSchedulerPriority(PackageName); }
|
get { return OperationSystem.GetSchedulerPriority(PackageName); }
|
||||||
set { OperationSystem.SetSchedulerPriority(PackageName, value); }
|
set { OperationSystem.SetSchedulerPriority(PackageName, value); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
internal ResourcePackage(string packageName)
|
internal ResourcePackage(string packageName)
|
||||||
{
|
{
|
||||||
@@ -62,40 +63,10 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 销毁资源包裹
|
/// 销毁资源包裹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal void DestroyPackage()
|
internal void InternalDestroy()
|
||||||
{
|
{
|
||||||
if (_isInitialize)
|
_initializeOp = null;
|
||||||
{
|
_bundleQuery = null;
|
||||||
_isInitialize = false;
|
|
||||||
_initializeError = string.Empty;
|
|
||||||
_initializeStatus = EOperationStatus.None;
|
|
||||||
|
|
||||||
// 销毁资源管理器
|
|
||||||
if (_resourceManager != null)
|
|
||||||
{
|
|
||||||
_resourceManager.Destroy();
|
|
||||||
_resourceManager = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 销毁文件系统
|
|
||||||
if (_playModeImpl != null)
|
|
||||||
_playModeImpl.DestroyFileSystem();
|
|
||||||
|
|
||||||
_bundleQuery = null;
|
|
||||||
_playModeImpl = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 异步初始化
|
|
||||||
/// </summary>
|
|
||||||
public InitializationOperation InitializeAsync(InitializeParameters parameters)
|
|
||||||
{
|
|
||||||
// 注意:联机平台因为网络原因可能会初始化失败!
|
|
||||||
ResetInitializeAfterFailed();
|
|
||||||
|
|
||||||
// 检测初始化参数合法性
|
|
||||||
CheckInitializeParameters(parameters);
|
|
||||||
|
|
||||||
// 销毁资源管理器
|
// 销毁资源管理器
|
||||||
if (_resourceManager != null)
|
if (_resourceManager != null)
|
||||||
@@ -104,147 +75,75 @@ namespace YooAsset
|
|||||||
_resourceManager = null;
|
_resourceManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建资源管理器
|
// 销毁文件系统
|
||||||
_resourceManager = new ResourceManager(PackageName);
|
if (_playModeImpl != null)
|
||||||
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
|
|
||||||
_bundleQuery = playModeImpl;
|
|
||||||
_playModeImpl = playModeImpl;
|
|
||||||
_resourceManager.Initialize(parameters, _bundleQuery);
|
|
||||||
|
|
||||||
// 初始化资源系统
|
|
||||||
InitializationOperation initializeOperation;
|
|
||||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
|
||||||
{
|
{
|
||||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
_playModeImpl.DestroyFileSystem();
|
||||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.EditorFileSystemParameters);
|
_playModeImpl = null;
|
||||||
}
|
}
|
||||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
|
||||||
{
|
|
||||||
var initializeParameters = parameters as OfflinePlayModeParameters;
|
|
||||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.HostPlayMode)
|
|
||||||
{
|
|
||||||
var initializeParameters = parameters as HostPlayModeParameters;
|
|
||||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.WebPlayMode)
|
|
||||||
{
|
|
||||||
var initializeParameters = parameters as WebPlayModeParameters;
|
|
||||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
|
|
||||||
}
|
|
||||||
else if (_playMode == EPlayMode.CustomPlayMode)
|
|
||||||
{
|
|
||||||
var initializeParameters = parameters as CustomPlayModeParameters;
|
|
||||||
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.FileSystemParameterList);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 监听初始化结果
|
|
||||||
_isInitialize = true;
|
|
||||||
OperationSystem.StartOperation(PackageName, initializeOperation);
|
|
||||||
initializeOperation.Completed += InitializeOperation_Completed;
|
|
||||||
return initializeOperation;
|
|
||||||
}
|
|
||||||
private void ResetInitializeAfterFailed()
|
|
||||||
{
|
|
||||||
if (_isInitialize && _initializeStatus == EOperationStatus.Failed)
|
|
||||||
{
|
|
||||||
_isInitialize = false;
|
|
||||||
_initializeStatus = EOperationStatus.None;
|
|
||||||
_initializeError = string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void CheckInitializeParameters(InitializeParameters parameters)
|
|
||||||
{
|
|
||||||
if (_isInitialize)
|
|
||||||
throw new YooPackageException(PackageName, $"Package '{PackageName}' is already initialized !");
|
|
||||||
|
|
||||||
if (parameters == null)
|
|
||||||
throw new YooPackageException(PackageName, $"Initialize parameters cannot be null.");
|
|
||||||
|
|
||||||
#if !UNITY_EDITOR
|
|
||||||
if (parameters is EditorSimulateModeParameters)
|
|
||||||
throw new YooPlatformNotSupportedException($"Editor simulate mode only support unity editor.");
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 检测初始化参数
|
|
||||||
if (parameters.BundleLoadingMaxConcurrency <= 0)
|
|
||||||
throw new YooPackageException(PackageName, $"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
|
|
||||||
|
|
||||||
// 鉴定运行模式
|
|
||||||
if (parameters is EditorSimulateModeParameters)
|
|
||||||
_playMode = EPlayMode.EditorSimulateMode;
|
|
||||||
else if (parameters is OfflinePlayModeParameters)
|
|
||||||
_playMode = EPlayMode.OfflinePlayMode;
|
|
||||||
else if (parameters is HostPlayModeParameters)
|
|
||||||
_playMode = EPlayMode.HostPlayMode;
|
|
||||||
else if (parameters is WebPlayModeParameters)
|
|
||||||
_playMode = EPlayMode.WebPlayMode;
|
|
||||||
else if (parameters is CustomPlayModeParameters)
|
|
||||||
_playMode = EPlayMode.CustomPlayMode;
|
|
||||||
else
|
|
||||||
throw new NotImplementedException();
|
|
||||||
|
|
||||||
// 检测运行时平台
|
|
||||||
if (_playMode != EPlayMode.EditorSimulateMode)
|
|
||||||
{
|
|
||||||
#if UNITY_WEBGL
|
|
||||||
if (_playMode != EPlayMode.WebPlayMode)
|
|
||||||
{
|
|
||||||
throw new YooPlatformNotSupportedException($"{_playMode} can not support WebGL plateform !");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
if (_playMode == EPlayMode.WebPlayMode)
|
|
||||||
{
|
|
||||||
throw new YooPlatformNotSupportedException($"{nameof(EPlayMode.WebPlayMode)} only support WebGL plateform !");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void InitializeOperation_Completed(AsyncOperationBase op)
|
|
||||||
{
|
|
||||||
_initializeStatus = op.Status;
|
|
||||||
_initializeError = op.Error;
|
|
||||||
if (_initializeStatus != EOperationStatus.Succeed)
|
|
||||||
YooLogger.Error(_initializeError);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 异步销毁
|
/// 异步初始化包裹
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DestroyOperation DestroyAsync()
|
public InitializePackageOperation InitializePackageAsync(InitializePackageOptions options)
|
||||||
{
|
{
|
||||||
var options = new UnloadAllAssetsOptions();
|
// 注意:联机平台因为网络原因可能会初始化失败!
|
||||||
options.ReleaseAllHandles = true;
|
ResetInitializeAfterFailed();
|
||||||
options.LockLoadOperation = true;
|
|
||||||
var operation = new DestroyOperation(this, options);
|
// 检测重复初始化
|
||||||
|
if (_initializeOp != null)
|
||||||
|
throw new YooPackageException(PackageName, $"Package '{PackageName}' is already initialized !");
|
||||||
|
|
||||||
|
// 开始初始化操作
|
||||||
|
_initializeOp = new InitializePackageOperation(this, options);
|
||||||
|
OperationSystem.StartOperation(PackageName, _initializeOp);
|
||||||
|
return _initializeOp;
|
||||||
|
}
|
||||||
|
private void ResetInitializeAfterFailed()
|
||||||
|
{
|
||||||
|
if (InitializeStatus == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
InternalDestroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步销毁包裹
|
||||||
|
/// </summary>
|
||||||
|
public DestroyPackageOperation DestroyPackageAsync()
|
||||||
|
{
|
||||||
|
var options = new UnloadAllAssetsOptions(true, true);
|
||||||
|
var operation = new DestroyPackageOperation(this, options);
|
||||||
OperationSystem.StartOperation(OperationSystem.GLOBAL_SCHEDULER_NAME, operation);
|
OperationSystem.StartOperation(OperationSystem.GLOBAL_SCHEDULER_NAME, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求最新的资源版本
|
/// 请求最新的资源版本
|
||||||
|
/// 说明:超时时间默认60秒
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
|
public RequestPackageVersionOperation RequestPackageVersionAsync()
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
{
|
||||||
public RequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
|
var options = new RequestPackageVersionOptions(true, 60);
|
||||||
|
return RequestPackageVersionAsync(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 请求最新的资源版本
|
||||||
|
/// </summary>
|
||||||
|
public RequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.RequestPackageVersionAsync(appendTimeTicks, timeout);
|
var operation = _playModeImpl.RequestPackageVersionAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 更新并加载指定版本的资源清单
|
/// 加载指定版本的资源清单
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">包裹版本</param>
|
public LoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
|
||||||
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
|
|
||||||
@@ -254,7 +153,7 @@ namespace YooAsset
|
|||||||
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle !");
|
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle !");
|
||||||
}
|
}
|
||||||
|
|
||||||
var operation = _playModeImpl.UpdatePackageManifestAsync(packageVersion, timeout);
|
var operation = _playModeImpl.LoadPackageManifestAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -262,12 +161,10 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 预下载指定版本的包裹资源
|
/// 预下载指定版本的包裹资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packageVersion">包裹版本</param>
|
public PreDownloadContentOperation PreDownloadContentAsync(PreDownloadContentOptions options)
|
||||||
/// <param name="timeout">资源清单下载的超时时间(默认值:60秒)</param>
|
|
||||||
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
var operation = _playModeImpl.PreDownloadContentAsync(packageVersion, timeout);
|
var operation = _playModeImpl.PreDownloadContentAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
}
|
}
|
||||||
@@ -275,30 +172,9 @@ namespace YooAsset
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 清理缓存文件
|
/// 清理缓存文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="clearMode">清理方式</param>
|
public ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||||
/// <param name="clearParam">执行参数</param>
|
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
|
||||||
{
|
{
|
||||||
DebugCheckInitialize(false);
|
DebugCheckInitialize(false);
|
||||||
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
|
||||||
options.ClearMode = clearMode.ToString();
|
|
||||||
options.ClearParam = clearParam;
|
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 清理缓存文件
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="clearMode">清理方式</param>
|
|
||||||
/// <param name="clearParam">执行参数</param>
|
|
||||||
public ClearCacheFilesOperation ClearCacheFilesAsync(string clearMode, object clearParam = null)
|
|
||||||
{
|
|
||||||
DebugCheckInitialize(false);
|
|
||||||
ClearCacheFilesOptions options = new ClearCacheFilesOptions();
|
|
||||||
options.ClearMode = clearMode;
|
|
||||||
options.ClearParam = clearParam;
|
|
||||||
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||||
OperationSystem.StartOperation(PackageName, operation);
|
OperationSystem.StartOperation(PackageName, operation);
|
||||||
return operation;
|
return operation;
|
||||||
@@ -1165,10 +1041,22 @@ namespace YooAsset
|
|||||||
#region 调试方法
|
#region 调试方法
|
||||||
private void DebugCheckInitialize(bool checkActiveManifest = true)
|
private void DebugCheckInitialize(bool checkActiveManifest = true)
|
||||||
{
|
{
|
||||||
if (_initializeStatus == EOperationStatus.None)
|
if (InitializeStatus != EOperationStatus.Succeed)
|
||||||
throw new YooPackageException(PackageName, "Package initialize not completed !");
|
{
|
||||||
else if (_initializeStatus == EOperationStatus.Failed)
|
if (InitializeStatus == EOperationStatus.None)
|
||||||
throw new YooPackageException(PackageName, $"Package initialize failed ! {_initializeError}");
|
{
|
||||||
|
throw new YooPackageException(PackageName, "Package not initialize !");
|
||||||
|
}
|
||||||
|
else if (InitializeStatus == EOperationStatus.Processing)
|
||||||
|
{
|
||||||
|
throw new YooPackageException(PackageName, "Package initialize not completed !");
|
||||||
|
}
|
||||||
|
else if (InitializeStatus == EOperationStatus.Failed)
|
||||||
|
{
|
||||||
|
string error = _initializeOp == null ? string.Empty : _initializeOp.Error;
|
||||||
|
throw new YooPackageException(PackageName, $"Package initialize failed ! {error}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (checkActiveManifest)
|
if (checkActiveManifest)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ namespace YooAsset
|
|||||||
string packageName = package.PackageName;
|
string packageName = package.PackageName;
|
||||||
if (package.InitializeStatus != EOperationStatus.None)
|
if (package.InitializeStatus != EOperationStatus.None)
|
||||||
{
|
{
|
||||||
YooLogger.Error($"The resource package {packageName} has not been destroyed, please call the method {nameof(ResourcePackage.DestroyAsync)} to destroy!");
|
YooLogger.Error($"The resource package {packageName} has not been destroyed, please call the method {nameof(ResourcePackage.DestroyPackageAsync)} to destroy!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,274 @@
|
|||||||
|
using YooAsset;
|
||||||
|
|
||||||
|
#region InitializeParameters
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化参数
|
||||||
|
/// </summary>
|
||||||
|
public abstract class InitializeParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 同时加载Bundle文件的最大并发数
|
||||||
|
/// </summary>
|
||||||
|
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当资源引用计数为零的时候自动释放资源包
|
||||||
|
/// </summary>
|
||||||
|
public bool AutoUnloadBundleWhenUnused = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WebGL平台强制同步加载资源对象
|
||||||
|
/// </summary>
|
||||||
|
public bool WebGLForceSyncLoadAsset = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下模拟运行模式的初始化参数
|
||||||
|
/// </summary>
|
||||||
|
public class EditorSimulateModeParameters : InitializeParameters
|
||||||
|
{
|
||||||
|
public FileSystemParameters EditorFileSystemParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 离线运行模式的初始化参数
|
||||||
|
/// </summary>
|
||||||
|
public class OfflinePlayModeParameters : InitializeParameters
|
||||||
|
{
|
||||||
|
public FileSystemParameters BuildinFileSystemParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 联机运行模式的初始化参数
|
||||||
|
/// </summary>
|
||||||
|
public class HostPlayModeParameters : InitializeParameters
|
||||||
|
{
|
||||||
|
public FileSystemParameters BuildinFileSystemParameters;
|
||||||
|
public FileSystemParameters CacheFileSystemParameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// WebGL运行模式的初始化参数
|
||||||
|
/// </summary>
|
||||||
|
public class WebPlayModeParameters : InitializeParameters
|
||||||
|
{
|
||||||
|
public FileSystemParameters WebServerFileSystemParameters;
|
||||||
|
public FileSystemParameters WebRemoteFileSystemParameters;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region InitializationOperation
|
||||||
|
public class InitializationOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private bool _isDone = false;
|
||||||
|
private readonly InitializePackageOperation _operation;
|
||||||
|
|
||||||
|
internal InitializationOperation(InitializePackageOperation op)
|
||||||
|
{
|
||||||
|
_operation = op;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_isDone)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_operation.UpdateOperation();
|
||||||
|
if (_operation.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isDone = true;
|
||||||
|
Status = _operation.Status;
|
||||||
|
Error = _operation.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region DestroyOperation
|
||||||
|
public class DestroyOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private bool _isDone = false;
|
||||||
|
private readonly DestroyPackageOperation _operation;
|
||||||
|
|
||||||
|
internal DestroyOperation(DestroyPackageOperation op)
|
||||||
|
{
|
||||||
|
_operation = op;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_isDone)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_operation.UpdateOperation();
|
||||||
|
if (_operation.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isDone = true;
|
||||||
|
Status = _operation.Status;
|
||||||
|
Error = _operation.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region UpdatePackageManifestOperation
|
||||||
|
public class UpdatePackageManifestOperation : AsyncOperationBase
|
||||||
|
{
|
||||||
|
private bool _isDone = false;
|
||||||
|
private readonly LoadPackageManifestOperation _operation;
|
||||||
|
|
||||||
|
internal UpdatePackageManifestOperation(LoadPackageManifestOperation op)
|
||||||
|
{
|
||||||
|
_operation = op;
|
||||||
|
}
|
||||||
|
internal override void InternalStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
internal override void InternalUpdate()
|
||||||
|
{
|
||||||
|
if (_isDone)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_operation.UpdateOperation();
|
||||||
|
if (_operation.IsDone == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_isDone = true;
|
||||||
|
Status = _operation.Status;
|
||||||
|
Error = _operation.Error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public static class CompatibleOldVersion
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static InitializationOperation InitializeAsync(this ResourcePackage package, InitializeParameters parameters)
|
||||||
|
{
|
||||||
|
if (parameters is EditorSimulateModeParameters)
|
||||||
|
{
|
||||||
|
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||||
|
var options = new EditorSimulateModeOptions();
|
||||||
|
options.BundleLoadingMaxConcurrency = initializeParameters.BundleLoadingMaxConcurrency;
|
||||||
|
options.AutoUnloadBundleWhenUnused = initializeParameters.AutoUnloadBundleWhenUnused;
|
||||||
|
options.WebGLForceSyncLoadAsset = initializeParameters.WebGLForceSyncLoadAsset;
|
||||||
|
options.EditorFileSystemParameters = initializeParameters.EditorFileSystemParameters;
|
||||||
|
var operation = package.InitializePackageAsync(options);
|
||||||
|
var wrapper = new InitializationOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
else if (parameters is OfflinePlayModeParameters)
|
||||||
|
{
|
||||||
|
var initializeParameters = parameters as OfflinePlayModeParameters;
|
||||||
|
var options = new OfflinePlayModeOptions();
|
||||||
|
options.BundleLoadingMaxConcurrency = initializeParameters.BundleLoadingMaxConcurrency;
|
||||||
|
options.AutoUnloadBundleWhenUnused = initializeParameters.AutoUnloadBundleWhenUnused;
|
||||||
|
options.WebGLForceSyncLoadAsset = initializeParameters.WebGLForceSyncLoadAsset;
|
||||||
|
options.BuildinFileSystemParameters = initializeParameters.BuildinFileSystemParameters;
|
||||||
|
var operation = package.InitializePackageAsync(options);
|
||||||
|
var wrapper = new InitializationOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
else if (parameters is HostPlayModeParameters)
|
||||||
|
{
|
||||||
|
var initializeParameters = parameters as HostPlayModeParameters;
|
||||||
|
var options = new HostPlayModeOptions();
|
||||||
|
options.BundleLoadingMaxConcurrency = initializeParameters.BundleLoadingMaxConcurrency;
|
||||||
|
options.AutoUnloadBundleWhenUnused = initializeParameters.AutoUnloadBundleWhenUnused;
|
||||||
|
options.WebGLForceSyncLoadAsset = initializeParameters.WebGLForceSyncLoadAsset;
|
||||||
|
options.BuildinFileSystemParameters = initializeParameters.BuildinFileSystemParameters;
|
||||||
|
options.CacheFileSystemParameters = initializeParameters.CacheFileSystemParameters;
|
||||||
|
var operation = package.InitializePackageAsync(options);
|
||||||
|
var wrapper = new InitializationOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
else if (parameters is WebPlayModeParameters)
|
||||||
|
{
|
||||||
|
var initializeParameters = parameters as WebPlayModeParameters;
|
||||||
|
var options = new WebPlayModeOptions();
|
||||||
|
options.BundleLoadingMaxConcurrency = initializeParameters.BundleLoadingMaxConcurrency;
|
||||||
|
options.AutoUnloadBundleWhenUnused = initializeParameters.AutoUnloadBundleWhenUnused;
|
||||||
|
options.WebGLForceSyncLoadAsset = initializeParameters.WebGLForceSyncLoadAsset;
|
||||||
|
options.WebServerFileSystemParameters = initializeParameters.WebServerFileSystemParameters;
|
||||||
|
options.WebRemoteFileSystemParameters = initializeParameters.WebRemoteFileSystemParameters;
|
||||||
|
var operation = package.InitializePackageAsync(options);
|
||||||
|
var wrapper = new InitializationOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new System.NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static DestroyOperation DestroyAsync(this ResourcePackage package)
|
||||||
|
{
|
||||||
|
var operation = package.DestroyPackageAsync();
|
||||||
|
var wrapper = new DestroyOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static RequestPackageVersionOperation RequestPackageVersionAsync(this ResourcePackage package, bool appendTimeTicks = true, int timeout = 60)
|
||||||
|
{
|
||||||
|
var options = new RequestPackageVersionOptions(appendTimeTicks, timeout);
|
||||||
|
var operation = package.RequestPackageVersionAsync(options);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static UpdatePackageManifestOperation UpdatePackageManifestAsync(this ResourcePackage package, string packageVersion, int timeout = 60)
|
||||||
|
{
|
||||||
|
var options = new LoadPackageManifestOptions(packageVersion, timeout);
|
||||||
|
var operation = package.LoadPackageManifestAsync(options);
|
||||||
|
var wrapper = new UpdatePackageManifestOperation(operation);
|
||||||
|
OperationSystem.StartOperation(package.PackageName, wrapper);
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static PreDownloadContentOperation PreDownloadContentAsync(this ResourcePackage package, string packageVersion, int timeout = 60)
|
||||||
|
{
|
||||||
|
var options = new PreDownloadContentOptions(packageVersion, timeout);
|
||||||
|
var operation = package.PreDownloadContentAsync(options);
|
||||||
|
return operation;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static ClearCacheFilesOperation ClearCacheFilesAsync(this ResourcePackage package, EFileClearMode fileClearMode, object clearParam = null)
|
||||||
|
{
|
||||||
|
var options = new ClearCacheFilesOptions(fileClearMode, clearParam);
|
||||||
|
return package.ClearCacheFilesAsync(options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 兼容Yoo2版本
|
||||||
|
/// </summary>
|
||||||
|
public static ClearCacheFilesOperation ClearCacheFilesAsync(this ResourcePackage package, string fileClearMode, object clearParam = null)
|
||||||
|
{
|
||||||
|
var options = new ClearCacheFilesOptions(fileClearMode, clearParam);
|
||||||
|
return package.ClearCacheFilesAsync(options);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b974d3d744622f3499d026f99074cd72
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -22,7 +22,8 @@ namespace YooAsset
|
|||||||
|
|
||||||
// 请求资源版本
|
// 请求资源版本
|
||||||
Debug.Log("请求资源版本信息!");
|
Debug.Log("请求资源版本信息!");
|
||||||
var requestPackageVersionOp = fileSystem.RequestPackageVersionAsync(true, 60);
|
var requestPackageVersionOptions = new RequestPackageVersionOptions(true, 60);
|
||||||
|
var requestPackageVersionOp = fileSystem.RequestPackageVersionAsync(requestPackageVersionOptions);
|
||||||
OperationSystem.StartOperation(packageName, requestPackageVersionOp);
|
OperationSystem.StartOperation(packageName, requestPackageVersionOp);
|
||||||
yield return requestPackageVersionOp;
|
yield return requestPackageVersionOp;
|
||||||
if (requestPackageVersionOp.Status != EOperationStatus.Succeed)
|
if (requestPackageVersionOp.Status != EOperationStatus.Succeed)
|
||||||
@@ -34,7 +35,8 @@ namespace YooAsset
|
|||||||
// 请求资源清单
|
// 请求资源清单
|
||||||
string packageVersion = requestPackageVersionOp.PackageVersion;
|
string packageVersion = requestPackageVersionOp.PackageVersion;
|
||||||
Debug.Log($"加载资源清单文件!{packageVersion}");
|
Debug.Log($"加载资源清单文件!{packageVersion}");
|
||||||
var loadPackageManifestOp = fileSystem.LoadPackageManifestAsync(packageVersion, 60);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(packageVersion, 60);
|
||||||
|
var loadPackageManifestOp = fileSystem.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
OperationSystem.StartOperation(packageName, loadPackageManifestOp);
|
OperationSystem.StartOperation(packageName, loadPackageManifestOp);
|
||||||
yield return loadPackageManifestOp;
|
yield return loadPackageManifestOp;
|
||||||
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
|
|||||||
@@ -59,9 +59,9 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new EditorSimulateModeParameters();
|
var initParams = new EditorSimulateModeOptions();
|
||||||
initParams.EditorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
initParams.EditorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializePackageAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(initializeOp.Error);
|
Debug.LogError(initializeOp.Error);
|
||||||
@@ -75,11 +75,12 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||||
|
|
||||||
// 更新资源清单
|
// 更新资源清单
|
||||||
var updateManifestOp = package.UpdatePackageManifestAsync(requetVersionOp.PackageVersion);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(requetVersionOp.PackageVersion, 60);
|
||||||
yield return updateManifestOp;
|
var loadPackageManifestOp = package.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
if (updateManifestOp.Status != EOperationStatus.Succeed)
|
yield return loadPackageManifestOp;
|
||||||
Debug.LogError(updateManifestOp.Error);
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
|
Debug.LogError(loadPackageManifestOp.Error);
|
||||||
|
Assert.AreEqual(EOperationStatus.Succeed, loadPackageManifestOp.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化资源包 RAW_BUNDLE
|
// 初始化资源包 RAW_BUNDLE
|
||||||
@@ -94,9 +95,9 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var package = YooAssets.CreatePackage(TestDefine.RawBundlePackageName);
|
var package = YooAssets.CreatePackage(TestDefine.RawBundlePackageName);
|
||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new EditorSimulateModeParameters();
|
var initParams = new EditorSimulateModeOptions();
|
||||||
initParams.EditorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
initParams.EditorFileSystemParameters = FileSystemParameters.CreateDefaultEditorFileSystemParameters(packageRoot);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializePackageAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(initializeOp.Error);
|
Debug.LogError(initializeOp.Error);
|
||||||
@@ -110,11 +111,12 @@ public class T1_TestEditorFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||||
|
|
||||||
// 更新资源清单
|
// 更新资源清单
|
||||||
var updateManifestOp = package.UpdatePackageManifestAsync(requetVersionOp.PackageVersion);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(requetVersionOp.PackageVersion, 60);
|
||||||
yield return updateManifestOp;
|
var loadPackageManifestOp = package.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
if (updateManifestOp.Status != EOperationStatus.Succeed)
|
yield return loadPackageManifestOp;
|
||||||
Debug.LogError(updateManifestOp.Error);
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
|
Debug.LogError(loadPackageManifestOp.Error);
|
||||||
|
Assert.AreEqual(EOperationStatus.Succeed, loadPackageManifestOp.Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new OfflinePlayModeParameters();
|
var initParams = new OfflinePlayModeOptions();
|
||||||
var fileDecryption = new TestFileStreamDecryption();
|
var fileDecryption = new TestFileStreamDecryption();
|
||||||
var manifestServices = new TestRestoreManifest();
|
var manifestServices = new TestRestoreManifest();
|
||||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(fileDecryption, packageRoot);
|
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(fileDecryption, packageRoot);
|
||||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializePackageAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(initializeOp.Error);
|
Debug.LogError(initializeOp.Error);
|
||||||
@@ -79,11 +79,12 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||||
|
|
||||||
// 更新资源清单
|
// 更新资源清单
|
||||||
var updateManifestOp = package.UpdatePackageManifestAsync(requetVersionOp.PackageVersion);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(requetVersionOp.PackageVersion, 60);
|
||||||
yield return updateManifestOp;
|
var loadPackageManifestOp = package.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
if (updateManifestOp.Status != EOperationStatus.Succeed)
|
yield return loadPackageManifestOp;
|
||||||
Debug.LogError(updateManifestOp.Error);
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
|
Debug.LogError(loadPackageManifestOp.Error);
|
||||||
|
Assert.AreEqual(EOperationStatus.Succeed, loadPackageManifestOp.Status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化资源包 RAW_BUNDLE
|
// 初始化资源包 RAW_BUNDLE
|
||||||
@@ -98,11 +99,11 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var package = YooAssets.CreatePackage(TestDefine.RawBundlePackageName);
|
var package = YooAssets.CreatePackage(TestDefine.RawBundlePackageName);
|
||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new OfflinePlayModeParameters();
|
var initParams = new OfflinePlayModeOptions();
|
||||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(null, packageRoot);
|
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(null, packageRoot);
|
||||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, true);
|
||||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializePackageAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(initializeOp.Error);
|
Debug.LogError(initializeOp.Error);
|
||||||
@@ -116,11 +117,12 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||||
|
|
||||||
// 更新资源清单
|
// 更新资源清单
|
||||||
var updateManifestOp = package.UpdatePackageManifestAsync(requetVersionOp.PackageVersion);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(requetVersionOp.PackageVersion, 60);
|
||||||
yield return updateManifestOp;
|
var loadPackageManifestOp = package.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
if (updateManifestOp.Status != EOperationStatus.Succeed)
|
yield return loadPackageManifestOp;
|
||||||
Debug.LogError(updateManifestOp.Error);
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
|
Debug.LogError(loadPackageManifestOp.Error);
|
||||||
|
Assert.AreEqual(EOperationStatus.Succeed, loadPackageManifestOp.Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
var package = YooAssets.CreatePackage(TestDefine.AssetBundlePackageName);
|
||||||
|
|
||||||
// 初始化资源包
|
// 初始化资源包
|
||||||
var initParams = new HostPlayModeParameters();
|
var initParams = new HostPlayModeOptions();
|
||||||
var fileDecryption = new TestFileStreamDecryption();
|
var fileDecryption = new TestFileStreamDecryption();
|
||||||
var manifestServices = new TestRestoreManifest();
|
var manifestServices = new TestRestoreManifest();
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
initParams.BuildinFileSystemParameters = null;
|
initParams.BuildinFileSystemParameters = null;
|
||||||
initParams.CacheFileSystemParameters = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices, fileDecryption);
|
initParams.CacheFileSystemParameters = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices, fileDecryption);
|
||||||
initParams.CacheFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
initParams.CacheFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
||||||
var initializeOp = package.InitializeAsync(initParams);
|
var initializeOp = package.InitializePackageAsync(initParams);
|
||||||
yield return initializeOp;
|
yield return initializeOp;
|
||||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(initializeOp.Error);
|
Debug.LogError(initializeOp.Error);
|
||||||
@@ -67,11 +67,12 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
|||||||
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, requetVersionOp.Status);
|
||||||
|
|
||||||
// 更新资源清单
|
// 更新资源清单
|
||||||
var updateManifestOp = package.UpdatePackageManifestAsync(requetVersionOp.PackageVersion);
|
var loadPackageManifestOptions = new LoadPackageManifestOptions(requetVersionOp.PackageVersion, 60);
|
||||||
yield return updateManifestOp;
|
var loadPackageManifestOp = package.LoadPackageManifestAsync(loadPackageManifestOptions);
|
||||||
if (updateManifestOp.Status != EOperationStatus.Succeed)
|
yield return loadPackageManifestOp;
|
||||||
Debug.LogError(updateManifestOp.Error);
|
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, updateManifestOp.Status);
|
Debug.LogError(loadPackageManifestOp.Error);
|
||||||
|
Assert.AreEqual(EOperationStatus.Succeed, loadPackageManifestOp.Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private class TestRemoteServices : IRemoteServices
|
private class TestRemoteServices : IRemoteServices
|
||||||
|
|||||||
@@ -36,9 +36,9 @@ public class TestBundlePlaying
|
|||||||
{
|
{
|
||||||
// 验证失败结果
|
// 验证失败结果
|
||||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
||||||
var assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
var assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||||
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
|
||||||
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
||||||
|
Assert.AreEqual(EOperationStatus.Failed, assetsHandle.Status);
|
||||||
|
|
||||||
// 清理加载器
|
// 清理加载器
|
||||||
assetsHandle.Release();
|
assetsHandle.Release();
|
||||||
@@ -47,7 +47,9 @@ public class TestBundlePlaying
|
|||||||
// 验证成功结果
|
// 验证成功结果
|
||||||
// 说明:同步加载也会触发远端下载任务!
|
// 说明:同步加载也会触发远端下载任务!
|
||||||
yield return new WaitForSeconds(1f);
|
yield return new WaitForSeconds(1f);
|
||||||
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = true;
|
||||||
assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
assetsHandle = package.LoadAssetSync<GameObject>("prefab_encryptB");
|
||||||
|
UnityEngine.TestTools.LogAssert.ignoreFailingMessages = false;
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, assetsHandle.Status);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class TestDestroyPackage
|
|||||||
// 销毁旧资源包 ASSET_BUNDLE
|
// 销毁旧资源包 ASSET_BUNDLE
|
||||||
{
|
{
|
||||||
var package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
var package = YooAssets.GetPackage(TestDefine.AssetBundlePackageName);
|
||||||
var destroyOp = package.DestroyAsync();
|
var destroyOp = package.DestroyPackageAsync();
|
||||||
yield return destroyOp;
|
yield return destroyOp;
|
||||||
if (destroyOp.Status != EOperationStatus.Succeed)
|
if (destroyOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(destroyOp.Error);
|
Debug.LogError(destroyOp.Error);
|
||||||
@@ -30,7 +30,7 @@ public class TestDestroyPackage
|
|||||||
if (destroyRawPackage)
|
if (destroyRawPackage)
|
||||||
{
|
{
|
||||||
var package = YooAssets.GetPackage(TestDefine.RawBundlePackageName);
|
var package = YooAssets.GetPackage(TestDefine.RawBundlePackageName);
|
||||||
var destroyOp = package.DestroyAsync();
|
var destroyOp = package.DestroyPackageAsync();
|
||||||
yield return destroyOp;
|
yield return destroyOp;
|
||||||
if (destroyOp.Status != EOperationStatus.Succeed)
|
if (destroyOp.Status != EOperationStatus.Succeed)
|
||||||
Debug.LogError(destroyOp.Error);
|
Debug.LogError(destroyOp.Error);
|
||||||
|
|||||||
@@ -38,7 +38,13 @@ public class TestLoadAsset
|
|||||||
|
|
||||||
// 同步加载音效
|
// 同步加载音效
|
||||||
{
|
{
|
||||||
|
int loadFrame = Time.frameCount;
|
||||||
var assetHandle = package.LoadAssetSync<AudioClip>("sound_b");
|
var assetHandle = package.LoadAssetSync<AudioClip>("sound_b");
|
||||||
|
assetHandle.Completed += (AssetHandle handle) =>
|
||||||
|
{
|
||||||
|
Assert.AreEqual(loadFrame, Time.frameCount);
|
||||||
|
};
|
||||||
|
Assert.AreEqual(true, assetHandle.Provider.IsFinish);
|
||||||
Assert.AreEqual(EOperationStatus.Succeed, assetHandle.Status);
|
Assert.AreEqual(EOperationStatus.Succeed, assetHandle.Status);
|
||||||
|
|
||||||
var audioClip = assetHandle.AssetObject as AudioClip;
|
var audioClip = assetHandle.AssetObject as AudioClip;
|
||||||
|
|||||||
Reference in New Issue
Block a user