update operation system

异步操作增加执行优先级
pull/229/head
hevinci 2023-10-27 16:08:38 +08:00
parent 9418544264
commit bc9a4e07e2
20 changed files with 391 additions and 429 deletions

View File

@ -224,7 +224,7 @@ namespace YooAsset.Editor
// Status // Status
StyleColor textColor; StyleColor textColor;
if (providerInfo.Status == ProviderBase.EStatus.Failed.ToString()) if (providerInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow); textColor = new StyleColor(Color.yellow);
else else
textColor = label1.style.color; textColor = label1.style.color;

View File

@ -80,12 +80,6 @@ namespace YooAsset
/// </summary> /// </summary>
public bool AutoDestroyAssetProvider = false; public bool AutoDestroyAssetProvider = false;
/// <summary>
/// 资源加载每帧处理的最大时间片段
/// 注意默认值为MaxValue
/// </summary>
public long LoadingMaxTimeSlice = long.MaxValue;
/// <summary> /// <summary>
/// 启用断点续传参数 /// 启用断点续传参数
/// 说明:当文件的大小大于设置的字节数时启用断点续传下载器 /// 说明:当文件的大小大于设置的字节数时启用断点续传下载器

View File

@ -5,16 +5,24 @@ using System.Threading.Tasks;
namespace YooAsset namespace YooAsset
{ {
public abstract class AsyncOperationBase : IEnumerator public abstract class AsyncOperationBase : IEnumerator, IComparable<AsyncOperationBase>
{ {
// 用户请求的回调 // 用户请求的回调
private Action<AsyncOperationBase> _callback; private Action<AsyncOperationBase> _callback;
// 是否已经完成
internal bool IsFinish = false;
/// <summary> /// <summary>
/// 所属包裹 /// 所属包裹
/// </summary> /// </summary>
public string PackageName { private set; get; } public string PackageName { private set; get; }
/// <summary>
/// 优先级
/// </summary>
public uint Priority { set; get; } = 0;
/// <summary> /// <summary>
/// 状态 /// 状态
/// </summary> /// </summary>
@ -80,7 +88,7 @@ namespace YooAsset
internal abstract void InternalOnUpdate(); internal abstract void InternalOnUpdate();
internal virtual void InternalOnAbort() { } internal virtual void InternalOnAbort() { }
internal void SetPackageName(string packageName) internal void Init(string packageName)
{ {
PackageName = packageName; PackageName = packageName;
} }
@ -91,8 +99,14 @@ namespace YooAsset
} }
internal void SetFinish() internal void SetFinish()
{ {
IsFinish = true;
// 进度百分百完成
Progress = 1f; Progress = 1f;
_callback?.Invoke(this); //注意如果完成回调内发生异常会导致Task无限期等待
//注意如果完成回调内发生异常会导致Task无限期等待
_callback?.Invoke(this);
if (_taskCompletionSource != null) if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null); _taskCompletionSource.TrySetResult(null);
} }
@ -115,6 +129,13 @@ namespace YooAsset
_callback = null; _callback = null;
} }
#region 排序接口实现
public int CompareTo(AsyncOperationBase other)
{
return other.Priority.CompareTo(this.Priority);
}
#endregion
#region 异步编程相关 #region 异步编程相关
bool IEnumerator.MoveNext() bool IEnumerator.MoveNext()
{ {

View File

@ -45,29 +45,50 @@ namespace YooAsset
{ {
_frameTime = _watch.ElapsedMilliseconds; _frameTime = _watch.ElapsedMilliseconds;
// 添加新的异步操作 // 添加新的异步操作
if (_newList.Count > 0) if (_newList.Count > 0)
{ {
bool sorting = false;
foreach (var operation in _newList)
{
if (operation.Priority > 0)
{
sorting = true;
break;
}
}
_operations.AddRange(_newList); _operations.AddRange(_newList);
_newList.Clear(); _newList.Clear();
// 重新排序优先级
if (sorting)
_operations.Sort();
} }
// 更新所有的异步操作 // 更新进行中的异步操作
for (int i = _operations.Count - 1; i >= 0; i--) for (int i = 0; i < _operations.Count; i++)
{ {
if (IsBusy) if (IsBusy)
break; break;
var operation = _operations[i]; var operation = _operations[i];
if (operation.IsFinish)
continue;
if (operation.IsDone == false) if (operation.IsDone == false)
operation.InternalOnUpdate(); operation.InternalOnUpdate();
if (operation.IsDone) if (operation.IsDone)
{
// 注意:如果业务端发生异常,保证异步操作提前移除。
_operations.RemoveAt(i);
operation.SetFinish(); operation.SetFinish();
} }
// 移除已经完成的异步操作
for (int i = _operations.Count - 1; i >= 0; i--)
{
var operation = _operations[i];
if (operation.IsFinish)
_operations.RemoveAt(i);
} }
} }
@ -113,7 +134,7 @@ namespace YooAsset
public static void StartOperation(string packageName, AsyncOperationBase operation) public static void StartOperation(string packageName, AsyncOperationBase operation)
{ {
_newList.Add(operation); _newList.Add(operation);
operation.SetPackageName(packageName); operation.Init(packageName);
operation.SetStart(); operation.SetStart();
} }
} }

View File

@ -45,15 +45,7 @@ namespace YooAsset
if (IsValidWithWarning == false) if (IsValidWithWarning == false)
return EOperationStatus.None; return EOperationStatus.None;
var status = Provider.Status; return Provider.Status;
if (status == ProviderBase.EStatus.None)
return EOperationStatus.None;
else if (status == ProviderBase.EStatus.Succeed)
return EOperationStatus.Succeed;
else if (status == ProviderBase.EStatus.Failed)
return EOperationStatus.Failed;
else
return EOperationStatus.Processing;
} }
} }
@ -66,7 +58,7 @@ namespace YooAsset
{ {
if (IsValidWithWarning == false) if (IsValidWithWarning == false)
return string.Empty; return string.Empty;
return Provider.LastError; return Provider.Error;
} }
} }

