update resource manager
重构运行时核心代码
This commit is contained in:
@@ -22,7 +22,7 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 资源包文件信息
|
||||
/// </summary>
|
||||
public BundleInfo BundleFileInfo { private set; get; }
|
||||
public BundleInfo LoadBundleInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经销毁
|
||||
@@ -47,13 +47,13 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载结果
|
||||
/// </summary>
|
||||
public object Result { set; get; }
|
||||
public BundleResult Result { set; get; }
|
||||
|
||||
|
||||
internal LoadBundleFileOperation(ResourceManager resourceManager, BundleInfo bundleInfo)
|
||||
{
|
||||
_resourceManager = resourceManager;
|
||||
BundleFileInfo = bundleInfo;
|
||||
LoadBundleInfo = bundleInfo;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
@@ -67,7 +67,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.LoadFile)
|
||||
{
|
||||
if (_loadBundleOp == null)
|
||||
_loadBundleOp = BundleFileInfo.LoadBundleFile();
|
||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
_loadBundleOp.WaitForAsyncComplete();
|
||||
@@ -83,7 +83,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The bundle loader result is null ! {BundleFileInfo.Bundle.BundleName}";
|
||||
Error = $"The bundle loader result is null ! {LoadBundleInfo.Bundle.BundleName}";
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -137,11 +137,12 @@ namespace YooAsset
|
||||
|
||||
// Check fatal
|
||||
if (RefCount > 0)
|
||||
throw new Exception($"Bundle file loader ref is not zero : {BundleFileInfo.Bundle.BundleName}");
|
||||
throw new Exception($"Bundle file loader ref is not zero : {LoadBundleInfo.Bundle.BundleName}");
|
||||
if (IsDone == false)
|
||||
throw new Exception($"Bundle file loader is not done : {BundleFileInfo.Bundle.BundleName}");
|
||||
throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}");
|
||||
|
||||
BundleFileInfo.UnloadBundleFile(Result);
|
||||
if (Result != null)
|
||||
Result.UnloadBundleFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadDependBundleFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckDepend,
|
||||
CheckResult,
|
||||
Done,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 依赖的资源包加载器列表
|
||||
/// </summary>
|
||||
internal readonly List<LoadBundleFileOperation> Depends;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal LoadDependBundleFileOperation(List<LoadBundleFileOperation> dpends)
|
||||
{
|
||||
Depends = dpends;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.CheckDepend;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckDepend)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
{
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
loader.WaitForAsyncComplete();
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
if (loader.IsDone == false)
|
||||
return;
|
||||
}
|
||||
_steps = ESteps.CheckResult;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckResult)
|
||||
{
|
||||
LoadBundleFileOperation failedLoader = null;
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
if (loader.Status != EOperationStatus.Succeed)
|
||||
{
|
||||
failedLoader = loader;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (failedLoader == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = failedLoader.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加引用计数
|
||||
/// </summary>
|
||||
public void Reference()
|
||||
{
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
loader.Reference();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 减少引用计数
|
||||
/// </summary>
|
||||
public void Release()
|
||||
{
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
loader.Release();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包的调试信息列表
|
||||
/// </summary>
|
||||
internal void GetBundleDebugInfos(List<DebugBundleInfo> output)
|
||||
{
|
||||
foreach (var loader in Depends)
|
||||
{
|
||||
var bundleInfo = new DebugBundleInfo();
|
||||
bundleInfo.BundleName = loader.BundleFileInfo.Bundle.BundleName;
|
||||
bundleInfo.RefCount = loader.RefCount;
|
||||
bundleInfo.Status = loader.Status;
|
||||
output.Add(bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3834f832061fdd74fbfb1eba381b1b3e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user