mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
update file system
This commit is contained in:
@@ -17,7 +17,7 @@ namespace YooAsset
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private CopyBuildinPackageManifestOperation _copyBuildinPackageManifestOp;
|
||||
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
|
||||
private LoadBuildinCatalogFileOperation _loadCatalogFileOp;
|
||||
private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DBFSInitializeOperation(DefaultBuildinFileSystem fileSystem)
|
||||
@@ -103,34 +103,18 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.LoadCatalogFile)
|
||||
{
|
||||
if (_loadCatalogFileOp == null)
|
||||
if (_loadBuildinCatalogFileOp == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/*
|
||||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.FileRoot;
|
||||
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.ManifestServices, _fileSystem.PackageName, packageRoot);
|
||||
if (result == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Create package catalog file failed ! See the detail error in console !";
|
||||
return;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
_loadCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadCatalogFileOp);
|
||||
_loadBuildinCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
|
||||
_loadBuildinCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadBuildinCatalogFileOp);
|
||||
}
|
||||
|
||||
_loadCatalogFileOp.UpdateOperation();
|
||||
if (_loadCatalogFileOp.IsDone == false)
|
||||
_loadBuildinCatalogFileOp.UpdateOperation();
|
||||
if (_loadBuildinCatalogFileOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -139,7 +123,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadCatalogFileOp.Error;
|
||||
Error = _loadBuildinCatalogFileOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,27 +104,28 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
|
||||
if (_assetBundle != null)
|
||||
if (_assetBundle == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
|
||||
YooLogger.Error(Error);
|
||||
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -176,13 +177,15 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.LoadBuildinRawBundle)
|
||||
{
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
//TODO : 安卓平台内置文件属于APK压缩包内的文件。
|
||||
_steps = ESteps.Done;
|
||||
Result = new RawBundleResult(_fileSystem, _bundle);
|
||||
Status = EOperationStatus.Succeed;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Can not load android buildin raw bundle file : {filePath}";
|
||||
YooLogger.Error(Error);
|
||||
#else
|
||||
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
||||
@@ -20,8 +20,8 @@ namespace YooAsset
|
||||
|
||||
private readonly DefaultBuildinFileSystem _fileSystem;
|
||||
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
|
||||
private UnityWebFileRequestOperation _hashFileRequestOp;
|
||||
private UnityWebFileRequestOperation _manifestFileRequestOp;
|
||||
private UnityWebFileRequestOperation _hashWebFileRequestOp;
|
||||
private UnityWebFileRequestOperation _manifestWebFileRequestOp;
|
||||
private string _buildinPackageVersion;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
@@ -78,21 +78,21 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.UnpackHashFile)
|
||||
{
|
||||
if (_hashFileRequestOp == null)
|
||||
if (_hashWebFileRequestOp == null)
|
||||
{
|
||||
string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion);
|
||||
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
||||
_hashFileRequestOp.StartOperation();
|
||||
AddChildOperation(_hashFileRequestOp);
|
||||
_hashWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
||||
_hashWebFileRequestOp.StartOperation();
|
||||
AddChildOperation(_hashWebFileRequestOp);
|
||||
}
|
||||
|
||||
_hashFileRequestOp.UpdateOperation();
|
||||
if (_hashFileRequestOp.IsDone == false)
|
||||
_hashWebFileRequestOp.UpdateOperation();
|
||||
if (_hashWebFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_hashFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
if (_hashWebFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CheckManifestFile;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _hashFileRequestOp.Error;
|
||||
Error = _hashWebFileRequestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,21 +119,21 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.UnpackManifestFile)
|
||||
{
|
||||
if (_manifestFileRequestOp == null)
|
||||
if (_manifestWebFileRequestOp == null)
|
||||
{
|
||||
string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
|
||||
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
||||
_manifestFileRequestOp.StartOperation();
|
||||
AddChildOperation(_manifestFileRequestOp);
|
||||
_manifestWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
|
||||
_manifestWebFileRequestOp.StartOperation();
|
||||
AddChildOperation(_manifestWebFileRequestOp);
|
||||
}
|
||||
|
||||
_manifestFileRequestOp.UpdateOperation();
|
||||
if (_manifestFileRequestOp.IsDone == false)
|
||||
_manifestWebFileRequestOp.UpdateOperation();
|
||||
if (_manifestWebFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_manifestFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
if (_manifestWebFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -142,7 +142,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _manifestFileRequestOp.Error;
|
||||
Error = _manifestWebFileRequestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(LoadWebAssetBundleOperation)} loaded asset bundle is null !";
|
||||
Error = $"{nameof(DWRFSLoadAssetBundleOperation)} loaded asset bundle is null !";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,22 +32,6 @@ namespace YooAsset
|
||||
{
|
||||
if (_loadCatalogFileOp == null)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/*
|
||||
// 兼容性初始化
|
||||
// 说明:内置文件系统在编辑器下运行时需要动态生成
|
||||
string packageRoot = _fileSystem.FileRoot;
|
||||
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.ManifestServices, _fileSystem.PackageName, packageRoot);
|
||||
if (result == false)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Create package catalog file failed ! See the detail error in console !";
|
||||
return;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem, 60);
|
||||
_loadCatalogFileOp.StartOperation();
|
||||
AddChildOperation(_loadCatalogFileOp);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{nameof(LoadWebAssetBundleOperation)} loaded asset bundle is null !";
|
||||
Error = $"{nameof(DWSFSLoadAssetBundleOperation)} loaded asset bundle is null !";
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
|
||||
@@ -13,10 +13,10 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private UnityWebDataRequestOperation _unityWebDataRequestOp;
|
||||
private readonly PackageBundle _bundle;
|
||||
private readonly DownloadFileOptions _options;
|
||||
private readonly IWebDecryptionServices _decryptionServices;
|
||||
private UnityWebDataRequestOperation _unityWebDataRequestOp;
|
||||
|
||||
protected int _requestCount = 0;
|
||||
protected float _tryAgainTimer;
|
||||
@@ -53,6 +53,7 @@ namespace YooAsset
|
||||
string url = GetRequestURL();
|
||||
_unityWebDataRequestOp = new UnityWebDataRequestOperation(url, 0);
|
||||
_unityWebDataRequestOp.StartOperation();
|
||||
AddChildOperation(_unityWebDataRequestOp);
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
@@ -115,12 +116,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
if (_unityWebDataRequestOp != null)
|
||||
_unityWebDataRequestOp.AbortOperation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace YooAsset
|
||||
string url = GetRequestURL();
|
||||
_unityAssetBundleRequestOp = new UnityAssetBundleRequestOperation(_bundle, _disableUnityWebCache, url);
|
||||
_unityAssetBundleRequestOp.StartOperation();
|
||||
AddChildOperation(_unityAssetBundleRequestOp);
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
@@ -96,12 +97,6 @@ namespace YooAsset
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
if (_unityAssetBundleRequestOp != null)
|
||||
_unityAssetBundleRequestOp.AbortOperation();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取网络请求地址
|
||||
|
||||
Reference in New Issue
Block a user