View File

@ -110,12 +110,6 @@ namespace YooAsset
/// </summary> /// </summary>
public void TryDestroyProviders() public void TryDestroyProviders()
{ {
// TODO 不用等待资源包加载完成
/*
if (IsDone() == false)
return;
*/
// 获取移除列表 // 获取移除列表
_removeList.Clear(); _removeList.Clear();
foreach (var provider in _providers) foreach (var provider in _providers)

View File

@ -8,23 +8,25 @@ namespace YooAsset
{ {
private AssetBundleRequest _cacheRequest; private AssetBundleRequest _cacheRequest;
public BundledAllAssetsProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public BundledAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{ {
DebugBeginRecording(); DebugBeginRecording();
}
internal override void InternalOnUpdate()
{
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -39,17 +41,15 @@ namespace YooAsset
if (DependBundles.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; string error = DependBundles.GetLastError();
LastError = DependBundles.GetLastError(); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
@ -59,11 +59,11 @@ namespace YooAsset
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (IsWaitForAsyncComplete || IsForceDestroyComplete) if (IsWaitForAsyncComplete || IsForceDestroyComplete)
{ {
@ -79,11 +79,11 @@ namespace YooAsset
else else
_cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType); _cacheRequest = OwnerBundle.CacheBundle.LoadAllAssetsAsync(MainAssetInfo.AssetType);
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
if (_cacheRequest != null) if (_cacheRequest != null)
{ {
@ -102,16 +102,20 @@ namespace YooAsset
} }
} }
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; if (AllAssetObjects == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
else else
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
} }
} }

View File

@ -8,23 +8,25 @@ namespace YooAsset
{ {
private AssetBundleRequest _cacheRequest; private AssetBundleRequest _cacheRequest;
public BundledAssetProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public BundledAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{ {
DebugBeginRecording(); DebugBeginRecording();
}
internal override void InternalOnUpdate()
{
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -39,17 +41,15 @@ namespace YooAsset
if (DependBundles.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; string error = DependBundles.GetLastError();
LastError = DependBundles.GetLastError(); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
@ -59,11 +59,11 @@ namespace YooAsset
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (IsWaitForAsyncComplete || IsForceDestroyComplete) if (IsWaitForAsyncComplete || IsForceDestroyComplete)
{ {
@ -79,11 +79,11 @@ namespace YooAsset
else else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
if (_cacheRequest != null) if (_cacheRequest != null)
{ {
@ -102,16 +102,20 @@ namespace YooAsset
} }
} }
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed; if (AssetObject == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
else else
LastError = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
} }
} }

View File

@ -3,23 +3,25 @@ namespace YooAsset
{ {
internal class BundledRawFileProvider : ProviderBase internal class BundledRawFileProvider : ProviderBase
{ {
public BundledRawFileProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public BundledRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{ {
DebugBeginRecording(); DebugBeginRecording();
}
internal override void InternalOnUpdate()
{
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -31,21 +33,19 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 2. 检测加载结果 // 2. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
RawFilePath = OwnerBundle.FileLoadPath; RawFilePath = OwnerBundle.FileLoadPath;
Status = EStatus.Succeed; InvokeCompletion(string.Empty, EOperationStatus.Succeed);
InvokeCompletion();
} }
} }
} }

View File

@ -12,26 +12,28 @@ namespace YooAsset
private readonly bool _suspendLoad; private readonly bool _suspendLoad;
private AsyncOperation _asyncOperation; private AsyncOperation _asyncOperation;
public BundledSceneProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, providerPriority, assetInfo) public BundledSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath); SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
_suspendLoad = suspendLoad; _suspendLoad = suspendLoad;
} }
public override void Update() internal override void InternalOnStart()
{ {
DebugBeginRecording(); DebugBeginRecording();
}
internal override void InternalOnUpdate()
{
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (DependBundles.IsDone() == false) if (DependBundles.IsDone() == false)
return; return;
@ -40,57 +42,57 @@ namespace YooAsset
if (DependBundles.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; string error = DependBundles.GetLastError();
LastError = DependBundles.GetLastError(); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载场景 // 2. 加载场景
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
// 注意如果场景不存在则返回NULL // 注意如果场景不存在则返回NULL
_asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode); _asyncOperation = SceneManager.LoadSceneAsync(MainAssetInfo.AssetPath, SceneMode);
if (_asyncOperation != null) if (_asyncOperation != null)
{ {
_asyncOperation.allowSceneActivation = !_suspendLoad; _asyncOperation.allowSceneActivation = !_suspendLoad;
_asyncOperation.priority = (int)ProviderPriority; _asyncOperation.priority = 100;
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
else else
{ {
Status = EStatus.Failed; string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
} }
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
Progress = _asyncOperation.progress; Progress = _asyncOperation.progress;
if (_asyncOperation.isDone) if (_asyncOperation.isDone)
{ {
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; if (SceneObject.IsValid())
if (Status == EStatus.Failed)
{ {
LastError = $"The load scene is invalid : {MainAssetInfo.AssetPath}"; InvokeCompletion(string.Empty, EOperationStatus.Succeed);
YooLogger.Error(LastError); }
else
{
string error = $"The load scene is invalid : {MainAssetInfo.AssetPath}";
YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
} }
InvokeCompletion();
} }
} }
} }

View File

@ -8,23 +8,25 @@ namespace YooAsset
{ {
private AssetBundleRequest _cacheRequest; private AssetBundleRequest _cacheRequest;
public BundledSubAssetsProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public BundledSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{ {
DebugBeginRecording(); DebugBeginRecording();
}
internal override void InternalOnUpdate()
{
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -39,17 +41,15 @@ namespace YooAsset
if (DependBundles.IsSucceed() == false) if (DependBundles.IsSucceed() == false)
{ {
Status = EStatus.Failed; string error = DependBundles.GetLastError();
LastError = DependBundles.GetLastError(); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
@ -59,11 +59,11 @@ namespace YooAsset
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (IsWaitForAsyncComplete || IsForceDestroyComplete) if (IsWaitForAsyncComplete || IsForceDestroyComplete)
{ {
@ -79,11 +79,11 @@ namespace YooAsset
else else
_cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType); _cacheRequest = OwnerBundle.CacheBundle.LoadAssetWithSubAssetsAsync(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
if (_cacheRequest != null) if (_cacheRequest != null)
{ {
@ -102,16 +102,20 @@ namespace YooAsset
} }
} }
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; if (AllAssetObjects == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
else else
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}"; error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {OwnerBundle.MainBundleInfo.Bundle.BundleName}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
} }
} }

View File

@ -3,19 +3,22 @@ namespace YooAsset
{ {
internal sealed class CompletedProvider : ProviderBase internal sealed class CompletedProvider : ProviderBase
{ {
public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, 0, assetInfo) public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, assetInfo)
{ {
} }
public override void Update()
internal override void InternalOnStart()
{ {
} }
internal override void InternalOnUpdate()
{
}
public void SetCompleted(string error) public void SetCompleted(string error)
{ {
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.Failed; InvokeCompletion(error, EOperationStatus.Failed);
LastError = error;
InvokeCompletion();
} }
} }
} }

View File

@ -6,29 +6,32 @@ namespace YooAsset
{ {
internal sealed class DatabaseAllAssetsProvider : ProviderBase internal sealed class DatabaseAllAssetsProvider : ProviderBase
{ {
public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{
DebugBeginRecording();
}
internal override void InternalOnUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Failed; string error = $"Not found asset : {MainAssetInfo.AssetPath}";
LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
// 注意:模拟异步加载效果提前返回 // 注意:模拟异步加载效果提前返回
if (IsWaitForAsyncComplete == false) if (IsWaitForAsyncComplete == false)
@ -36,7 +39,7 @@ namespace YooAsset
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -48,17 +51,16 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
{ {
@ -82,22 +84,26 @@ namespace YooAsset
} }
AllAssetObjects = result.ToArray(); AllAssetObjects = result.ToArray();
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; if (AllAssetObjects == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null"; error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null";
else else
LastError = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}"; error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
#endif #endif
} }

View File

@ -6,29 +6,32 @@ namespace YooAsset
{ {
internal sealed class DatabaseAssetProvider : ProviderBase internal sealed class DatabaseAssetProvider : ProviderBase
{ {
public DatabaseAssetProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public DatabaseAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{
DebugBeginRecording();
}
internal override void InternalOnUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Failed; string error = $"Not found asset : {MainAssetInfo.AssetPath}";
LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
// 注意:模拟异步加载效果提前返回 // 注意:模拟异步加载效果提前返回
if (IsWaitForAsyncComplete == false) if (IsWaitForAsyncComplete == false)
@ -36,7 +39,7 @@ namespace YooAsset
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -48,38 +51,41 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath); AssetObject = UnityEditor.AssetDatabase.LoadMainAssetAtPath(MainAssetInfo.AssetPath);
else else
AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType); AssetObject = UnityEditor.AssetDatabase.LoadAssetAtPath(MainAssetInfo.AssetPath, MainAssetInfo.AssetType);
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
Status = AssetObject == null ? EStatus.Failed : EStatus.Succeed; if (AssetObject == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null"; error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : null";
else else
LastError = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}"; error = $"Failed to load asset object : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
#endif #endif
} }

View File

@ -3,29 +3,32 @@ namespace YooAsset
{ {
internal class DatabaseRawFileProvider : ProviderBase internal class DatabaseRawFileProvider : ProviderBase
{ {
public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{
DebugBeginRecording();
}
internal override void InternalOnUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Failed; string error = $"Not found asset : {MainAssetInfo.AssetPath}";
LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
// 注意:模拟异步加载效果提前返回 // 注意:模拟异步加载效果提前返回
if (IsWaitForAsyncComplete == false) if (IsWaitForAsyncComplete == false)
@ -33,7 +36,7 @@ namespace YooAsset
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -45,21 +48,19 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 2. 检测加载结果 // 2. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
RawFilePath = MainAssetInfo.AssetPath; RawFilePath = MainAssetInfo.AssetPath;
Status = EStatus.Succeed; InvokeCompletion(string.Empty, EOperationStatus.Succeed);
InvokeCompletion();
} }
#endif #endif
} }

View File

@ -12,25 +12,29 @@ namespace YooAsset
private readonly bool _suspendLoad; private readonly bool _suspendLoad;
private AsyncOperation _asyncOperation; private AsyncOperation _asyncOperation;
public DatabaseSceneProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, providerPriority, assetInfo) public DatabaseSceneProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo, LoadSceneMode sceneMode, bool suspendLoad) : base(manager, providerGUID, assetInfo)
{ {
SceneMode = sceneMode; SceneMode = sceneMode;
SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath); SceneName = Path.GetFileNameWithoutExtension(assetInfo.AssetPath);
_suspendLoad = suspendLoad; _suspendLoad = suspendLoad;
} }
public override void Update() internal override void InternalOnStart()
{
DebugBeginRecording();
}
internal override void InternalOnUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -42,17 +46,16 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
LoadSceneParameters loadSceneParameters = new LoadSceneParameters(); LoadSceneParameters loadSceneParameters = new LoadSceneParameters();
loadSceneParameters.loadSceneMode = SceneMode; loadSceneParameters.loadSceneMode = SceneMode;
@ -60,32 +63,34 @@ namespace YooAsset
if (_asyncOperation != null) if (_asyncOperation != null)
{ {
_asyncOperation.allowSceneActivation = !_suspendLoad; _asyncOperation.allowSceneActivation = !_suspendLoad;
_asyncOperation.priority = (int)ProviderPriority; _asyncOperation.priority = 100;
SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1); SceneObject = SceneManager.GetSceneAt(SceneManager.sceneCount - 1);
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
else else
{ {
Status = EStatus.Failed; string error = $"Failed to load scene : {MainAssetInfo.AssetPath}";
LastError = $"Failed to load scene : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
} }
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
Progress = _asyncOperation.progress; Progress = _asyncOperation.progress;
if (_asyncOperation.isDone) if (_asyncOperation.isDone)
{ {
Status = SceneObject.IsValid() ? EStatus.Succeed : EStatus.Failed; if (SceneObject.IsValid())
if (Status == EStatus.Failed)
{ {
LastError = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}"; InvokeCompletion(string.Empty, EOperationStatus.Succeed);
YooLogger.Error(LastError); }
else
{
string error = $"The loaded scene is invalid : {MainAssetInfo.AssetPath}";
YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
} }
InvokeCompletion();
} }
} }
#endif #endif

