update operation logic
This commit is contained in:
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class BundledAllAssetsProvider : ProviderBase
|
||||
internal sealed class BundledAllAssetsProvider : ProviderOperation
|
||||
{
|
||||
private AssetBundle _assetBundle;
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
@@ -29,45 +29,37 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
DependLoaders.WaitForAsyncComplete();
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (DependLoaders.IsDone() == false)
|
||||
if (LoadDependBundleFileOp.IsDone == false)
|
||||
return;
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (DependLoaders.IsSucceed() == false)
|
||||
if (LoadDependBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = DependLoaders.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadDependBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result == null)
|
||||
if (LoadBundleFileOp.Result == null)
|
||||
{
|
||||
ProcessFatalEvent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result is AssetBundle == false)
|
||||
if (LoadBundleFileOp.Result is AssetBundle == false)
|
||||
{
|
||||
string error = "Try load raw file using load assetbundle method !";
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
_assetBundle = FileLoader.Result as AssetBundle;
|
||||
_assetBundle = LoadBundleFileOp.Result as AssetBundle;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
@@ -115,9 +107,9 @@ namespace YooAsset
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
else
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load all assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class BundledAssetProvider : ProviderBase
|
||||
internal sealed class BundledAssetProvider : ProviderOperation
|
||||
{
|
||||
private AssetBundle _assetBundle;
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
@@ -29,45 +29,37 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
DependLoaders.WaitForAsyncComplete();
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (DependLoaders.IsDone() == false)
|
||||
if (LoadDependBundleFileOp.IsDone == false)
|
||||
return;
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (DependLoaders.IsSucceed() == false)
|
||||
if (LoadDependBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = DependLoaders.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadDependBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result == null)
|
||||
if (LoadBundleFileOp.Result == null)
|
||||
{
|
||||
ProcessFatalEvent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result is AssetBundle == false)
|
||||
if (LoadBundleFileOp.Result is AssetBundle == false)
|
||||
{
|
||||
string error = "Try load raw file using load assetbundle method !";
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
_assetBundle = FileLoader.Result as AssetBundle;
|
||||
_assetBundle = LoadBundleFileOp.Result as AssetBundle;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
@@ -115,9 +107,9 @@ namespace YooAsset
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
else
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load asset : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class BundledRawFileProvider : ProviderBase
|
||||
internal class BundledRawFileProvider : ProviderOperation
|
||||
{
|
||||
public BundledRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
@@ -23,20 +23,16 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result is string == false)
|
||||
if (LoadBundleFileOp.Result is string == false)
|
||||
{
|
||||
string error = "Try load AssetBundle file using load raw file method !";
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
@@ -49,7 +45,7 @@ namespace YooAsset
|
||||
// 2. 检测加载结果
|
||||
if (_steps == ESteps.Checking)
|
||||
{
|
||||
RawFilePath = FileLoader.Result as string;
|
||||
RawFilePath = LoadBundleFileOp.Result as string;
|
||||
InvokeCompletion(string.Empty, EOperationStatus.Succeed);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class BundledSceneProvider : ProviderBase
|
||||
internal sealed class BundledSceneProvider : ProviderOperation
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private AsyncOperation _asyncOperation;
|
||||
@@ -35,28 +35,20 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
DependLoaders.WaitForAsyncComplete();
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (DependLoaders.IsDone() == false)
|
||||
if (LoadDependBundleFileOp.IsDone == false)
|
||||
return;
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (DependLoaders.IsSucceed() == false)
|
||||
if (LoadDependBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = DependLoaders.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadDependBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class BundledSubAssetsProvider : ProviderBase
|
||||
internal sealed class BundledSubAssetsProvider : ProviderOperation
|
||||
{
|
||||
private AssetBundle _assetBundle;
|
||||
private AssetBundleRequest _cacheRequest;
|
||||
@@ -29,45 +29,37 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
DependLoaders.WaitForAsyncComplete();
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (DependLoaders.IsDone() == false)
|
||||
if (LoadDependBundleFileOp.IsDone == false)
|
||||
return;
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (DependLoaders.IsSucceed() == false)
|
||||
if (LoadDependBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = DependLoaders.GetLastError();
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadDependBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result == null)
|
||||
if (LoadBundleFileOp.Result == null)
|
||||
{
|
||||
ProcessFatalEvent();
|
||||
return;
|
||||
}
|
||||
|
||||
if (FileLoader.Result is AssetBundle == false)
|
||||
if (LoadBundleFileOp.Result is AssetBundle == false)
|
||||
{
|
||||
string error = "Try load raw file using load assetbundle method !";
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
_assetBundle = FileLoader.Result as AssetBundle;
|
||||
_assetBundle = LoadBundleFileOp.Result as AssetBundle;
|
||||
_steps = ESteps.Loading;
|
||||
}
|
||||
|
||||
@@ -115,9 +107,9 @@ namespace YooAsset
|
||||
{
|
||||
string error;
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : null AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
else
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {FileLoader.MainBundleInfo.Bundle.BundleName}";
|
||||
error = $"Failed to load sub assets : {MainAssetInfo.AssetPath} AssetType : {MainAssetInfo.AssetType} AssetBundle : {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName}";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class CompletedProvider : ProviderBase
|
||||
internal sealed class CompletedProvider : ProviderOperation
|
||||
{
|
||||
public CompletedProvider(AssetInfo assetInfo) : base(null, string.Empty, assetInfo)
|
||||
public CompletedProvider(ResourceManager manager, AssetInfo assetInfo) : base(manager, string.Empty, assetInfo)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAllAssetsProvider : ProviderBase
|
||||
internal sealed class DatabaseAllAssetsProvider : ProviderOperation
|
||||
{
|
||||
public DatabaseAllAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
@@ -41,16 +41,12 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +59,7 @@ namespace YooAsset
|
||||
if (MainAssetInfo.AssetType == null)
|
||||
{
|
||||
List<UnityEngine.Object> result = new List<Object>();
|
||||
foreach (var assetPath in FileLoader.MainBundleInfo.IncludeAssetsInEditor)
|
||||
foreach (var assetPath in LoadBundleFileOp.BundleFileInfo.IncludeAssetsInEditor)
|
||||
{
|
||||
UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadMainAssetAtPath(assetPath);
|
||||
if (mainAsset != null)
|
||||
@@ -74,7 +70,7 @@ namespace YooAsset
|
||||
else
|
||||
{
|
||||
List<UnityEngine.Object> result = new List<Object>();
|
||||
foreach (var assetPath in FileLoader.MainBundleInfo.IncludeAssetsInEditor)
|
||||
foreach (var assetPath in LoadBundleFileOp.BundleFileInfo.IncludeAssetsInEditor)
|
||||
{
|
||||
UnityEngine.Object mainAsset = UnityEditor.AssetDatabase.LoadAssetAtPath(assetPath, MainAssetInfo.AssetType);
|
||||
if (mainAsset != null)
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseAssetProvider : ProviderBase
|
||||
internal sealed class DatabaseAssetProvider : ProviderOperation
|
||||
{
|
||||
public DatabaseAssetProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
@@ -41,16 +41,12 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DatabaseRawFileProvider : ProviderBase
|
||||
internal class DatabaseRawFileProvider : ProviderOperation
|
||||
{
|
||||
public DatabaseRawFileProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
@@ -38,16 +38,12 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseSceneProvider : ProviderBase
|
||||
internal sealed class DatabaseSceneProvider : ProviderOperation
|
||||
{
|
||||
public readonly LoadSceneMode SceneMode;
|
||||
private bool _suspendLoadMode;
|
||||
@@ -36,16 +36,12 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DatabaseSubAssetsProvider : ProviderBase
|
||||
internal sealed class DatabaseSubAssetsProvider : ProviderOperation
|
||||
{
|
||||
public DatabaseSubAssetsProvider(ResourceManager manager, string providerGUID, AssetInfo assetInfo) : base(manager, providerGUID, assetInfo)
|
||||
{
|
||||
@@ -41,16 +41,12 @@ namespace YooAsset
|
||||
// 1. 检测资源包
|
||||
if (_steps == ESteps.CheckBundle)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
FileLoader.WaitForAsyncComplete();
|
||||
|
||||
if (FileLoader.IsDone() == false)
|
||||
if (LoadBundleFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (FileLoader.Status != BundleFileLoader.EStatus.Succeed)
|
||||
if (LoadBundleFileOp.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
string error = FileLoader.LastError;
|
||||
InvokeCompletion(error, EOperationStatus.Failed);
|
||||
InvokeCompletion(LoadBundleFileOp.Error, EOperationStatus.Failed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+42
-37
@@ -5,7 +5,7 @@ using System;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal abstract class ProviderBase : AsyncOperationBase
|
||||
internal abstract class ProviderOperation : AsyncOperationBase
|
||||
{
|
||||
protected enum ESteps
|
||||
{
|
||||
@@ -68,47 +68,52 @@ namespace YooAsset
|
||||
|
||||
|
||||
protected ESteps _steps = ESteps.None;
|
||||
protected BundleFileLoader FileLoader { private set; get; }
|
||||
protected DependFileLoaders DependLoaders { private set; get; }
|
||||
protected LoadBundleFileOperation LoadBundleFileOp { private set; get; }
|
||||
protected LoadDependBundleFileOperation LoadDependBundleFileOp { private set; get; }
|
||||
protected bool IsWaitForAsyncComplete { private set; get; } = false;
|
||||
private readonly List<HandleBase> _handles = new List<HandleBase>();
|
||||
|
||||
|
||||
public ProviderBase(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
{
|
||||
ResourceMgr = manager;
|
||||
ProviderGUID = providerGUID;
|
||||
MainAssetInfo = assetInfo;
|
||||
|
||||
// 创建资源包加载器
|
||||
if (manager != null)
|
||||
if (string.IsNullOrEmpty(providerGUID) == false)
|
||||
{
|
||||
FileLoader = manager.CreateOwnerFileLoader(assetInfo);
|
||||
FileLoader.Reference();
|
||||
FileLoader.AddProvider(this);
|
||||
LoadBundleFileOp = manager.CreateMainBundleFileLoader(assetInfo);
|
||||
LoadBundleFileOp.Reference();
|
||||
LoadBundleFileOp.AddProvider(this);
|
||||
|
||||
var dependList = manager.CreateDependFileLoaders(assetInfo);
|
||||
DependLoaders = new DependFileLoaders(dependList);
|
||||
DependLoaders.Reference();
|
||||
LoadDependBundleFileOp = manager.CreateDependFileLoaders(assetInfo);
|
||||
LoadDependBundleFileOp.Reference();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 等待异步执行完毕
|
||||
/// </summary>
|
||||
public override void WaitForAsyncComplete()
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
IsWaitForAsyncComplete = true;
|
||||
|
||||
// 注意:主动轮询更新完成同步加载
|
||||
InternalOnUpdate();
|
||||
DebugCheckWaitForAsyncComplete($"Loading asset {MainAssetInfo.AssetPath}");
|
||||
while (true)
|
||||
{
|
||||
if (LoadDependBundleFileOp != null)
|
||||
LoadDependBundleFileOp.WaitForAsyncComplete();
|
||||
if (LoadBundleFileOp != null)
|
||||
LoadBundleFileOp.WaitForAsyncComplete();
|
||||
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 销毁资源提供者
|
||||
/// </summary>
|
||||
public void Destroy()
|
||||
public void DestroyProvider()
|
||||
{
|
||||
IsDestroyed = true;
|
||||
|
||||
@@ -120,22 +125,22 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
// 释放资源包加载器
|
||||
if (FileLoader != null)
|
||||
if (LoadBundleFileOp != null)
|
||||
{
|
||||
FileLoader.Release();
|
||||
FileLoader = null;
|
||||
LoadBundleFileOp.Release();
|
||||
LoadBundleFileOp = null;
|
||||
}
|
||||
if (DependLoaders != null)
|
||||
if (LoadDependBundleFileOp != null)
|
||||
{
|
||||
DependLoaders.Release();
|
||||
DependLoaders = null;
|
||||
LoadDependBundleFileOp.Release();
|
||||
LoadDependBundleFileOp = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否可以销毁
|
||||
/// </summary>
|
||||
public bool CanDestroy()
|
||||
public bool CanDestroyProvider()
|
||||
{
|
||||
// 注意:在进行资源加载过程时不可以销毁
|
||||
if (_steps == ESteps.Loading || _steps == ESteps.Checking)
|
||||
@@ -202,10 +207,10 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
protected void ProcessFatalEvent()
|
||||
{
|
||||
if (FileLoader.IsDestroyed)
|
||||
if (LoadBundleFileOp.IsDestroyed)
|
||||
throw new System.Exception("Should never get here !");
|
||||
|
||||
string error = $"The bundle {FileLoader.MainBundleInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
string error = $"The bundle {LoadBundleFileOp.BundleFileInfo.Bundle.BundleName} has been destroyed by unity bugs !";
|
||||
YooLogger.Error(error);
|
||||
InvokeCompletion(Error, EOperationStatus.Failed);
|
||||
}
|
||||
@@ -239,11 +244,11 @@ namespace YooAsset
|
||||
public DownloadStatus GetDownloadStatus()
|
||||
{
|
||||
DownloadStatus status = new DownloadStatus();
|
||||
status.TotalBytes = FileLoader.MainBundleInfo.Bundle.FileSize;
|
||||
status.DownloadedBytes = FileLoader.DownloadedBytes;
|
||||
foreach (var dependBundle in DependLoaders.DependList)
|
||||
status.TotalBytes = LoadBundleFileOp.BundleFileInfo.Bundle.FileSize;
|
||||
status.DownloadedBytes = LoadBundleFileOp.DownloadedBytes;
|
||||
foreach (var dependBundle in LoadDependBundleFileOp.Depends)
|
||||
{
|
||||
status.TotalBytes += dependBundle.MainBundleInfo.Bundle.FileSize;
|
||||
status.TotalBytes += dependBundle.BundleFileInfo.Bundle.FileSize;
|
||||
status.DownloadedBytes += dependBundle.DownloadedBytes;
|
||||
}
|
||||
|
||||
@@ -313,12 +318,12 @@ namespace YooAsset
|
||||
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
||||
{
|
||||
var bundleInfo = new DebugBundleInfo();
|
||||
bundleInfo.BundleName = FileLoader.MainBundleInfo.Bundle.BundleName;
|
||||
bundleInfo.RefCount = FileLoader.RefCount;
|
||||
bundleInfo.Status = FileLoader.Status.ToString();
|
||||
bundleInfo.BundleName = LoadBundleFileOp.BundleFileInfo.Bundle.BundleName;
|
||||
bundleInfo.RefCount = LoadBundleFileOp.RefCount;
|
||||
bundleInfo.Status = LoadBundleFileOp.Status;
|
||||
output.Add(bundleInfo);
|
||||
|
||||
DependLoaders.GetBundleDebugInfos(output);
|
||||
LoadDependBundleFileOp.GetBundleDebugInfos(output);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
Reference in New Issue
Block a user