TE6 打飞机Demo

TE6 打飞机Demo
This commit is contained in:
ALEXTANGXIAO
2025-04-26 23:23:39 +08:00
parent aaf7ddbee8
commit 1e195ed3b4
1921 changed files with 47050 additions and 44359 deletions

View File

@@ -14,11 +14,7 @@ namespace YooAsset
private EPlayMode _playMode;
// 管理器
private CacheManager _cacheMgr;
private PersistentManager _persistentMgr;
private DownloadManager _downloadMgr;
private ResourceManager _resourceMgr;
private ResourceLoader _resourceLoader;
private ResourceManager _resourceManager;
private IBundleQuery _bundleQuery;
private IPlayMode _playModeImpl;
@@ -35,27 +31,25 @@ namespace YooAsset
get { return _initializeStatus; }
}
private ResourcePackage()
/// <summary>
/// 包裹是否有效
/// </summary>
public bool PackageValid
{
get
{
if (_playModeImpl == null)
return false;
return _playModeImpl.ActiveManifest != null;
}
}
internal ResourcePackage(string packageName)
{
PackageName = packageName;
}
/// <summary>
/// 更新资源包裹
/// </summary>
internal void UpdatePackage()
{
if (_resourceMgr != null)
_resourceMgr.Update();
if (_downloadMgr != null)
_downloadMgr.Update();
}
/// <summary>
/// 销毁资源包裹
/// </summary>
@@ -67,32 +61,19 @@ namespace YooAsset
_initializeError = string.Empty;
_initializeStatus = EOperationStatus.None;
// 销毁资源管理器
if (_resourceManager != null)
{
_resourceManager.Destroy();
_resourceManager = null;
}
// 销毁文件系统
if (_playModeImpl != null)
_playModeImpl.DestroyFileSystem();
_bundleQuery = null;
_playModeImpl = null;
_persistentMgr = null;
_resourceLoader = null;
if (_resourceMgr != null)
{
_resourceMgr.ForceUnloadAllAssets();
_resourceMgr = null;
}
if (_downloadMgr != null)
{
_downloadMgr.DestroyAll();
_downloadMgr = null;
}
if (_cacheMgr != null)
{
_cacheMgr.ClearAll();
_cacheMgr = null;
}
// 最后清理该包裹的异步任务
// 注意:对于有线程操作的异步任务,需要保证线程安全释放。
OperationSystem.ClearPackageOperation(PackageName);
}
}
@@ -101,90 +82,52 @@ namespace YooAsset
/// </summary>
public InitializationOperation InitializeAsync(InitializeParameters parameters)
{
// 注意:WebGL平台因为网络原因可能会初始化失败!
// 注意:联机平台因为网络原因可能会初始化失败!
ResetInitializeAfterFailed();
// 检测初始化参数合法性
CheckInitializeParameters(parameters);
// 创建缓存管理器
_cacheMgr = new CacheManager(PackageName, parameters.CacheBootVerifyLevel);
// 创建持久化管理器
_persistentMgr = new PersistentManager(PackageName);
_persistentMgr.Initialize(parameters.BuildinRootDirectory, parameters.SandboxRootDirectory, parameters.CacheFileAppendExtension);
// 创建下载管理器
_downloadMgr = new DownloadManager(PackageName);
_downloadMgr.Initialize(parameters.BreakpointResumeFileSize);
// 创建资源包加载器
if (_playMode == EPlayMode.HostPlayMode)
// 销毁资源管理器
if (_resourceManager != null)
{
var initializeParameters = parameters as HostPlayModeParameters;
_resourceLoader = new ResourceLoader();
_resourceLoader.Init(parameters.DecryptionServices, initializeParameters.DeliveryLoadServices);
}
else
{
_resourceLoader = new ResourceLoader();
_resourceLoader.Init(parameters.DecryptionServices, null);
_resourceManager.Destroy();
_resourceManager = null;
}
// 创建资源协助类
ResourceAssist assist = new ResourceAssist();
assist.Cache = _cacheMgr;
assist.Persistent = _persistentMgr;
assist.Download = _downloadMgr;
assist.Loader = _resourceLoader;
// 创建资源管理器
_resourceManager = new ResourceManager(PackageName);
var playModeImpl = new PlayModeImpl(PackageName, _playMode);
_bundleQuery = playModeImpl;
_playModeImpl = playModeImpl;
_resourceManager.Initialize(parameters, _bundleQuery);
// 创建资源管理器
// 初始化资源系统
InitializationOperation initializeOperation;
_resourceMgr = new ResourceManager(PackageName);
if (_playMode == EPlayMode.EditorSimulateMode)
{
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
_bundleQuery = editorSimulateModeImpl;
_playModeImpl = editorSimulateModeImpl;
_resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as EditorSimulateModeParameters;
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.EditorFileSystemParameters);
}
else if (_playMode == EPlayMode.OfflinePlayMode)
{
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
_bundleQuery = offlinePlayModeImpl;
_playModeImpl = offlinePlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as OfflinePlayModeParameters;
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
}
else if (_playMode == EPlayMode.HostPlayMode)
{
var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
_bundleQuery = hostPlayModeImpl;
_playModeImpl = hostPlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as HostPlayModeParameters;
initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
initializeParameters.BuildinQueryServices,
initializeParameters.DeliveryQueryServices,
initializeParameters.RemoteServices);
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
}
else if (_playMode == EPlayMode.WebPlayMode)
{
var webPlayModeImpl = new WebPlayModeImpl(PackageName);
_bundleQuery = webPlayModeImpl;
_playModeImpl = webPlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as WebPlayModeParameters;
initializeOperation = webPlayModeImpl.InitializeAsync(assist,
initializeParameters.BuildinQueryServices,
initializeParameters.RemoteServices);
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
}
else if (_playMode == EPlayMode.CustomPlayMode)
{
var initializeParameters = parameters as CustomPlayModeParameters;
initializeOperation = playModeImpl.InitializeAsync(initializeParameters.FileSystemParameterList);
}
else
{
@@ -193,6 +136,7 @@ namespace YooAsset
// 监听初始化结果
_isInitialize = true;
OperationSystem.StartOperation(PackageName, initializeOperation);
initializeOperation.Completed += InitializeOperation_Completed;
return initializeOperation;
}
@@ -218,26 +162,9 @@ namespace YooAsset
throw new Exception($"Editor simulate mode only support unity editor.");
#endif
if (parameters is EditorSimulateModeParameters)
{
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulateManifestFilePath))
throw new Exception($"{nameof(editorSimulateModeParameters.SimulateManifestFilePath)} is null or empty.");
}
if (parameters is HostPlayModeParameters)
{
var hostPlayModeParameters = parameters as HostPlayModeParameters;
if (hostPlayModeParameters.RemoteServices == null)
throw new Exception($"{nameof(IRemoteServices)} is null.");
if (hostPlayModeParameters.BuildinQueryServices == null)
throw new Exception($"{nameof(IBuildinQueryServices)} is null.");
if (hostPlayModeParameters.DeliveryQueryServices != null)
{
if (hostPlayModeParameters.DeliveryLoadServices == null)
throw new Exception($"{nameof(IDeliveryLoadServices)} is null.");
}
}
// 检测初始化参数
if (parameters.BundleLoadingMaxConcurrency <= 0)
throw new Exception($"{nameof(parameters.BundleLoadingMaxConcurrency)} value must be greater than zero.");
// 鉴定运行模式
if (parameters is EditorSimulateModeParameters)
@@ -248,6 +175,8 @@ namespace YooAsset
_playMode = EPlayMode.HostPlayMode;
else if (parameters is WebPlayModeParameters)
_playMode = EPlayMode.WebPlayMode;
else if (parameters is CustomPlayModeParameters)
_playMode = EPlayMode.CustomPlayMode;
else
throw new NotImplementedException();
@@ -257,7 +186,7 @@ namespace YooAsset
#if UNITY_WEBGL
if (_playMode != EPlayMode.WebPlayMode)
{
throw new Exception($"{_playMode} can not support WebGL plateform ! Please use {nameof(EPlayMode.WebPlayMode)}");
throw new Exception($"{_playMode} can not support WebGL plateform !");
}
#else
if (_playMode == EPlayMode.WebPlayMode)
@@ -271,51 +200,102 @@ namespace YooAsset
{
_initializeStatus = op.Status;
_initializeError = op.Error;
if (_initializeStatus != EOperationStatus.Succeed)
YooLogger.Error(_initializeError);
}
/// <summary>
/// 向网络端请求最新的资源版本
/// 异步销毁
/// </summary>
public DestroyOperation DestroyAsync()
{
var operation = new DestroyOperation(this);
OperationSystem.StartOperation(null, operation);
return operation;
}
/// <summary>
/// 请求最新的资源版本
/// </summary>
/// <param name="appendTimeTicks">在URL末尾添加时间戳</param>
/// <param name="timeout">超时时间默认值60秒</param>
public UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
public RequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks = true, int timeout = 60)
{
DebugCheckInitialize(false);
return _playModeImpl.UpdatePackageVersionAsync(appendTimeTicks, timeout);
var operation = _playModeImpl.RequestPackageVersionAsync(appendTimeTicks, timeout);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
/// <summary>
/// 向网络端请求并更新清单
/// 更新并加载指定版本的资源清单
/// </summary>
/// <param name="packageVersion">更新的包裹版本</param>
/// <param name="autoSaveVersion">更新成功后自动保存版本号,作为下次初始化的版本。</param>
/// <param name="packageVersion">包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param>
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, bool autoSaveVersion = true, int timeout = 60)
public UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout = 60)
{
DebugCheckInitialize(false);
// 注意:强烈建议在更新之前保持加载器为空!
if (_resourceMgr.HasAnyLoader())
if (_resourceManager.HasAnyLoader())
{
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(ForceUnloadAllAssets)} method to release loaded bundle !");
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle !");
}
return _playModeImpl.UpdatePackageManifestAsync(packageVersion, autoSaveVersion, timeout);
var operation = _playModeImpl.UpdatePackageManifestAsync(packageVersion, timeout);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
/// <summary>
/// 预下载指定版本的包裹资源
/// </summary>
/// <param name="packageVersion">下载的包裹版本</param>
/// <param name="packageVersion">包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param>
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
{
DebugCheckInitialize(false);
return _playModeImpl.PreDownloadContentAsync(packageVersion, timeout);
var operation = _playModeImpl.PreDownloadContentAsync(packageVersion, timeout);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
/// <summary>
/// 获取本地包裹的版本信息
/// 清理缓存文件
/// </summary>
/// <param name="clearMode">清理方式</param>
/// <param name="clearParam">执行参数</param>
public ClearCacheFilesOperation ClearCacheFilesAsync(EFileClearMode clearMode, object clearParam = null)
{
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);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
#region
/// <summary>
/// 获取当前加载包裹的版本信息
/// </summary>
public string GetPackageVersion()
{
@@ -323,106 +303,79 @@ namespace YooAsset
return _playModeImpl.ActiveManifest.PackageVersion;
}
#region
/// <summary>
/// 资源回收(卸载引用计数为零的资源)
/// 获取当前加载包裹的备注信息
/// </summary>
public void UnloadUnusedAssets()
public string GetPackageNote()
{
DebugCheckInitialize();
_resourceMgr.UnloadUnusedAssets();
return _playModeImpl.ActiveManifest.PackageNote;
}
/// <summary>
/// 资源回收(尝试卸载指定的资源)
/// 获取当前加载包裹的详细信息
/// </summary>
public void TryUnloadUnusedAsset(string location)
public PackageDetails GetPackageDetails()
{
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
return _playModeImpl.ActiveManifest.GetPackageDetails();
}
#endregion
#region
/// <summary>
/// 资源回收(尝试卸载指定的资源
/// 强制回收所有资源
/// </summary>
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
public UnloadAllAssetsOperation UnloadAllAssetsAsync()
{
DebugCheckInitialize();
_resourceMgr.TryUnloadUnusedAsset(assetInfo);
var options = new UnloadAllAssetsOptions();
return UnloadAllAssetsAsync(options);
}
/// <summary>
/// 强制回收所有资源
/// </summary>
public void ForceUnloadAllAssets()
/// <param name="options">卸载选项</param>
public UnloadAllAssetsOperation UnloadAllAssetsAsync(UnloadAllAssetsOptions options)
{
DebugCheckInitialize();
_resourceMgr.ForceUnloadAllAssets();
}
#endregion
#region
/// <summary>
/// 获取包裹的内置文件根路径
/// </summary>
public string GetPackageBuildinRootDirectory()
{
DebugCheckInitialize();
return _persistentMgr.BuildinRoot;
}
/// <summary>
/// 获取包裹的沙盒文件根路径
/// </summary>
public string GetPackageSandboxRootDirectory()
{
DebugCheckInitialize();
return _persistentMgr.SandboxRoot;
}
/// <summary>
/// 清空包裹的沙盒目录
/// </summary>
public void ClearPackageSandbox()
{
DebugCheckInitialize();
_persistentMgr.DeleteSandboxPackageFolder();
_cacheMgr.ClearAll();
}
/// <summary>
/// 清理包裹未使用的缓存文件
/// </summary>
public ClearUnusedCacheFilesOperation ClearUnusedCacheFilesAsync()
{
DebugCheckInitialize();
var operation = new ClearUnusedCacheFilesOperation(this, _cacheMgr);
var operation = new UnloadAllAssetsOperation(_resourceManager, options);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
/// <summary>
/// 清理包裹本地所有的缓存文件
/// 回收不再使用的资源
/// 说明:卸载引用计数为零的资源
/// </summary>
public ClearAllCacheFilesOperation ClearAllCacheFilesAsync()
/// <param name="loopCount">循环迭代次数</param>
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync(int loopCount = 10)
{
DebugCheckInitialize();
var operation = new ClearAllCacheFilesOperation(_cacheMgr);
var operation = new UnloadUnusedAssetsOperation(_resourceManager, loopCount);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
/// <summary>
/// 获取指定版本的缓存信息
/// 资源回收
/// 说明:尝试卸载指定的资源
/// </summary>
public GetAllCacheFileInfosOperation GetAllCacheFileInfosAsync(string packageVersion)
public void TryUnloadUnusedAsset(string location)
{
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
_resourceManager.TryUnloadUnusedAsset(assetInfo);
}
var operation = new GetAllCacheFileInfosOperation(_persistentMgr, _cacheMgr, packageVersion);
OperationSystem.StartOperation(PackageName, operation);
return operation;
/// <summary>
/// 资源回收
/// 说明:尝试卸载指定的资源
/// </summary>
public void TryUnloadUnusedAsset(AssetInfo assetInfo)
{
DebugCheckInitialize();
_resourceManager.TryUnloadUnusedAsset(assetInfo);
}
#endregion
@@ -448,6 +401,15 @@ namespace YooAsset
return IsNeedDownloadFromRemoteInternal(assetInfo);
}
/// <summary>
/// 获取所有的资源信息
/// </summary>
public AssetInfo[] GetAllAssetInfos()
{
DebugCheckInitialize();
return _playModeImpl.ActiveManifest.GetAllAssetInfos();
}
/// <summary>
/// 获取资源信息列表
/// </summary>
@@ -456,7 +418,7 @@ namespace YooAsset
{
DebugCheckInitialize();
string[] tags = new string[] { tag };
return _playModeImpl.ActiveManifest.GetAssetsInfoByTags(tags);
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
}
/// <summary>
@@ -466,7 +428,7 @@ namespace YooAsset
public AssetInfo[] GetAssetInfos(string[] tags)
{
DebugCheckInitialize();
return _playModeImpl.ActiveManifest.GetAssetsInfoByTags(tags);
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
}
/// <summary>
@@ -531,13 +493,13 @@ namespace YooAsset
}
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
if (bundleInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
if (bundleInfo.IsNeedDownloadFromRemote())
return true;
BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo);
foreach (var depend in depends)
{
if (depend.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
if (depend.IsNeedDownloadFromRemote())
return true;
}
@@ -593,8 +555,7 @@ namespace YooAsset
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckRawFileLoadMethod(nameof(LoadRawFileAsync));
var handle = _resourceMgr.LoadRawFileAsync(assetInfo, priority);
var handle = _resourceManager.LoadRawFileAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
return handle;
@@ -607,11 +568,12 @@ namespace YooAsset
/// </summary>
/// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param>
public SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single)
/// <param name="physicsMode">场景物理模式</param>
public SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
{
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
return LoadSceneInternal(assetInfo, true, sceneMode, false, 0);
return LoadSceneInternal(assetInfo, true, sceneMode, physicsMode, false, 0);
}
/// <summary>
@@ -619,10 +581,11 @@ namespace YooAsset
/// </summary>
/// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param>
public SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single)
/// <param name="physicsMode">场景物理模式</param>
public SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
{
DebugCheckInitialize();
return LoadSceneInternal(assetInfo, true, sceneMode, false, 0);
return LoadSceneInternal(assetInfo, true, sceneMode, physicsMode, false, 0);
}
/// <summary>
@@ -630,13 +593,14 @@ namespace YooAsset
/// </summary>
/// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="physicsMode">场景物理模式</param>
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
/// <param name="priority">加载的优先级</param>
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0)
{
DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
return LoadSceneInternal(assetInfo, false, sceneMode, suspendLoad, priority);
return LoadSceneInternal(assetInfo, false, sceneMode, physicsMode, suspendLoad, priority);
}
/// <summary>
@@ -644,19 +608,21 @@ namespace YooAsset
/// </summary>
/// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param>
/// <param name="physicsMode">场景物理模式</param>
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
/// <param name="priority">加载的优先级</param>
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 0)
{
DebugCheckInitialize();
return LoadSceneInternal(assetInfo, false, sceneMode, suspendLoad, priority);
return LoadSceneInternal(assetInfo, false, sceneMode, physicsMode, suspendLoad, priority);
}
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, bool suspendLoad, uint priority)
private SceneHandle LoadSceneInternal(AssetInfo assetInfo, bool waitForAsyncComplete, LoadSceneMode sceneMode, LocalPhysicsMode physicsMode, bool suspendLoad, uint priority)
{
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadScene;
var loadSceneParams = new LoadSceneParameters(sceneMode, physicsMode);
var handle = _resourceManager.LoadSceneAsync(assetInfo, loadSceneParams, suspendLoad, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
return handle;
@@ -764,9 +730,9 @@ namespace YooAsset
private AssetHandle LoadAssetInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadMethod(nameof(LoadAssetAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadAssetAsync(assetInfo, priority);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAsset;
var handle = _resourceManager.LoadAssetAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
return handle;
@@ -874,9 +840,9 @@ namespace YooAsset
private SubAssetsHandle LoadSubAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadMethod(nameof(LoadSubAssetsAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadSubAssetsAsync(assetInfo, priority);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadSubAssets;
var handle = _resourceManager.LoadSubAssetsAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
return handle;
@@ -984,9 +950,9 @@ namespace YooAsset
private AllAssetsHandle LoadAllAssetsInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{
DebugCheckAssetLoadMethod(nameof(LoadAllAssetsAsync));
DebugCheckAssetLoadType(assetInfo.AssetType);
var handle = _resourceMgr.LoadAllAssetsAsync(assetInfo, priority);
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadAllAssets;
var handle = _resourceManager.LoadAllAssetsAsync(assetInfo, priority);
if (waitForAsyncComplete)
handle.WaitForAsyncComplete();
return handle;
@@ -1036,25 +1002,31 @@ namespace YooAsset
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="location">资源的定位地址</param>
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
var assetInfo = ConvertLocationToAssetInfo(location, null);
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
}
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源的定位地址列表</param>
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -1063,34 +1035,48 @@ namespace YooAsset
var assetInfo = ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
}
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
}
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="assetInfo">资源信息</param>
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
}
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="assetInfos">资源信息列表</param>
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout);
}
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain, timeout);
}
#endregion
@@ -1147,17 +1133,6 @@ namespace YooAsset
#endregion
#region
/// <summary>
/// 是否包含资源文件
/// </summary>
internal bool IsIncludeBundleFile(string cacheGUID)
{
// NOTE : 编辑器模拟模式下始终返回TRUE
if (_playMode == EPlayMode.EditorSimulateMode)
return true;
return _playModeImpl.ActiveManifest.IsIncludeBundleFile(cacheGUID);
}
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
{
return _playModeImpl.ActiveManifest.ConvertLocationToAssetInfo(location, assetType);
@@ -1180,25 +1155,7 @@ namespace YooAsset
if (checkActiveManifest)
{
if (_playModeImpl.ActiveManifest == null)
throw new Exception("Not found active package manifest !");
}
}
[Conditional("DEBUG")]
private void DebugCheckRawFileLoadMethod(string method)
{
if (_playModeImpl.ActiveManifest.BuildPipeline != EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
{
throw new Exception($"Cannot load asset bundle file using {method} method !");
}
}
[Conditional("DEBUG")]
private void DebugCheckAssetLoadMethod(string method)
{
if (_playModeImpl.ActiveManifest.BuildPipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
{
throw new Exception($"Cannot load raw file using {method} method !");
throw new Exception("Can not found active package manifest !");
}
}
@@ -1225,7 +1182,9 @@ namespace YooAsset
{
DebugPackageData data = new DebugPackageData();
data.PackageName = PackageName;
data.ProviderInfos = _resourceMgr.GetDebugReportInfos();
data.ProviderInfos = _resourceManager.GetDebugProviderInfos();
data.BundleInfos = _resourceManager.GetDebugBundleInfos();
data.OperationInfos = OperationSystem.GetDebugOperationInfos(PackageName);
return data;
}
#endregion