View File

@ -6,29 +6,32 @@ namespace YooAsset
{ {
internal sealed class DatabaseSubAssetsProvider : ProviderBase internal sealed class DatabaseSubAssetsProvider : ProviderBase
{ {
public DatabaseSubAssetsProvider(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) : base(manager, providerGUID, providerPriority, assetInfo) public DatabaseSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
{ {
} }
public override void Update() internal override void InternalOnStart()
{
DebugBeginRecording();
}
internal override void InternalOnUpdate()
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
if (IsDone) if (IsDone)
return; return;
if (Status == EStatus.None) if (_steps == ESteps.None)
{ {
// 检测资源文件是否存在 // 检测资源文件是否存在
string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath); string guid = UnityEditor.AssetDatabase.AssetPathToGUID(MainAssetInfo.AssetPath);
if (string.IsNullOrEmpty(guid)) if (string.IsNullOrEmpty(guid))
{ {
Status = EStatus.Failed; string error = $"Not found asset : {MainAssetInfo.AssetPath}";
LastError = $"Not found asset : {MainAssetInfo.AssetPath}"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.CheckBundle; _steps = ESteps.CheckBundle;
// 注意:模拟异步加载效果提前返回 // 注意:模拟异步加载效果提前返回
if (IsWaitForAsyncComplete == false) if (IsWaitForAsyncComplete == false)
@ -36,7 +39,7 @@ namespace YooAsset
} }
// 1. 检测资源包 // 1. 检测资源包
if (Status == EStatus.CheckBundle) if (_steps == ESteps.CheckBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{ {
@ -48,17 +51,16 @@ namespace YooAsset
if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed) if (OwnerBundle.Status != BundleLoaderBase.EStatus.Succeed)
{ {
Status = EStatus.Failed; string error = OwnerBundle.LastError;
LastError = OwnerBundle.LastError; InvokeCompletion(error, EOperationStatus.Failed);
InvokeCompletion();
return; return;
} }
Status = EStatus.Loading; _steps = ESteps.Loading;
} }
// 2. 加载资源对象 // 2. 加载资源对象
if (Status == EStatus.Loading) if (_steps == ESteps.Loading)
{ {
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
{ {
@ -75,22 +77,26 @@ namespace YooAsset
} }
AllAssetObjects = result.ToArray(); AllAssetObjects = result.ToArray();
} }
Status = EStatus.Checking; _steps = ESteps.Checking;
} }
// 3. 检测加载结果 // 3. 检测加载结果
if (Status == EStatus.Checking) if (_steps == ESteps.Checking)
{ {
Status = AllAssetObjects == null ? EStatus.Failed : EStatus.Succeed; if (AllAssetObjects == null)
if (Status == EStatus.Failed)
{ {
string error;
if (MainAssetInfo.AssetType == null) if (MainAssetInfo.AssetType == null)
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null"; error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null";
else else
LastError = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}"; error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType}";
YooLogger.Error(LastError); YooLogger.Error(error);
InvokeCompletion(error, EOperationStatus.Failed);
}
else
{
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
} }
InvokeCompletion();
} }
#endif #endif
} }

