refactor : 重构资源包裹模块
This commit is contained in:
@@ -3,19 +3,6 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public sealed class UnloadAllAssetsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
||||
/// </summary>
|
||||
public bool ReleaseAllHandles = false;
|
||||
|
||||
/// <summary>
|
||||
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
||||
/// </summary>
|
||||
public bool LockLoadOperation = false;
|
||||
}
|
||||
|
||||
public sealed class UnloadAllAssetsOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
@@ -49,14 +36,6 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.CheckOptions)
|
||||
{
|
||||
if (_options == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(UnloadAllAssetsOptions)} is null.";
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置锁定状态
|
||||
if (_options.LockLoadOperation)
|
||||
_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>
|
||||
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
|
||||
public void Initialize(InitializePackageOptions options, IBundleQuery bundleServices)
|
||||
{
|
||||
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
|
||||
AutoUnloadBundleWhenUnused = parameters.AutoUnloadBundleWhenUnused;
|
||||
WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
|
||||
_bundleLoadingMaxConcurrency = options.BundleLoadingMaxConcurrency;
|
||||
AutoUnloadBundleWhenUnused = options.AutoUnloadBundleWhenUnused;
|
||||
WebGLForceSyncLoadAsset = options.WebGLForceSyncLoadAsset;
|
||||
_bundleQuery = bundleServices;
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user