Operation handles support error queries
操作句柄支持错误信息查询。
This commit is contained in:
@@ -43,10 +43,10 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
return;
|
||||
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
|
||||
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromRemote)
|
||||
{
|
||||
_steps = ESteps.Download;
|
||||
_fileLoadPath = BundleFileInfo.GetCacheLoadPath();
|
||||
@@ -83,9 +83,9 @@ namespace YooAsset
|
||||
|
||||
if (_downloader.HasError())
|
||||
{
|
||||
_downloader.ReportError();
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = _downloader.GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -100,9 +100,10 @@ namespace YooAsset
|
||||
// 注意:Unity2017.4编辑器模式下,如果AssetBundle文件不存在会导致编辑器崩溃,这里做了预判。
|
||||
if (System.IO.File.Exists(_fileLoadPath) == false)
|
||||
{
|
||||
YooLogger.Warning($"Not found assetBundle file : {_fileLoadPath}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Not found assetBundle file : {_fileLoadPath}";
|
||||
YooLogger.Error(LastError);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
@@ -151,9 +152,10 @@ namespace YooAsset
|
||||
// Check error
|
||||
if (CacheBundle == null)
|
||||
{
|
||||
YooLogger.Error($"Failed to load assetBundle file : {BundleFileInfo.BundleName}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"Failed to load assetBundle : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -29,6 +29,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public EStatus Status { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 最近的错误信息
|
||||
/// </summary>
|
||||
public string LastError { protected set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经销毁
|
||||
/// </summary>
|
||||
@@ -139,7 +144,7 @@ namespace YooAsset
|
||||
// 销毁所有Providers
|
||||
foreach (var provider in _providers)
|
||||
{
|
||||
provider.Destory();
|
||||
provider.Destroy();
|
||||
}
|
||||
|
||||
// 从列表里移除Providers
|
||||
|
||||
@@ -41,10 +41,10 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
return;
|
||||
LastError = $"Invalid load mode : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
|
||||
if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||
else if (BundleFileInfo.LoadMode == BundleInfo.ELoadMode.LoadFromStreaming)
|
||||
{
|
||||
_steps = ESteps.LoadFile;
|
||||
_webURL = BundleFileInfo.GetStreamingLoadPath();
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset
|
||||
if (_webRequest.isNetworkError || _webRequest.isHttpError)
|
||||
#endif
|
||||
{
|
||||
Debug.LogWarning($"Failed to get asset bundle form web : {_webURL} Error : {_webRequest.error}");
|
||||
YooLogger.Warning($"Failed to get asset bundle form web : {_webURL} Error : {_webRequest.error}");
|
||||
_steps = ESteps.TryLoad;
|
||||
_tryTimer = 0;
|
||||
}
|
||||
@@ -85,9 +85,10 @@ namespace YooAsset
|
||||
CacheBundle = DownloadHandlerAssetBundle.GetContent(_webRequest);
|
||||
if (CacheBundle == null)
|
||||
{
|
||||
Debug.LogError($"Get asset bundle error : {_webRequest.error}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EStatus.Failed;
|
||||
LastError = $"AssetBundle file is invalid : {BundleFileInfo.BundleName}";
|
||||
YooLogger.Error(LastError);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -11,6 +11,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
private readonly List<AssetBundleLoaderBase> _dependBundles;
|
||||
|
||||
|
||||
public DependAssetBundleGrouper(string assetPath)
|
||||
{
|
||||
_dependBundles = AssetSystem.CreateDependAssetBundleLoaders(assetPath);
|
||||
@@ -29,6 +30,36 @@ namespace YooAsset
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依赖资源包是否全部加载成功
|
||||
/// </summary>
|
||||
public bool IsSucceed()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
{
|
||||
if (loader.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取某个加载失败的资源包错误信息
|
||||
/// </summary>
|
||||
public string GetLastError()
|
||||
{
|
||||
foreach (var loader in _dependBundles)
|
||||
{
|
||||
if (loader.Status != AssetBundleLoaderBase.EStatus.Succeed)
|
||||
{
|
||||
return loader.LastError;
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 主线程等待异步操作完毕
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user