View File

@ -6,16 +6,15 @@ using System;
namespace YooAsset namespace YooAsset
{ {
internal abstract class ProviderBase : IComparable<ProviderBase> internal abstract class ProviderBase : AsyncOperationBase
{ {
public enum EStatus protected enum ESteps
{ {
None = 0, None = 0,
CheckBundle, CheckBundle,
Loading, Loading,
Checking, Checking,
Succeed, Done,
Failed,
} }
/// <summary> /// <summary>
@ -23,11 +22,6 @@ namespace YooAsset
/// </summary> /// </summary>
public string ProviderGUID { private set; get; } public string ProviderGUID { private set; get; }
/// <summary>
/// 资源加载的优先级
/// </summary>
public uint ProviderPriority { private set; get; }
/// <summary> /// <summary>
/// 所属资源系统 /// 所属资源系统
/// </summary> /// </summary>
@ -63,22 +57,6 @@ namespace YooAsset
/// </summary> /// </summary>
public string RawFilePath { protected set; get; } public string RawFilePath { protected set; get; }
/// <summary>
/// 当前的加载状态
/// </summary>
public EStatus Status { protected set; get; } = EStatus.None;
/// <summary>
/// 最近的错误信息
/// </summary>
public string LastError { protected set; get; } = string.Empty;
/// <summary>
/// 加载进度
/// </summary>
public float Progress { protected set; get; } = 0f;
/// <summary> /// <summary>
/// 引用计数 /// 引用计数
/// </summary> /// </summary>
@ -89,18 +67,8 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsDestroyed { private set; get; } = false; public bool IsDestroyed { private set; get; } = false;
/// <summary>
/// 是否完毕(成功或失败)
/// </summary>
public bool IsDone
{
get
{
return Status == EStatus.Succeed || Status == EStatus.Failed;
}
}
protected ESteps _steps = ESteps.None;
protected BundleLoaderBase OwnerBundle { private set; get; } protected BundleLoaderBase OwnerBundle { private set; get; }
protected DependAssetBundles DependBundles { private set; get; } protected DependAssetBundles DependBundles { private set; get; }
protected bool IsWaitForAsyncComplete { private set; get; } = false; protected bool IsWaitForAsyncComplete { private set; get; } = false;
@ -108,11 +76,10 @@ namespace YooAsset
private readonly List<HandleBase> _handles = new List<HandleBase>(); private readonly List<HandleBase> _handles = new List<HandleBase>();
public ProviderBase(ResourceManager manager, string providerGUID, uint providerPriority, AssetInfo assetInfo) public ProviderBase(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
{ {
ResourceMgr = manager; ResourceMgr = manager;
ProviderGUID = providerGUID; ProviderGUID = providerGUID;
ProviderPriority = providerPriority;
MainAssetInfo = assetInfo; MainAssetInfo = assetInfo;
// 创建资源包加载器 // 创建资源包加载器
@ -128,11 +95,6 @@ namespace YooAsset
} }
} }
/// <summary>
/// 轮询更新方法
/// </summary>
public abstract void Update();
/// <summary> /// <summary>
/// 销毁资源提供者 /// 销毁资源提供者
/// </summary> /// </summary>
@ -140,6 +102,13 @@ namespace YooAsset
{ {
IsDestroyed = true; IsDestroyed = true;
// 检测是否为正常销毁
if (IsDone == false)
{
Error = "User abort !";
Status = EOperationStatus.Failed;
}
// 释放资源包加载器 // 释放资源包加载器
if (OwnerBundle != null) if (OwnerBundle != null)
{ {
@ -159,7 +128,7 @@ namespace YooAsset
public bool CanDestroy() public bool CanDestroy()
{ {
// 注意:在进行资源加载过程时不可以销毁 // 注意:在进行资源加载过程时不可以销毁
if (Status == EStatus.Loading || Status == EStatus.Checking) if (_steps == ESteps.Loading || _steps == ESteps.Checking)
return false; return false;
return RefCount <= 0; return RefCount <= 0;
@ -226,7 +195,7 @@ namespace YooAsset
IsWaitForAsyncComplete = true; IsWaitForAsyncComplete = true;
// 注意:主动轮询更新完成同步加载 // 注意:主动轮询更新完成同步加载
Update(); InternalOnUpdate();
// 验证结果 // 验证结果
if (IsDone == false) if (IsDone == false)
@ -244,7 +213,7 @@ namespace YooAsset
// 注意:主动轮询更新完成同步加载 // 注意:主动轮询更新完成同步加载
// 说明:如果资源包未准备完毕也可以放心销毁。 // 说明:如果资源包未准备完毕也可以放心销毁。
Update(); InternalOnUpdate();
} }
/// <summary> /// <summary>
@ -255,44 +224,21 @@ namespace YooAsset
if (OwnerBundle.IsDestroyed) if (OwnerBundle.IsDestroyed)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
Status = EStatus.Failed; string error = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
LastError = $"The bundle {OwnerBundle.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !"; YooLogger.Error(error);
YooLogger.Error(LastError); InvokeCompletion(Error, EOperationStatus.Failed);
InvokeCompletion();
} }
/// <summary> /// <summary>
/// 异步操作任务 /// 结束流程
/// </summary> /// </summary>
public Task Task protected void InvokeCompletion(string error, EOperationStatus status)
{
get
{
if (_taskCompletionSource == null)
{
_taskCompletionSource = new TaskCompletionSource<object>();
if (IsDone)
_taskCompletionSource.SetResult(null);
}
return _taskCompletionSource.Task;
}
}
#region 排序接口实现
public int CompareTo(ProviderBase other)
{
return other.ProviderPriority.CompareTo(this.ProviderPriority);
}
#endregion
#region 异步编程相关
private TaskCompletionSource<object> _taskCompletionSource;
protected void InvokeCompletion()
{ {
DebugEndRecording(); DebugEndRecording();
// 进度百分百完成 _steps = ESteps.Done;
Progress = 1f; Error = error;
Status = status;
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。 // 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法! // 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
@ -304,11 +250,7 @@ namespace YooAsset
hande.InvokeCallback(); hande.InvokeCallback();
} }
} }
if (_taskCompletionSource != null)
_taskCompletionSource.TrySetResult(null);
} }
#endregion
#region 调试信息相关 #region 调试信息相关
/// <summary> /// <summary>

View File

@ -9,32 +9,17 @@ namespace YooAsset
{ {
internal class ResourceManager internal class ResourceManager
{ {
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000); // 全局场景句柄集合
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
private readonly List<ProviderBase> _providerList = new List<ProviderBase>(5000);
private readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100); private readonly static Dictionary<string, SceneHandle> _sceneHandles = new Dictionary<string, SceneHandle>(100);
private static long _sceneCreateCount = 0; private static long _sceneCreateCount = 0;
private readonly Dictionary<string, ProviderBase> _providerDic = new Dictionary<string, ProviderBase>(5000);
private readonly Dictionary<string, BundleLoaderBase> _loaderDic = new Dictionary<string, BundleLoaderBase>(5000);
private readonly List<BundleLoaderBase> _loaderList = new List<BundleLoaderBase>(5000);
private bool _simulationOnEditor; private bool _simulationOnEditor;
private bool _autoDestroyAssetProvider; private bool _autoDestroyAssetProvider;
private long _loadingMaxTimeSlice;
private IBundleQuery _bundleQuery; private IBundleQuery _bundleQuery;
private bool _isUnloadSafe = true;
// 计时器相关
private Stopwatch _watch;
private long _frameTime;
private bool IsBusy
{
get
{
return _watch.ElapsedMilliseconds - _frameTime >= _loadingMaxTimeSlice;
}
}
/// <summary> /// <summary>
/// 所属包裹 /// 所属包裹
@ -50,13 +35,11 @@ namespace YooAsset
/// <summary> /// <summary>
/// 初始化 /// 初始化
/// </summary> /// </summary>
public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, long loadingMaxTimeSlice, IBundleQuery bundleServices) public void Initialize(bool simulationOnEditor, bool autoDestroyAssetProvider, IBundleQuery bundleServices)
{ {
_simulationOnEditor = simulationOnEditor; _simulationOnEditor = simulationOnEditor;
_autoDestroyAssetProvider = autoDestroyAssetProvider; _autoDestroyAssetProvider = autoDestroyAssetProvider;
_loadingMaxTimeSlice = loadingMaxTimeSlice;
_bundleQuery = bundleServices; _bundleQuery = bundleServices;
_watch = Stopwatch.StartNew();
} }
/// <summary> /// <summary>
@ -64,9 +47,6 @@ namespace YooAsset
/// </summary> /// </summary>
public void Update() public void Update()
{ {
_frameTime = _watch.ElapsedMilliseconds;
// 更新加载器
foreach (var loader in _loaderList) foreach (var loader in _loaderList)
{ {
loader.Update(); loader.Update();
@ -74,17 +54,6 @@ namespace YooAsset
if (_autoDestroyAssetProvider) if (_autoDestroyAssetProvider)
loader.TryDestroyProviders(); loader.TryDestroyProviders();
} }
// 更新资源提供者
// 注意:循环更新的时候,可能会扩展列表
_isUnloadSafe = false;
for (int i = 0; i < _providerList.Count; i++)
{
if (IsBusy)
break;
_providerList[i].Update();
}
_isUnloadSafe = true;
} }
/// <summary> /// <summary>
@ -92,12 +61,6 @@ namespace YooAsset
/// </summary> /// </summary>
public void UnloadUnusedAssets() public void UnloadUnusedAssets()
{ {
if (_isUnloadSafe == false)
{
YooLogger.Warning("Can not unload unused assets when processing resource loading !");
return;
}
// 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。 // 注意:资源包之间可能存在多层深层嵌套,需要多次循环释放。
int loopCount = 10; int loopCount = 10;
for (int i = 0; i < loopCount; i++) for (int i = 0; i < loopCount; i++)
@ -191,13 +154,13 @@ namespace YooAsset
} }
// 释放所有资源句柄 // 释放所有资源句柄
foreach (var provider in _providerList) foreach (var provider in _providerDic.Values)
{ {
provider.ReleaseAllHandles(); provider.ReleaseAllHandles();
} }
// 强制销毁资源提供者 // 强制销毁资源提供者
foreach (var provider in _providerList) foreach (var provider in _providerDic.Values)
{ {
provider.ForceDestroyComplete(); provider.ForceDestroyComplete();
provider.Destroy(); provider.Destroy();
@ -211,7 +174,6 @@ namespace YooAsset
} }
// 清空数据 // 清空数据
_providerList.Clear();
_providerDic.Clear(); _providerDic.Clear();
_loaderList.Clear(); _loaderList.Clear();
_loaderDic.Clear(); _loaderDic.Clear();
@ -248,18 +210,15 @@ namespace YooAsset
ProviderBase provider; ProviderBase provider;
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseSceneProvider(this, providerGUID, priority, assetInfo, sceneMode, suspendLoad); provider = new DatabaseSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
else else
provider = new BundledSceneProvider(this, providerGUID, priority, assetInfo, sceneMode, suspendLoad); provider = new BundledSceneProvider(this, providerGUID, assetInfo, sceneMode, suspendLoad);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);
if (priority > 0) OperationSystem.StartOperation(PackageName, provider);
{
_providerList.Sort();
}
} }
provider.Priority = priority;
var handle = provider.CreateHandle<SceneHandle>(); var handle = provider.CreateHandle<SceneHandle>();
handle.PackageName = PackageName; handle.PackageName = PackageName;
_sceneHandles.Add(providerGUID, handle); _sceneHandles.Add(providerGUID, handle);
@ -284,17 +243,15 @@ namespace YooAsset
if (provider == null) if (provider == null)
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseAssetProvider(this, providerGUID, priority, assetInfo); provider = new DatabaseAssetProvider(this, providerGUID, assetInfo);
else else
provider = new BundledAssetProvider(this, providerGUID, priority, assetInfo); provider = new BundledAssetProvider(this, providerGUID, assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);
if (priority > 0) OperationSystem.StartOperation(PackageName, provider);
{
_providerList.Sort();
}
} }
provider.Priority = priority;
return provider.CreateHandle<AssetHandle>(); return provider.CreateHandle<AssetHandle>();
} }
@ -316,17 +273,15 @@ namespace YooAsset
if (provider == null) if (provider == null)
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseSubAssetsProvider(this, providerGUID, priority, assetInfo); provider = new DatabaseSubAssetsProvider(this, providerGUID, assetInfo);
else else
provider = new BundledSubAssetsProvider(this, providerGUID, priority, assetInfo); provider = new BundledSubAssetsProvider(this, providerGUID, assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);
if (priority > 0) OperationSystem.StartOperation(PackageName, provider);
{
_providerList.Sort();
}
} }
provider.Priority = priority;
return provider.CreateHandle<SubAssetsHandle>(); return provider.CreateHandle<SubAssetsHandle>();
} }
@ -348,17 +303,15 @@ namespace YooAsset
if (provider == null) if (provider == null)
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseAllAssetsProvider(this, providerGUID, priority, assetInfo); provider = new DatabaseAllAssetsProvider(this, providerGUID, assetInfo);
else else
provider = new BundledAllAssetsProvider(this, providerGUID, priority, assetInfo); provider = new BundledAllAssetsProvider(this, providerGUID, assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);
if (priority > 0) OperationSystem.StartOperation(PackageName, provider);
{
_providerList.Sort();
}
} }
provider.Priority = priority;
return provider.CreateHandle<AllAssetsHandle>(); return provider.CreateHandle<AllAssetsHandle>();
} }
@ -380,17 +333,15 @@ namespace YooAsset
if (provider == null) if (provider == null)
{ {
if (_simulationOnEditor) if (_simulationOnEditor)
provider = new DatabaseRawFileProvider(this, providerGUID, priority, assetInfo); provider = new DatabaseRawFileProvider(this, providerGUID, assetInfo);
else else
provider = new BundledRawFileProvider(this, providerGUID, priority, assetInfo); provider = new BundledRawFileProvider(this, providerGUID, assetInfo);
provider.InitSpawnDebugInfo(); provider.InitSpawnDebugInfo();
_providerList.Add(provider);
_providerDic.Add(providerGUID, provider); _providerDic.Add(providerGUID, provider);
if (priority > 0) OperationSystem.StartOperation(PackageName, provider);
{
_providerList.Sort();
}
} }
provider.Priority = priority;
return provider.CreateHandle<RawFileHandle>(); return provider.CreateHandle<RawFileHandle>();
} }
@ -463,7 +414,6 @@ namespace YooAsset
{ {
foreach (var provider in removeList) foreach (var provider in removeList)
{ {
_providerList.Remove(provider);
_providerDic.Remove(provider.ProviderGUID); _providerDic.Remove(provider.ProviderGUID);
} }
} }
@ -522,8 +472,8 @@ namespace YooAsset
#region 调试信息 #region 调试信息
internal List<DebugProviderInfo> GetDebugReportInfos() internal List<DebugProviderInfo> GetDebugReportInfos()
{ {
List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerList.Count); List<DebugProviderInfo> result = new List<DebugProviderInfo>(_providerDic.Count);
foreach (var provider in _providerList) foreach (var provider in _providerDic.Values)
{ {
DebugProviderInfo providerInfo = new DebugProviderInfo(); DebugProviderInfo providerInfo = new DebugProviderInfo();
providerInfo.AssetPath = provider.MainAssetInfo.AssetPath; providerInfo.AssetPath = provider.MainAssetInfo.AssetPath;

View File

@ -146,7 +146,7 @@ namespace YooAsset
var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName); var editorSimulateModeImpl = new EditorSimulateModeImpl(PackageName);
_bundleQuery = editorSimulateModeImpl; _bundleQuery = editorSimulateModeImpl;
_playModeImpl = editorSimulateModeImpl; _playModeImpl = editorSimulateModeImpl;
_resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery); _resourceMgr.Initialize(true, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as EditorSimulateModeParameters; var initializeParameters = parameters as EditorSimulateModeParameters;
initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath); initializeOperation = editorSimulateModeImpl.InitializeAsync(assist, initializeParameters.SimulateManifestFilePath);
@ -156,7 +156,7 @@ namespace YooAsset
var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName); var offlinePlayModeImpl = new OfflinePlayModeImpl(PackageName);
_bundleQuery = offlinePlayModeImpl; _bundleQuery = offlinePlayModeImpl;
_playModeImpl = offlinePlayModeImpl; _playModeImpl = offlinePlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery); _resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as OfflinePlayModeParameters; var initializeParameters = parameters as OfflinePlayModeParameters;
initializeOperation = offlinePlayModeImpl.InitializeAsync(assist); initializeOperation = offlinePlayModeImpl.InitializeAsync(assist);
@ -166,7 +166,7 @@ namespace YooAsset
var hostPlayModeImpl = new HostPlayModeImpl(PackageName); var hostPlayModeImpl = new HostPlayModeImpl(PackageName);
_bundleQuery = hostPlayModeImpl; _bundleQuery = hostPlayModeImpl;
_playModeImpl = hostPlayModeImpl; _playModeImpl = hostPlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery); _resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as HostPlayModeParameters; var initializeParameters = parameters as HostPlayModeParameters;
initializeOperation = hostPlayModeImpl.InitializeAsync(assist, initializeOperation = hostPlayModeImpl.InitializeAsync(assist,
@ -179,7 +179,7 @@ namespace YooAsset
var webPlayModeImpl = new WebPlayModeImpl(PackageName); var webPlayModeImpl = new WebPlayModeImpl(PackageName);
_bundleQuery = webPlayModeImpl; _bundleQuery = webPlayModeImpl;
_playModeImpl = webPlayModeImpl; _playModeImpl = webPlayModeImpl;
_resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, parameters.LoadingMaxTimeSlice, _bundleQuery); _resourceMgr.Initialize(false, parameters.AutoDestroyAssetProvider, _bundleQuery);
var initializeParameters = parameters as WebPlayModeParameters; var initializeParameters = parameters as WebPlayModeParameters;
initializeOperation = webPlayModeImpl.InitializeAsync(assist, initializeOperation = webPlayModeImpl.InitializeAsync(assist,
@ -266,13 +266,6 @@ namespace YooAsset
} }
#endif #endif
} }
// 检测参数范围
if (parameters.LoadingMaxTimeSlice < 10)
{
parameters.LoadingMaxTimeSlice = 10;
YooLogger.Warning($"{nameof(parameters.LoadingMaxTimeSlice)} minimum value is 10 milliseconds.");
}
} }
private void InitializeOperation_Completed(AsyncOperationBase op) private void InitializeOperation_Completed(AsyncOperationBase op)
{ {
@ -566,6 +559,7 @@ namespace YooAsset
/// 异步加载原生文件 /// 异步加载原生文件
/// </summary> /// </summary>
/// <param name="assetInfo">资源信息</param> /// <param name="assetInfo">资源信息</param>
/// <param name="priority">加载的优先级</param>
public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0) public RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -576,6 +570,7 @@ namespace YooAsset
/// 异步加载原生文件 /// 异步加载原生文件
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public RawFileHandle LoadRawFileAsync(string location, uint priority = 0) public RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -601,8 +596,8 @@ namespace YooAsset
/// <param name="location">场景的定位地址</param> /// <param name="location">场景的定位地址</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="suspendLoad">场景加载到90%自动挂起</param> /// <param name="suspendLoad">场景加载到90%自动挂起</param>
/// <param name="priority">优先级</param> /// <param name="priority">加载的优先级</param>
public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100) public SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null); AssetInfo assetInfo = ConvertLocationToAssetInfo(location, null);
@ -616,8 +611,8 @@ namespace YooAsset
/// <param name="assetInfo">场景的资源信息</param> /// <param name="assetInfo">场景的资源信息</param>
/// <param name="sceneMode">场景加载模式</param> /// <param name="sceneMode">场景加载模式</param>
/// <param name="suspendLoad">场景加载到90%自动挂起</param> /// <param name="suspendLoad">场景加载到90%自动挂起</param>
/// <param name="priority">优先级</param> /// <param name="priority">加载的优先级</param>
public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 100) public SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, bool suspendLoad = false, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority); var handle = _resourceMgr.LoadSceneAsync(assetInfo, sceneMode, suspendLoad, priority);
@ -677,6 +672,7 @@ namespace YooAsset
/// 异步加载资源对象 /// 异步加载资源对象
/// </summary> /// </summary>
/// <param name="assetInfo">资源信息</param> /// <param name="assetInfo">资源信息</param>
/// <param name="priority">加载的优先级</param>
public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0) public AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -688,6 +684,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <typeparam name="TObject">资源类型</typeparam> /// <typeparam name="TObject">资源类型</typeparam>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object public AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -700,6 +697,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="type">资源类型</param> /// <param name="type">资源类型</param>
/// <param name="priority">加载的优先级</param>
public AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0) public AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -711,6 +709,7 @@ namespace YooAsset
/// 异步加载资源对象 /// 异步加载资源对象
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public AssetHandle LoadAssetAsync(string location, uint priority = 0) public AssetHandle LoadAssetAsync(string location, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -783,6 +782,7 @@ namespace YooAsset
/// 异步加载子资源对象 /// 异步加载子资源对象
/// </summary> /// </summary>
/// <param name="assetInfo">资源信息</param> /// <param name="assetInfo">资源信息</param>
/// <param name="priority">加载的优先级</param>
public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0) public SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -794,6 +794,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <typeparam name="TObject">资源类型</typeparam> /// <typeparam name="TObject">资源类型</typeparam>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object public SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -806,6 +807,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="type">子对象类型</param> /// <param name="type">子对象类型</param>
/// <param name="priority">加载的优先级</param>
public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0) public SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -817,6 +819,7 @@ namespace YooAsset
/// 异步加载子资源对象 /// 异步加载子资源对象
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0) public SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -889,6 +892,7 @@ namespace YooAsset
/// 异步加载资源包内所有资源对象 /// 异步加载资源包内所有资源对象
/// </summary> /// </summary>
/// <param name="assetInfo">资源信息</param> /// <param name="assetInfo">资源信息</param>
/// <param name="priority">加载的优先级</param>
public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0) public AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -900,6 +904,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <typeparam name="TObject">资源类型</typeparam> /// <typeparam name="TObject">资源类型</typeparam>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object public AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -912,6 +917,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="type">子对象类型</param> /// <param name="type">子对象类型</param>
/// <param name="priority">加载的优先级</param>
public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0) public AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
@ -923,6 +929,7 @@ namespace YooAsset
/// 异步加载资源包内所有资源对象 /// 异步加载资源包内所有资源对象
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param> /// <param name="location">资源的定位地址</param>
/// <param name="priority">加载的优先级</param>
public AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0) public AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
{ {
DebugCheckInitialize(); DebugCheckInitialize();