update file system
This commit is contained in:
+4
-4
@@ -34,7 +34,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.InitUnpackFileSystem)
|
||||
{
|
||||
if (_initUnpackFIleSystemOp == null)
|
||||
_initUnpackFIleSystemOp = _fileSystem.UnpackFileSystem.InitializeFileSystemAsync();
|
||||
_initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem();
|
||||
|
||||
Progress = _initUnpackFIleSystemOp.Progress;
|
||||
if (_initUnpackFIleSystemOp.IsDone == false)
|
||||
@@ -113,7 +113,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.InitUnpackFileSystem)
|
||||
{
|
||||
if (_initUnpackFIleSystemOp == null)
|
||||
_initUnpackFIleSystemOp = _fileSystem.UnpackFileSystem.InitializeFileSystemAsync();
|
||||
_initUnpackFIleSystemOp = _fileSystem.InitializeUpackFileSystem();
|
||||
|
||||
Progress = _initUnpackFIleSystemOp.Progress;
|
||||
if (_initUnpackFIleSystemOp.IsDone == false)
|
||||
@@ -156,7 +156,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.RecordFiles)
|
||||
{
|
||||
PackageManifest manifest = _loadPackageManifestOp.Result;
|
||||
PackageManifest manifest = _loadPackageManifestOp.Manifest;
|
||||
string pacakgeDirectory = _fileSystem.FileRoot;
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(pacakgeDirectory);
|
||||
FileInfo[] fileInfos = rootDirectory.GetFiles();
|
||||
@@ -174,7 +174,7 @@ namespace YooAsset
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Failed mapping file : {fileName}");
|
||||
YooLogger.Warning($"Failed to mapping buildin bundle file : {fileName}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-152
@@ -3,13 +3,14 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 加载AssetBundle文件
|
||||
/// </summary>
|
||||
internal class DBFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
UnpackAssetBundleFile,
|
||||
LoadUnpackAssetBundle,
|
||||
LoadBuidlinAssetBundle,
|
||||
CheckLoadBuildinResult,
|
||||
Done,
|
||||
@@ -17,8 +18,6 @@ namespace YooAsset
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private FSLoadBundleOperation _loadUnpackBundleOp;
|
||||
private FSDownloadFileOperation _unpackBundleOp;
|
||||
private AssetBundleCreateRequest _createRequest;
|
||||
private bool _isWaitForAsyncComplete = false;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -33,67 +32,13 @@ namespace YooAsset
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
|
||||
if (_fileSystem.NeedUnpack(_bundle))
|
||||
{
|
||||
_steps = ESteps.UnpackAssetBundleFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadBuidlinAssetBundle;
|
||||
}
|
||||
_steps = ESteps.LoadBuidlinAssetBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.UnpackAssetBundleFile)
|
||||
{
|
||||
if (_unpackBundleOp == null)
|
||||
{
|
||||
int failedTryAgain = 0;
|
||||
int timeout = int.MaxValue;
|
||||
_unpackBundleOp = _fileSystem.DownloadFileAsync(_bundle, null, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
if (_unpackBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unpackBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadUnpackAssetBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unpackBundleOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadUnpackAssetBundle)
|
||||
{
|
||||
if (_loadUnpackBundleOp == null)
|
||||
_loadUnpackBundleOp = _fileSystem.UnpackFileSystem.LoadBundleFile(_bundle);
|
||||
|
||||
if (_loadUnpackBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadUnpackBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = _loadUnpackBundleOp.Result;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadUnpackBundleOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuidlinAssetBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
@@ -146,18 +91,6 @@ namespace YooAsset
|
||||
|
||||
while (true)
|
||||
{
|
||||
if (_unpackBundleOp != null)
|
||||
{
|
||||
if (_unpackBundleOp.IsDone == false)
|
||||
_unpackBundleOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (_loadUnpackBundleOp != null)
|
||||
{
|
||||
if (_loadUnpackBundleOp.IsDone == false)
|
||||
_loadUnpackBundleOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
@@ -168,21 +101,17 @@ namespace YooAsset
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
if (_steps == ESteps.UnpackAssetBundleFile)
|
||||
{
|
||||
if (_unpackBundleOp != null)
|
||||
_unpackBundleOp.SetAbort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载原生文件
|
||||
/// </summary>
|
||||
internal class DBFSLoadRawBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
UnpackRawBundleFile,
|
||||
LoadUnpackRawBundle,
|
||||
LoadBuildinRawBundle,
|
||||
CheckLoadBuildinResult,
|
||||
Done,
|
||||
@@ -190,8 +119,6 @@ namespace YooAsset
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private FSLoadBundleOperation _loadUnpackBundleOp;
|
||||
private FSDownloadFileOperation _unpackBundleOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
@@ -204,67 +131,13 @@ namespace YooAsset
|
||||
{
|
||||
DownloadProgress = 1f;
|
||||
DownloadedBytes = _bundle.FileSize;
|
||||
|
||||
if (_fileSystem.NeedUnpack(_bundle))
|
||||
{
|
||||
_steps = ESteps.UnpackRawBundleFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.LoadBuildinRawBundle;
|
||||
}
|
||||
_steps = ESteps.LoadBuildinRawBundle;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.UnpackRawBundleFile)
|
||||
{
|
||||
if (_unpackBundleOp == null)
|
||||
{
|
||||
int failedTryAgain = 0;
|
||||
int timeout = int.MaxValue;
|
||||
_unpackBundleOp = _fileSystem.DownloadFileAsync(_bundle, null, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
if (_unpackBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_unpackBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadUnpackRawBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _unpackBundleOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadUnpackRawBundle)
|
||||
{
|
||||
if (_loadUnpackBundleOp == null)
|
||||
_loadUnpackBundleOp = _fileSystem.UnpackFileSystem.LoadBundleFile(_bundle);
|
||||
|
||||
if (_loadUnpackBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadUnpackBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = _loadUnpackBundleOp.Result;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadUnpackBundleOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadBuildinRawBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
@@ -302,18 +175,6 @@ namespace YooAsset
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (_unpackBundleOp != null)
|
||||
{
|
||||
if (_unpackBundleOp.IsDone == false)
|
||||
_unpackBundleOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
if (_loadUnpackBundleOp != null)
|
||||
{
|
||||
if (_loadUnpackBundleOp.IsDone == false)
|
||||
_loadUnpackBundleOp.WaitForAsyncComplete();
|
||||
}
|
||||
|
||||
// 驱动流程
|
||||
InternalOnUpdate();
|
||||
|
||||
@@ -324,11 +185,6 @@ namespace YooAsset
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
if (_steps == ESteps.UnpackRawBundleFile)
|
||||
{
|
||||
if (_unpackBundleOp != null)
|
||||
_unpackBundleOp.SetAbort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -95,7 +95,7 @@ namespace YooAsset
|
||||
if (_loadBuildinPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = _loadBuildinPackageManifestOp.Manifest;
|
||||
Manifest = _loadBuildinPackageManifestOp.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ namespace YooAsset
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
GetPackageVersion,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
@@ -21,14 +21,14 @@ namespace YooAsset
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.GetPackageVersion;
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.GetPackageVersion)
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_requestBuildinPackageVersionOp == null)
|
||||
{
|
||||
|
||||
+2
-2
@@ -44,7 +44,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||
Error = $"Catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace YooAsset
|
||||
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' catalog files count : {catalog.Wrappers.Count}");
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' buildin catalog files count : {catalog.Wrappers.Count}");
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
+2
-2
@@ -20,7 +20,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 加载的清单实例
|
||||
/// 包裹清单
|
||||
/// </summary>
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify buildin package manifest file!";
|
||||
Error = "Failed to verify buildin package manifest file !";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user