update file system

重构运行时核心代码
pull/418/head
何冠峰 2024-12-24 18:23:19 +08:00
parent 6d6fd3af2c
commit 6254d00bb5
67 changed files with 1811 additions and 204 deletions

View File

@ -46,5 +46,19 @@ namespace YooAsset
throw new System.NotImplementedException();
#endif
}
/// <summary>
/// 是否请求的本地文件
/// </summary>
public static bool IsRequestLocalFile(string url)
{
//TODO : UNITY_STANDALONE_OSX平台目前无法确定
if (url.StartsWith("file:"))
return true;
if (url.StartsWith("jar:file:"))
return true;
return false;
}
}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a9ca0d0d29eb5294b9c6926c6a09e76b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 167d849df37f45e42a77ab47464a9442
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,73 @@
using System.IO;
using UnityEngine;
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal class AssetBundleResult : BundleResult
{
private readonly IFileSystem _fileSystem;
private readonly PackageBundle _packageBundle;
private readonly AssetBundle _assetBundle;
private readonly Stream _managedStream;
public AssetBundleResult(IFileSystem fileSystem, PackageBundle packageBundle, AssetBundle assetBundle, Stream managedStream)
{
_fileSystem = fileSystem;
_packageBundle = packageBundle;
_assetBundle = assetBundle;
_managedStream = managedStream;
}
public override void UnloadBundleFile()
{
if (_assetBundle != null)
{
_assetBundle.Unload(true);
}
if (_managedStream != null)
{
_managedStream.Close();
_managedStream.Dispose();
}
}
public override string GetBundleFilePath()
{
return _fileSystem.GetBundleFilePath(_packageBundle);
}
public override byte[] ReadBundleFileData()
{
return _fileSystem.ReadBundleFileData(_packageBundle);
}
public override string ReadBundleFileText()
{
return _fileSystem.ReadBundleFileText(_packageBundle);
}
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{
var operation = new AssetBundleLoadAssetOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{
var operation = new AssetBundleLoadAllAssetsOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{
var operation = new AssetBundleLoadSubAssetsOperation(_packageBundle, _assetBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{
var operation = new AssetBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e30b4a882730b534e98d7d70821de979
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e310d20cf53709541bc66d1483afe627
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,121 @@
using UnityEngine;
namespace YooAsset
{
internal class AssetBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetBundle _assetBundle;
private readonly AssetInfo _assetInfo;
private AssetBundleRequest _request;
private ESteps _steps = ESteps.None;
public AssetBundleLoadAllAssetsOperation(PackageBundle packageBundle, AssetBundle assetBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetBundle = assetBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
_steps = ESteps.CheckBundle;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
if (_assetBundle == null)
{
_steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !";
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (IsWaitForAsyncComplete)
{
if (_assetInfo.AssetType == null)
Result = _assetBundle.LoadAllAssets();
else
Result = _assetBundle.LoadAllAssets(_assetInfo.AssetType);
}
else
{
if (_assetInfo.AssetType == null)
_request = _assetBundle.LoadAllAssetsAsync();
else
_request = _assetBundle.LoadAllAssetsAsync(_assetInfo.AssetType);
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (_request != null)
{
if (IsWaitForAsyncComplete)
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity asset.");
Result = _request.allAssets;
}
else
{
Progress = _request.progress;
if (_request.isDone == false)
return;
Result = _request.allAssets;
}
}
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load all assets : {_assetInfo.AssetPath} AssetType : null AssetBundle : {_packageBundle.BundleName}";
else
error = $"Failed to load all assets : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType} AssetBundle : {_packageBundle.BundleName}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 15e73c9ca9f0a7143b155e87ef1a3ce4
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,121 @@
using UnityEngine;
namespace YooAsset
{
internal class AssetBundleLoadAssetOperation : FSLoadAssetOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetBundle _assetBundle;
private readonly AssetInfo _assetInfo;
private AssetBundleRequest _request;
private ESteps _steps = ESteps.None;
public AssetBundleLoadAssetOperation(PackageBundle packageBundle, AssetBundle assetBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetBundle = assetBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
_steps = ESteps.CheckBundle;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
if (_assetBundle == null)
{
_steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !";
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (IsWaitForAsyncComplete)
{
if (_assetInfo.AssetType == null)
Result = _assetBundle.LoadAsset(_assetInfo.AssetPath);
else
Result = _assetBundle.LoadAsset(_assetInfo.AssetPath, _assetInfo.AssetType);
}
else
{
if (_assetInfo.AssetType == null)
_request = _assetBundle.LoadAssetAsync(_assetInfo.AssetPath);
else
_request = _assetBundle.LoadAssetAsync(_assetInfo.AssetPath, _assetInfo.AssetType);
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (_request != null)
{
if (IsWaitForAsyncComplete)
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity asset.");
Result = _request.asset;
}
else
{
Progress = _request.progress;
if (_request.isDone == false)
return;
Result = _request.asset;
}
}
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load asset : {_assetInfo.AssetPath} AssetType : null AssetBundle : {_packageBundle.BundleName}";
else
error = $"Failed to load asset : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType} AssetBundle : {_packageBundle.BundleName}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 88d19b84940f37a4c9814e60cfaff893
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,112 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal class AssetBundleLoadSceneOperation : FSLoadSceneOperation
{
protected enum ESteps
{
None,
LoadScene,
CheckResult,
Done,
}
private readonly AssetInfo _assetInfo;
private readonly LoadSceneParameters _loadParams;
private bool _suspendLoad;
private AsyncOperation _asyncOperation;
private ESteps _steps = ESteps.None;
public AssetBundleLoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{
_assetInfo = assetInfo;
_loadParams = loadParams;
_suspendLoad = suspendLoad;
}
internal override void InternalOnStart()
{
_steps = ESteps.LoadScene;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadScene)
{
if (IsWaitForAsyncComplete)
{
// 注意:场景同步加载方法不会立即加载场景,而是在下一帧加载。
Result = SceneManager.LoadScene(_assetInfo.AssetPath, _loadParams);
_steps = ESteps.CheckResult;
}
else
{
// 注意如果场景不存在异步加载方法返回NULL
// 注意:即使是异步加载也要在当帧获取到场景对象
_asyncOperation = SceneManager.LoadSceneAsync(_assetInfo.AssetPath, _loadParams);
if (_asyncOperation != null)
{
_asyncOperation.allowSceneActivation = !_suspendLoad;
_asyncOperation.priority = 100;
Result = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
_steps = ESteps.CheckResult;
}
else
{
string error = $"Failed to load scene : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
}
}
if (_steps == ESteps.CheckResult)
{
if (_asyncOperation != null)
{
if (IsWaitForAsyncComplete)
{
// 场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !");
}
else
{
// 注意:在业务层中途可以取消挂起
if (_asyncOperation.allowSceneActivation == false)
{
if (_suspendLoad == false)
_asyncOperation.allowSceneActivation = true;
}
Progress = _asyncOperation.progress;
if (_asyncOperation.isDone == false)
return;
}
}
if (Result.IsValid())
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
string error = $"The loaded scene is invalid : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
}
}
public override void UnSuspendLoad()
{
_suspendLoad = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 797fb02af35f2414a8b4bdb937c68ae2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,121 @@
using UnityEngine;
namespace YooAsset
{
internal class AssetBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetBundle _assetBundle;
private readonly AssetInfo _assetInfo;
private AssetBundleRequest _request;
private ESteps _steps = ESteps.None;
public AssetBundleLoadSubAssetsOperation(PackageBundle packageBundle, AssetBundle assetBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetBundle = assetBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
_steps = ESteps.CheckBundle;
}
internal override void InternalOnUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
if (_assetBundle == null)
{
_steps = ESteps.Done;
Error = $"The bundle {_packageBundle.BundleName} has been destroyed due to unity engine bugs !";
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (IsWaitForAsyncComplete)
{
if (_assetInfo.AssetType == null)
Result = _assetBundle.LoadAssetWithSubAssets(_assetInfo.AssetPath);
else
Result = _assetBundle.LoadAssetWithSubAssets(_assetInfo.AssetPath, _assetInfo.AssetType);
}
else
{
if (_assetInfo.AssetType == null)
_request = _assetBundle.LoadAssetWithSubAssetsAsync(_assetInfo.AssetPath);
else
_request = _assetBundle.LoadAssetWithSubAssetsAsync(_assetInfo.AssetPath, _assetInfo.AssetType);
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (_request != null)
{
if (IsWaitForAsyncComplete)
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity asset.");
Result = _request.allAssets;
}
else
{
Progress = _request.progress;
if (_request.isDone == false)
return;
Result = _request.allAssets;
}
}
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load sub assets : {_assetInfo.AssetPath} AssetType : null AssetBundle : {_packageBundle.BundleName}";
else
error = $"Failed to load sub assets : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType} AssetBundle : {_packageBundle.BundleName}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f0ff91311450bc44b8e9fc46637dcc4f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,48 @@
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal abstract class BundleResult
{
/// <summary>
/// 卸载资源包文件
/// </summary>
public abstract void UnloadBundleFile();
/// <summary>
/// 获取资源包文件的路径
/// </summary>
public abstract string GetBundleFilePath();
/// <summary>
/// 读取资源包文件的二进制数据
/// </summary>
public abstract byte[] ReadBundleFileData();
/// <summary>
/// 读取资源包文件的文本数据
/// </summary>
public abstract string ReadBundleFileText();
/// <summary>
/// 加载资源包内的资源对象
/// </summary>
public abstract FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo);
/// <summary>
/// 加载资源包内的所有资源对象
/// </summary>
public abstract FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo);
/// <summary>
/// 加载资源包内的资源对象及所有子资源对象
/// </summary>
public abstract FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo);
/// <summary>
/// 加载资源包内的场景对象
/// </summary>
public abstract FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 773d121e67073ec44adaa843ebcb01a0
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 87cc377fd18e5f948ba2b1f3e5175781
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 436e50c3a761f854d990f680fdf277ad
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@

namespace YooAsset
{
internal class RawBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation
{
internal override void InternalOnStart()
{
Error = $"{nameof(RawBundleLoadAllAssetsOperation)} not support load all assets !";
Status = EOperationStatus.Failed;
}
internal override void InternalOnUpdate()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 11c2a5a73d3ce674fbe95f014c5f17c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@

namespace YooAsset
{
internal class RawBundleLoadAssetOperation : FSLoadAssetOperation
{
internal override void InternalOnStart()
{
Error = $"{nameof(RawBundleLoadAssetOperation)} not support load asset !";
Status = EOperationStatus.Failed;
}
internal override void InternalOnUpdate()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2a4519177358454695404c8af876509
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@

namespace YooAsset
{
internal class RawBundleLoadSceneOperation : FSLoadSceneOperation
{
internal override void InternalOnStart()
{
Error = $"{nameof(RawBundleLoadSceneOperation)} not support load scene !";
Status = EOperationStatus.Failed;
}
internal override void InternalOnUpdate()
{
}
public override void UnSuspendLoad()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2e4c5d4b0b12d7045bf0c371f9efe0ce
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,15 @@

namespace YooAsset
{
internal class RawBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation
{
internal override void InternalOnStart()
{
Error = $"{nameof(RawBundleLoadSubAssetsOperation)} not support load sub assets !";
Status = EOperationStatus.Failed;
}
internal override void InternalOnUpdate()
{
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a6227d1a6e648e04d8b2e50a456c98bb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal class RawBundleResult : BundleResult
{
private readonly IFileSystem _fileSystem;
private readonly PackageBundle _packageBundle;
public RawBundleResult(IFileSystem fileSystem, PackageBundle packageBundle)
{
_fileSystem = fileSystem;
_packageBundle = packageBundle;
}
public override void UnloadBundleFile()
{
}
public override string GetBundleFilePath()
{
return _fileSystem.GetBundleFilePath(_packageBundle);
}
public override byte[] ReadBundleFileData()
{
return _fileSystem.ReadBundleFileData(_packageBundle);
}
public override string ReadBundleFileText()
{
return _fileSystem.ReadBundleFileText(_packageBundle);
}
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{
var operation = new RawBundleLoadAssetOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{
var operation = new RawBundleLoadAllAssetsOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{
var operation = new RawBundleLoadSubAssetsOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{
var operation = new RawBundleLoadSceneOperation();
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c6e71c986d2a8c74d981deeed7b5a8ef
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 2e49e0ae672b9944783571b2ad737df9
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 81e8e8c03e8b3f840aa8ffef751d5207
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,122 @@
using System.Collections.Generic;
namespace YooAsset
{
internal class VirtualBundleLoadAllAssetsOperation : FSLoadAllAssetsOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetInfo _assetInfo;
private ESteps _steps = ESteps.None;
public VirtualBundleLoadAllAssetsOperation(PackageBundle packageBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
#if UNITY_EDITOR
_steps = ESteps.CheckBundle;
#else
_steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadAllAssetsOperation)} only support unity editor platform !";
Status = EOperationStatus.Failed;
#endif
}
internal override void InternalOnUpdate()
{
#if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(_assetInfo.AssetPath);
if (string.IsNullOrEmpty(guid))
{
string error = $"Not found asset : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (_assetInfo.AssetType == null)
{
List<UnityEngine.Object> result = new List<UnityEngine.Object>();
foreach (var packageAsset in _packageBundle.IncludeMainAssets)
{
string assetPath = packageAsset.AssetPath;
UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetPath);
if (mainAsset != null)
result.Add(mainAsset);
}
Result = result.ToArray();
}
else
{
List<UnityEngine.Object> result = new List<UnityEngine.Object>();
foreach (var packageAsset in _packageBundle.IncludeMainAssets)
{
string assetPath = packageAsset.AssetPath;
UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, _assetInfo.AssetType);
if (mainAsset != null)
result.Add(mainAsset);
}
Result = result.ToArray();
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load all assets : {_assetInfo.AssetPath} AssetType : null";
else
error = $"Failed to load all assets : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
#endif
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f357dc3f2b24d0a478e4f01d4464bf8f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,101 @@

namespace YooAsset
{
internal class VirtualBundleLoadAssetOperation : FSLoadAssetOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetInfo _assetInfo;
private ESteps _steps = ESteps.None;
public VirtualBundleLoadAssetOperation(PackageBundle packageBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
#if UNITY_EDITOR
_steps = ESteps.CheckBundle;
#else
_steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadAssetOperation)} only support unity editor platform !";
Status = EOperationStatus.Failed;
#endif
}
internal override void InternalOnUpdate()
{
#if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(_assetInfo.AssetPath);
if (string.IsNullOrEmpty(guid))
{
string error = $"Not found asset : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (_assetInfo.AssetType == null)
Result = UnityEditor.AssetDatabase.LoadMainAssetAtPath(_assetInfo.AssetPath);
else
Result = UnityEditor.AssetDatabase.LoadAssetAtPath(_assetInfo.AssetPath, _assetInfo.AssetType);
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load asset object : {_assetInfo.AssetPath} AssetType : null";
else
error = $"Failed to load asset object : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
#endif
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 03615d03f7c5f1a4cb20309d7cce231d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,118 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal class VirtualBundleLoadSceneOperation : FSLoadSceneOperation
{
protected enum ESteps
{
None,
LoadScene,
CheckResult,
Done,
}
private readonly AssetInfo _assetInfo;
private readonly LoadSceneParameters _loadParams;
private bool _suspendLoad;
private AsyncOperation _asyncOperation;
private ESteps _steps = ESteps.None;
public VirtualBundleLoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{
_assetInfo = assetInfo;
_loadParams = loadParams;
_suspendLoad = suspendLoad;
}
internal override void InternalOnStart()
{
#if UNITY_EDITOR
_steps = ESteps.LoadScene;
#else
_steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadSceneOperation)} only support unity editor platform !";
Status = EOperationStatus.Failed;
#endif
}
internal override void InternalOnUpdate()
{
#if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.LoadScene)
{
if (IsWaitForAsyncComplete)
{
Result = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneInPlayMode(_assetInfo.AssetPath, _loadParams);
_steps = ESteps.CheckResult;
}
else
{
_asyncOperation = UnityEditor.SceneManagement.EditorSceneManager.LoadSceneAsyncInPlayMode(_assetInfo.AssetPath, _loadParams);
if (_asyncOperation != null)
{
_asyncOperation.allowSceneActivation = !_suspendLoad;
_asyncOperation.priority = 100;
Result = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
_steps = ESteps.CheckResult;
}
else
{
string error = $"Failed to load scene : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
return;
}
}
}
if (_steps == ESteps.CheckResult)
{
if (_asyncOperation != null)
{
if (IsWaitForAsyncComplete)
{
// 场景加载无法强制异步转同步
YooLogger.Error("The scene is loading asyn !");
}
else
{
// 注意:在业务层中途可以取消挂起
if (_asyncOperation.allowSceneActivation == false)
{
if (_suspendLoad == false)
_asyncOperation.allowSceneActivation = true;
}
Progress = _asyncOperation.progress;
if (_asyncOperation.isDone == false)
return;
}
}
if (Result.IsValid())
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
string error = $"The loaded scene is invalid : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
}
#endif
}
public override void UnSuspendLoad()
{
_suspendLoad = false;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 8b8822604da5ad44db43c220ab019a3d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,113 @@
using System.Collections.Generic;
namespace YooAsset
{
internal class VirtualBundleLoadSubAssetsOperation : FSLoadSubAssetsOperation
{
protected enum ESteps
{
None,
CheckBundle,
LoadAsset,
CheckResult,
Done,
}
private readonly PackageBundle _packageBundle;
private readonly AssetInfo _assetInfo;
private ESteps _steps = ESteps.None;
public VirtualBundleLoadSubAssetsOperation(PackageBundle packageBundle, AssetInfo assetInfo)
{
_packageBundle = packageBundle;
_assetInfo = assetInfo;
}
internal override void InternalOnStart()
{
#if UNITY_EDITOR
_steps = ESteps.CheckBundle;
#else
_steps = ESteps.Done;
Error = $"{nameof(VirtualBundleLoadSubAssetsOperation)} only support unity editor platform !";
Status = EOperationStatus.Failed;
#endif
}
internal override void InternalOnUpdate()
{
#if UNITY_EDITOR
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckBundle)
{
// 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(_assetInfo.AssetPath);
if (string.IsNullOrEmpty(guid))
{
string error = $"Not found asset : {_assetInfo.AssetPath}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
return;
}
_steps = ESteps.LoadAsset;
}
if (_steps == ESteps.LoadAsset)
{
if (_assetInfo.AssetType == null)
{
Result = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(_assetInfo.AssetPath);
}
else
{
UnityEngine.Object[] findAssets = UnityEditor.AssetDatabase.LoadAllAssetRepresentationsAtPath(_assetInfo.AssetPath);
List<UnityEngine.Object> result = new List<UnityEngine.Object>(findAssets.Length);
foreach (var findAsset in findAssets)
{
if (_assetInfo.AssetType.IsAssignableFrom(findAsset.GetType()))
result.Add(findAsset);
}
Result = result.ToArray();
}
_steps = ESteps.CheckResult;
}
if (_steps == ESteps.CheckResult)
{
if (Result == null)
{
string error;
if (_assetInfo.AssetType == null)
error = $"Failed to load sub assets : {_assetInfo.AssetPath} AssetType : null";
else
error = $"Failed to load sub assets : {_assetInfo.AssetPath} AssetType : {_assetInfo.AssetType}";
YooLogger.Error(error);
_steps = ESteps.Done;
Error = error;
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
#endif
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: afdd738603565e6499dc48e4f00ca178
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
using UnityEngine.SceneManagement;
namespace YooAsset
{
internal class VirtualBundleResult : BundleResult
{
private readonly IFileSystem _fileSystem;
private readonly PackageBundle _packageBundle;
public VirtualBundleResult(IFileSystem fileSystem, PackageBundle bundle)
{
_fileSystem = fileSystem;
_packageBundle = bundle;
}
public override void UnloadBundleFile()
{
}
public override string GetBundleFilePath()
{
return _fileSystem.GetBundleFilePath(_packageBundle);
}
public override byte[] ReadBundleFileData()
{
return _fileSystem.ReadBundleFileData(_packageBundle);
}
public override string ReadBundleFileText()
{
return _fileSystem.ReadBundleFileText(_packageBundle);
}
public override FSLoadAssetOperation LoadAssetAsync(AssetInfo assetInfo)
{
var operation = new VirtualBundleLoadAssetOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadAllAssetsOperation LoadAllAssetsAsync(AssetInfo assetInfo)
{
var operation = new VirtualBundleLoadAllAssetsOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSubAssetsOperation LoadSubAssetsAsync(AssetInfo assetInfo)
{
var operation = new VirtualBundleLoadSubAssetsOperation(_packageBundle, assetInfo);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
public override FSLoadSceneOperation LoadSceneOperation(AssetInfo assetInfo, LoadSceneParameters loadParams, bool suspendLoad)
{
var operation = new VirtualBundleLoadSceneOperation(assetInfo, loadParams, suspendLoad);
OperationSystem.StartOperation(_fileSystem.PackageName, operation);
return operation;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 822bb85f05144d842977dda341174db2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -9,6 +9,7 @@ namespace YooAsset
private readonly IFileSystem _fileSystem;
private readonly ICacheSystem _cacheSystem;
private VerifyTempFileOperation _verifyOperation;
private bool _isReuqestLocalFile;
private string _tempFilePath;
private ESteps _steps = ESteps.None;
@ -19,6 +20,7 @@ namespace YooAsset
}
internal override void InternalOnStart()
{
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
_tempFilePath = _cacheSystem.GetTempFilePath(Bundle);
_steps = ESteps.CheckExists;
}
@ -131,6 +133,15 @@ namespace YooAsset
// 重新尝试下载
if (_steps == ESteps.TryAgain)
{
//TODO : 拷贝本地文件失败后不再尝试!
if (_isReuqestLocalFile)
{
Status = EOperationStatus.Failed;
_steps = ESteps.Done;
YooLogger.Error(Error);
return;
}
if (FailedTryAgain <= 0)
{
Status = EOperationStatus.Failed;
@ -155,12 +166,16 @@ namespace YooAsset
}
internal override void InternalWaitForAsyncComplete()
{
bool isReuqestLocalFile = IsRequestLocalFile();
//TODO : 防止下载器挂起陷入无限死循环!
if (_steps == ESteps.None)
{
InternalOnStart();
}
while (true)
{
// 注意:如果是导入或解压本地文件,执行等待完毕
if (isReuqestLocalFile)
//TODO : 如果是导入或解压本地文件,执行等待完毕
if (_isReuqestLocalFile)
{
InternalOnUpdate();
if (IsDone)

View File

@ -12,6 +12,7 @@ namespace YooAsset
private readonly List<long> _responseCodes;
private DownloadHandlerFileRange _downloadHandle;
private VerifyTempFileOperation _verifyOperation;
private bool _isReuqestLocalFile;
private long _fileOriginLength = 0;
private string _tempFilePath;
private ESteps _steps = ESteps.None;
@ -25,6 +26,7 @@ namespace YooAsset
}
internal override void InternalOnStart()
{
_isReuqestLocalFile = DownloadSystemHelper.IsRequestLocalFile(Param.MainURL);
_tempFilePath = _cacheSystem.GetTempFilePath(Bundle);
_steps = ESteps.CheckExists;
}
@ -153,6 +155,15 @@ namespace YooAsset
// 重新尝试下载
if (_steps == ESteps.TryAgain)
{
//TODO : 拷贝本地文件失败后不再尝试!
if (_isReuqestLocalFile)
{
Status = EOperationStatus.Failed;
_steps = ESteps.Done;
YooLogger.Error(Error);
return;
}
if (FailedTryAgain <= 0)
{
Status = EOperationStatus.Failed;
@ -177,12 +188,16 @@ namespace YooAsset
}
internal override void InternalWaitForAsyncComplete()
{
bool isReuqestLocalFile = IsRequestLocalFile();
//TODO : 防止下载器挂起陷入无限死循环!
if (_steps == ESteps.None)
{
InternalOnStart();
}
while (true)
{
// 注意:如果是导入或解压本地文件,执行等待完毕
if (isReuqestLocalFile)
//TODO : 如果是导入或解压本地文件,执行等待完毕
if (_isReuqestLocalFile)
{
InternalOnUpdate();
if (IsDone)

View File

@ -70,7 +70,7 @@ namespace YooAsset
{
while (true)
{
// 注意:等待子线程验证文件完毕
//TODO : 等待子线程验证文件完毕,该操作会挂起主线程
InternalOnUpdate();
if (IsDone)
break;

View File

@ -21,7 +21,6 @@ namespace YooAsset
}
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
protected readonly Dictionary<string, Stream> _loadedStream = new Dictionary<string, Stream>(10000);
protected readonly Dictionary<string, string> _buildinFilePaths = new Dictionary<string, string>(10000);
protected IFileSystem _unpackFileSystem;
protected string _packageRoot;
@ -64,11 +63,6 @@ namespace YooAsset
/// </summary>
public bool AppendFileExtension { private set; get; } = false;
/// <summary>
/// 自定义参数:原生文件构建管线
/// </summary>
public bool RawFileBuildPipeline { private set; get; } = false;
/// <summary>
/// 自定义参数:解密方法类
/// </summary>
@ -113,7 +107,13 @@ namespace YooAsset
return _unpackFileSystem.LoadBundleFile(bundle);
}
if (RawFileBuildPipeline)
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
{
var operation = new DBFSLoadRawBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
@ -121,37 +121,12 @@ namespace YooAsset
}
else
{
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
string error = $"{nameof(DefaultBuildinFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
AssetBundle assetBundle = result as AssetBundle;
if (assetBundle == null)
return;
if (_unpackFileSystem.Exists(bundle))
{
_unpackFileSystem.UnloadBundleFile(bundle, assetBundle);
}
else
{
if (assetBundle != null)
assetBundle.Unload(true);
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
{
if (managedStream != null)
{
managedStream.Close();
managedStream.Dispose();
}
_loadedStream.Remove(bundle.BundleGUID);
}
}
}
public virtual void SetParameter(string name, object value)
{
@ -163,10 +138,6 @@ namespace YooAsset
{
AppendFileExtension = (bool)value;
}
else if (name == FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE)
{
RawFileBuildPipeline = (bool)value;
}
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
{
DecryptionServices = (IDecryptionServices)value;
@ -191,7 +162,6 @@ namespace YooAsset
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE, RawFileBuildPipeline);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
_unpackFileSystem.OnCreate(packageName, null);
}
@ -218,7 +188,7 @@ namespace YooAsset
return false;
#if UNITY_ANDROID
return RawFileBuildPipeline || bundle.Encrypted;
return bundle.BundleType == (int)EBuildBundleType.RawBundle || bundle.Encrypted;
#else
return false;
#endif
@ -228,10 +198,17 @@ namespace YooAsset
return false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
if (NeedUnpack(bundle))
return _unpackFileSystem.ReadFileData(bundle);
return _unpackFileSystem.GetBundleFilePath(bundle);
return GetBuildinFileLoadPath(bundle);
}
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
if (NeedUnpack(bundle))
return _unpackFileSystem.ReadBundleFileData(bundle);
if (Exists(bundle) == false)
return null;
@ -259,10 +236,10 @@ namespace YooAsset
return FileUtility.ReadAllBytes(filePath);
}
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual string ReadBundleFileText(PackageBundle bundle)
{
if (NeedUnpack(bundle))
return _unpackFileSystem.ReadFileText(bundle);
return _unpackFileSystem.ReadBundleFileText(bundle);
if (Exists(bundle) == false)
return null;
@ -350,9 +327,9 @@ namespace YooAsset
}
/// <summary>
/// 加载加密资源文件
/// 加载加密资源文件
/// </summary>
public AssetBundle LoadEncryptedAssetBundle(PackageBundle bundle)
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
{
string filePath = GetBuildinFileLoadPath(bundle);
var fileInfo = new DecryptFileInfo()
@ -361,16 +338,13 @@ namespace YooAsset
FileLoadCRC = bundle.UnityCRC,
FileLoadPath = filePath,
};
var assetBundle = DecryptionServices.LoadAssetBundle(fileInfo, out var managedStream);
_loadedStream.Add(bundle.BundleGUID, managedStream);
return assetBundle;
return DecryptionServices.LoadAssetBundle(fileInfo);
}
/// <summary>
/// 加载加密资源文件
/// 加载加密资源文件
/// </summary>
public AssetBundleCreateRequest LoadEncryptedAssetBundleAsync(PackageBundle bundle)
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
{
string filePath = GetBuildinFileLoadPath(bundle);
var fileInfo = new DecryptFileInfo()
@ -379,10 +353,7 @@ namespace YooAsset
FileLoadCRC = bundle.UnityCRC,
FileLoadPath = filePath,
};
var createRequest = DecryptionServices.LoadAssetBundleAsync(fileInfo, out var managedStream);
_loadedStream.Add(bundle.BundleGUID, managedStream);
return createRequest;
return DecryptionServices.LoadAssetBundleAsync(fileInfo);
}
#endregion
}

View File

@ -19,6 +19,8 @@ namespace YooAsset
private readonly DefaultBuildinFileSystem _fileSystem;
private readonly PackageBundle _bundle;
private AssetBundleCreateRequest _createRequest;
private AssetBundle _assetBundle;
private Stream _managedStream;
private ESteps _steps = ESteps.None;
@ -56,19 +58,23 @@ namespace YooAsset
{
if (_bundle.Encrypted)
{
Result = _fileSystem.LoadEncryptedAssetBundle(_bundle);
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
_assetBundle = decryptResult.Result;
_managedStream = decryptResult.ManagedStream;
}
else
{
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
Result = AssetBundle.LoadFromFile(filePath);
_assetBundle = AssetBundle.LoadFromFile(filePath);
}
}
else
{
if (_bundle.Encrypted)
{
_createRequest = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
_createRequest = decryptResult.CreateRequest;
_managedStream = decryptResult.ManagedStream;
}
else
{
@ -88,19 +94,20 @@ namespace YooAsset
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity bundle.");
Result = _createRequest.assetBundle;
_assetBundle = _createRequest.assetBundle;
}
else
{
if (_createRequest.isDone == false)
return;
Result = _createRequest.assetBundle;
_assetBundle = _createRequest.assetBundle;
}
}
if (Result != null)
if (_assetBundle != null)
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
Status = EOperationStatus.Succeed;
return;
}
@ -176,7 +183,7 @@ namespace YooAsset
if (File.Exists(filePath))
{
_steps = ESteps.Done;
Result = new RawBundle(_fileSystem, _bundle, filePath);
Result = new RawBundleResult(_fileSystem, _bundle);
Status = EOperationStatus.Succeed;
}
else

View File

@ -84,7 +84,6 @@ namespace YooAsset
}
// 设置请求URL
bool importFile = false;
if (string.IsNullOrEmpty(param.ImportFilePath))
{
param.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(bundle.FileName);
@ -95,7 +94,6 @@ namespace YooAsset
// 注意:把本地文件路径指定为远端下载地址
param.MainURL = DownloadSystemHelper.ConvertToWWWPath(param.ImportFilePath);
param.FallbackURL = param.MainURL;
importFile = true;
}
// 创建新的下载器
@ -112,12 +110,6 @@ namespace YooAsset
newDownloader.Reference();
_downloaders.Add(bundle.BundleGUID, newDownloader);
}
// 注意:导入文件不要限制并发!导入文件涉及到异步转同步,限制并发会导致主线程卡死风险!
if (importFile)
{
OperationSystem.StartOperation(_fileSystem.PackageName, newDownloader);
}
return newDownloader;
}

View File

@ -13,7 +13,6 @@ namespace YooAsset
internal class DefaultCacheFileSystem : IFileSystem, ICacheSystem
{
protected readonly Dictionary<string, CacheWrapper> _wrappers = new Dictionary<string, CacheWrapper>(10000);
protected readonly Dictionary<string, Stream> _loadedStream = new Dictionary<string, Stream>(10000);
protected readonly Dictionary<string, string> _dataFilePaths = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _infoFilePaths = new Dictionary<string, string>(10000);
protected readonly Dictionary<string, string> _tempFilePaths = new Dictionary<string, string>(10000);
@ -67,11 +66,6 @@ namespace YooAsset
/// </summary>
public bool AppendFileExtension { private set; get; } = false;
/// <summary>
/// 自定义参数:原生文件构建管线
/// </summary>
public bool RawFileBuildPipeline { private set; get; } = false;
/// <summary>
/// 自定义参数:最大并发连接数
/// </summary>
@ -154,7 +148,13 @@ namespace YooAsset
}
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
if (RawFileBuildPipeline)
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
{
var operation = new DCFSLoadRawBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
@ -162,30 +162,12 @@ namespace YooAsset
}
else
{
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
string error = $"{nameof(DefaultCacheFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
AssetBundle assetBundle = result as AssetBundle;
if (assetBundle == null)
return;
if (assetBundle != null)
assetBundle.Unload(true);
if (_loadedStream.TryGetValue(bundle.BundleGUID, out Stream managedStream))
{
if (managedStream != null)
{
managedStream.Close();
managedStream.Dispose();
}
_loadedStream.Remove(bundle.BundleGUID);
}
}
public virtual void SetParameter(string name, object value)
{
@ -201,10 +183,6 @@ namespace YooAsset
{
AppendFileExtension = (bool)value;
}
else if (name == FileSystemParametersDefine.RAW_FILE_BUILD_PIPELINE)
{
RawFileBuildPipeline = (bool)value;
}
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
{
DownloadMaxConcurrency = (int)value;
@ -276,7 +254,11 @@ namespace YooAsset
return Exists(bundle) == false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
return GetCacheFileLoadPath(bundle);
}
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
if (Exists(bundle) == false)
return null;
@ -304,7 +286,7 @@ namespace YooAsset
return FileUtility.ReadAllBytes(filePath);
}
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual string ReadBundleFileText(PackageBundle bundle)
{
if (Exists(bundle) == false)
return null;
@ -523,7 +505,7 @@ namespace YooAsset
/// <summary>
/// 加载加密资源文件
/// </summary>
public AssetBundle LoadEncryptedAssetBundle(PackageBundle bundle)
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
{
string filePath = GetCacheFileLoadPath(bundle);
var fileInfo = new DecryptFileInfo()
@ -532,16 +514,13 @@ namespace YooAsset
FileLoadCRC = bundle.UnityCRC,
FileLoadPath = filePath,
};
var assetBundle = DecryptionServices.LoadAssetBundle(fileInfo, out var managedStream);
_loadedStream.Add(bundle.BundleGUID, managedStream);
return assetBundle;
return DecryptionServices.LoadAssetBundle(fileInfo);
}
/// <summary>
/// 加载加密资源文件
/// </summary>
public AssetBundleCreateRequest LoadEncryptedAssetBundleAsync(PackageBundle bundle)
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
{
string filePath = GetCacheFileLoadPath(bundle);
var fileInfo = new DecryptFileInfo()
@ -550,10 +529,7 @@ namespace YooAsset
FileLoadCRC = bundle.UnityCRC,
FileLoadPath = filePath,
};
var createRequest = DecryptionServices.LoadAssetBundleAsync(fileInfo, out var managedStream);
_loadedStream.Add(bundle.BundleGUID, managedStream);
return createRequest;
return DecryptionServices.LoadAssetBundleAsync(fileInfo);
}
#endregion
}

View File

@ -19,6 +19,8 @@ namespace YooAsset
protected readonly PackageBundle _bundle;
protected FSDownloadFileOperation _downloadFileOp;
protected AssetBundleCreateRequest _createRequest;
private AssetBundle _assetBundle;
private Stream _managedStream;
protected ESteps _steps = ESteps.None;
@ -96,19 +98,23 @@ namespace YooAsset
{
if (_bundle.Encrypted)
{
Result = _fileSystem.LoadEncryptedAssetBundle(_bundle);
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
_assetBundle = decryptResult.Result;
_managedStream = decryptResult.ManagedStream;
}
else
{
string filePath = _fileSystem.GetCacheFileLoadPath(_bundle);
Result = AssetBundle.LoadFromFile(filePath);
_assetBundle = AssetBundle.LoadFromFile(filePath);
}
}
else
{
if (_bundle.Encrypted)
{
_createRequest = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
_createRequest = decryptResult.CreateRequest;
_managedStream = decryptResult.ManagedStream;
}
else
{
@ -128,19 +134,20 @@ namespace YooAsset
{
// 强制挂起主线程(注意:该操作会很耗时)
YooLogger.Warning("Suspend the main thread to load unity bundle.");
Result = _createRequest.assetBundle;
_assetBundle = _createRequest.assetBundle;
}
else
{
if (_createRequest.isDone == false)
return;
Result = _createRequest.assetBundle;
_assetBundle = _createRequest.assetBundle;
}
}
if (Result != null)
if (_assetBundle != null)
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
Status = EOperationStatus.Succeed;
return;
}
@ -165,8 +172,8 @@ namespace YooAsset
byte[] fileData = FileUtility.ReadAllBytes(filePath);
if (fileData != null && fileData.Length > 0)
{
Result = AssetBundle.LoadFromMemory(fileData);
if (Result == null)
_assetBundle = AssetBundle.LoadFromMemory(fileData);
if (_assetBundle == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
@ -176,6 +183,7 @@ namespace YooAsset
else
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, null);
Status = EOperationStatus.Succeed;
}
}
@ -300,7 +308,7 @@ namespace YooAsset
if (File.Exists(filePath))
{
_steps = ESteps.Done;
Result = new RawBundle(_fileSystem, _bundle, filePath);
Result = new RawBundleResult(_fileSystem, _bundle);
Status = EOperationStatus.Succeed;
}
else
@ -318,6 +326,7 @@ namespace YooAsset
{
if (ExecuteWhileDone())
{
//TODO 拷贝本地文件失败也会触发该错误!
if (_downloadFileOp != null && _downloadFileOp.Status == EOperationStatus.Failed)
YooLogger.Error($"Try load bundle {_bundle.BundleName} from remote !");

View File

@ -81,12 +81,19 @@ namespace YooAsset
}
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
var operation = new DEFSLoadBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
if (bundle.BundleType == (int)EBuildBundleType.VirtualBundle)
{
var operation = new DEFSLoadBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else
{
string error = $"{nameof(DefaultEditorFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void SetParameter(string name, object value)
@ -139,13 +146,29 @@ namespace YooAsset
return false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
throw new System.NotImplementedException();
if (bundle.IncludeMainAssets.Count == 0)
return string.Empty;
var pacakgeAsset = bundle.IncludeMainAssets[0];
return pacakgeAsset.AssetPath;
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
throw new System.NotImplementedException();
if (bundle.IncludeMainAssets.Count == 0)
return null;
var pacakgeAsset = bundle.IncludeMainAssets[0];
return FileUtility.ReadAllBytes(pacakgeAsset.AssetPath);
}
public virtual string ReadBundleFileText(PackageBundle bundle)
{
if (bundle.IncludeMainAssets.Count == 0)
return null;
var pacakgeAsset = bundle.IncludeMainAssets[0];
return FileUtility.ReadAllText(pacakgeAsset.AssetPath);
}
#region 内部方法

View File

@ -57,7 +57,7 @@ namespace YooAsset
if (_steps == ESteps.CheckResult)
{
_steps = ESteps.Done;
Result = new VirtualBundle(_fileSystem, _bundle);
Result = new VirtualBundleResult(_fileSystem, _bundle);
Status = EOperationStatus.Succeed;
}
}

View File

@ -83,18 +83,19 @@ namespace YooAsset
}
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
var operation = new DWRFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
AssetBundle assetBundle = result as AssetBundle;
if (assetBundle == null)
return;
if (assetBundle != null)
assetBundle.Unload(true);
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new DWRFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else
{
string error = $"{nameof(DefaultWebRemoteFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void SetParameter(string name, object value)
@ -141,11 +142,15 @@ namespace YooAsset
return false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadBundleFileText(PackageBundle bundle)
{
throw new System.NotImplementedException();
}

View File

@ -1,4 +1,6 @@

using UnityEngine;
namespace YooAsset
{
internal class DWRFSLoadAssetBundleOperation : FSLoadBundleOperation
@ -49,9 +51,19 @@ namespace YooAsset
if (_downloadhanlderAssetBundleOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.Done;
Result = _downloadhanlderAssetBundleOp.Result;
Status = EOperationStatus.Succeed;
var assetBundle = _downloadhanlderAssetBundleOp.Result;
if(assetBundle == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"{nameof(DownloadHandlerAssetBundleOperation)} loaded asset bundle is null !";
}
else
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, assetBundle, null);
Status = EOperationStatus.Succeed;
}
}
else
{

View File

@ -92,18 +92,19 @@ namespace YooAsset
}
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{
var operation = new DWSFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
{
AssetBundle assetBundle = result as AssetBundle;
if (assetBundle == null)
return;
if (assetBundle != null)
assetBundle.Unload(true);
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
{
var operation = new DWSFSLoadAssetBundleOperation(this, bundle);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
else
{
string error = $"{nameof(DefaultWebServerFileSystem)} not support load bundle type : {bundle.BundleType}";
var operation = new FSLoadBundleCompleteOperation(error);
OperationSystem.StartOperation(PackageName, operation);
return operation;
}
}
public virtual void SetParameter(string name, object value)
@ -151,11 +152,15 @@ namespace YooAsset
return false;
}
public virtual byte[] ReadFileData(PackageBundle bundle)
public virtual string GetBundleFilePath(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadFileText(PackageBundle bundle)
public virtual byte[] ReadBundleFileData(PackageBundle bundle)
{
throw new System.NotImplementedException();
}
public virtual string ReadBundleFileText(PackageBundle bundle)
{
throw new System.NotImplementedException();
}

View File

@ -50,9 +50,19 @@ namespace YooAsset
if (_downloadhanlderAssetBundleOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.Done;
Result = _downloadhanlderAssetBundleOp.Result;
Status = EOperationStatus.Succeed;
var assetBundle = _downloadhanlderAssetBundleOp.Result;
if (assetBundle == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"{nameof(DownloadHandlerAssetBundleOperation)} loaded asset bundle is null !";
}
else
{
_steps = ESteps.Done;
Result = new AssetBundleResult(_fileSystem, _bundle, assetBundle, null);
Status = EOperationStatus.Succeed;
}
}
else
{

View File

@ -7,7 +7,6 @@ namespace YooAsset
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
public const string RAW_FILE_BUILD_PIPELINE = "RAW_FILE_BUILD_PIPELINE";
public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE";
public const string DOWNLOAD_MAX_CONCURRENCY = "DOWNLOAD_MAX_CONCURRENCY";
public const string DOWNLOAD_MAX_REQUEST_PER_FRAME = "DOWNLOAD_MAX_REQUEST_PER_FRAME";

View File

@ -48,12 +48,7 @@ namespace YooAsset
/// 加载Bundle文件
/// </summary>
FSLoadBundleOperation LoadBundleFile(PackageBundle bundle);
/// <summary>
/// 卸载Bundle文件
/// </summary>
void UnloadBundleFile(PackageBundle bundle, object result);
/// <summary>
/// 设置自定义参数
@ -98,13 +93,18 @@ namespace YooAsset
/// <summary>
/// 读取文件二进制数据
/// 获取Bundle文件路径
/// </summary>
byte[] ReadFileData(PackageBundle bundle);
string GetBundleFilePath(PackageBundle bundle);
/// <summary>
/// 读取文件文本数据
/// 读取Bundle文件的二进制数据
/// </summary>
string ReadFileText(PackageBundle bundle);
byte[] ReadBundleFileData(PackageBundle bundle);
/// <summary>
/// 读取Bundle文件的文本数据
/// </summary>
string ReadBundleFileText(PackageBundle bundle);
}
}

View File

@ -0,0 +1,8 @@

namespace YooAsset
{
internal abstract class FSLoadAllAssetsOperation : AsyncOperationBase
{
public UnityEngine.Object[] Result;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45cfe41807608d24dbe5506c8d7b4a9e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@

namespace YooAsset
{
internal abstract class FSLoadAssetOperation : AsyncOperationBase
{
public UnityEngine.Object Result;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 51851bd94e8307d4881ceecc84ee71e9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -7,7 +7,7 @@ namespace YooAsset
/// <summary>
/// 加载结果
/// </summary>
public object Result { protected set; get; }
public BundleResult Result { protected set; get; }
/// <summary>
/// 下载进度
@ -24,4 +24,25 @@ namespace YooAsset
/// </summary>
public abstract void AbortDownloadOperation();
}
internal sealed class FSLoadBundleCompleteOperation : FSLoadBundleOperation
{
private readonly string _error;
internal FSLoadBundleCompleteOperation(string error)
{
_error = error;
}
internal override void InternalOnStart()
{
Status = EOperationStatus.Failed;
Error = _error;
}
internal override void InternalOnUpdate()
{
}
public override void AbortDownloadOperation()
{
}
}
}

View File

@ -0,0 +1,10 @@

namespace YooAsset
{
internal abstract class FSLoadSceneOperation : AsyncOperationBase
{
public UnityEngine.SceneManagement.Scene Result;
public abstract void UnSuspendLoad();
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7ad384dede61ad6478cc376d4af598a9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@

namespace YooAsset
{
internal abstract class FSLoadSubAssetsOperation : AsyncOperationBase
{
public UnityEngine.Object[] Result;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b44c0a8ba7b4bcd4a9271675db5a5a83
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -126,19 +126,5 @@ namespace YooAsset
}
#endif
}
/// <summary>
/// 是否请求的本地文件
/// </summary>
protected bool IsRequestLocalFile()
{
//TODO : UNITY_STANDALONE_OSX平台目前无法确定
if (Param.MainURL.StartsWith("file:"))
return true;
if (Param.MainURL.StartsWith("jar:file:"))
return true;
return false;
}
}
}

View File

@ -55,9 +55,19 @@ namespace YooAsset
// 检查网络错误
if (CheckRequestResult())
{
_steps = ESteps.Done;
Result = _downloadhandler.assetBundle;
Status = EOperationStatus.Succeed;
var assetBundle = _downloadhandler.assetBundle;
if (assetBundle == null)
{
_steps = ESteps.Done;
Error = "Download handler asset bundle object is null !";
Status = EOperationStatus.Failed;
}
else
{
_steps = ESteps.Done;
Result = assetBundle;
Status = EOperationStatus.Succeed;
}
}
else
{