2025-01-09 11:31:04 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
namespace YooAsset
|
|
|
|
|
{
|
|
|
|
|
internal sealed class LoadBuildinCatalogFileOperation : AsyncOperationBase
|
|
|
|
|
{
|
|
|
|
|
private enum ESteps
|
|
|
|
|
{
|
|
|
|
|
None,
|
|
|
|
|
LoadCatalog,
|
|
|
|
|
Done,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private readonly DefaultBuildinFileSystem _fileSystem;
|
|
|
|
|
private ESteps _steps = ESteps.None;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
internal LoadBuildinCatalogFileOperation(DefaultBuildinFileSystem fileSystem)
|
|
|
|
|
{
|
|
|
|
|
_fileSystem = fileSystem;
|
|
|
|
|
}
|
2025-02-28 16:11:01 +08:00
|
|
|
|
internal override void InternalStart()
|
2025-01-09 11:31:04 +08:00
|
|
|
|
{
|
|
|
|
|
_steps = ESteps.LoadCatalog;
|
|
|
|
|
}
|
2025-02-28 16:11:01 +08:00
|
|
|
|
internal override void InternalUpdate()
|
2025-01-09 11:31:04 +08:00
|
|
|
|
{
|
|
|
|
|
if (_steps == ESteps.None || _steps == ESteps.Done)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (_steps == ESteps.LoadCatalog)
|
|
|
|
|
{
|
|
|
|
|
string catalogFilePath = _fileSystem.GetCatalogFileLoadPath();
|
|
|
|
|
var catalog = Resources.Load<DefaultBuildinFileCatalog>(catalogFilePath);
|
|
|
|
|
if (catalog == null)
|
|
|
|
|
{
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
Error = $"Failed to load catalog file : {catalogFilePath}";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (catalog.PackageName != _fileSystem.PackageName)
|
|
|
|
|
{
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
Status = EOperationStatus.Failed;
|
|
|
|
|
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (var wrapper in catalog.Wrappers)
|
|
|
|
|
{
|
|
|
|
|
var fileWrapper = new DefaultBuildinFileSystem.FileWrapper(wrapper.FileName);
|
|
|
|
|
_fileSystem.RecordCatalogFile(wrapper.BundleGUID, fileWrapper);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
|
|
|
|
_steps = ESteps.Done;
|
|
|
|
|
Status = EOperationStatus.Succeed;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|