mirror of https://github.com/tuyoogame/YooAsset
Compare commits
1 Commits
a9f8449d86
...
0dd97e9004
Author | SHA1 | Date |
---|---|---|
absences | 0dd97e9004 |
|
@ -46,10 +46,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string PackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建的包裹备注
|
||||
/// </summary>
|
||||
public string PackageNote;
|
||||
|
||||
/// <summary>
|
||||
/// 是否启用共享资源打包
|
||||
|
@ -163,12 +159,6 @@ namespace YooAsset.Editor
|
|||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
|
||||
// 设置默认备注信息
|
||||
if (string.IsNullOrEmpty(PackageNote))
|
||||
{
|
||||
PackageNote = DateTime.Now.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -35,7 +35,6 @@ namespace YooAsset.Editor
|
|||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
manifest.PackageName = buildParameters.PackageName;
|
||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||
manifest.PackageNote = buildParameters.PackageNote;
|
||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
||||
|
||||
|
|
|
@ -31,7 +31,6 @@ namespace YooAsset.Editor
|
|||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||
|
||||
// 收集器配置
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
|
|
|
@ -53,11 +53,6 @@ namespace YooAsset.Editor
|
|||
/// </summary>
|
||||
public string BuildPackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 构建包裹备注
|
||||
/// </summary>
|
||||
public string BuildPackageNote;
|
||||
|
||||
// 收集器配置
|
||||
public bool UniqueBundleName;
|
||||
public bool EnableAddressable;
|
||||
|
|
|
@ -65,7 +65,6 @@ namespace YooAsset.Editor
|
|||
_items.Add(new ItemWrapper("Build Mode", $"{buildReport.Summary.BuildMode}"));
|
||||
_items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
|
||||
_items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
|
||||
_items.Add(new ItemWrapper("Package Note", buildReport.Summary.BuildPackageNote));
|
||||
|
||||
_items.Add(new ItemWrapper(string.Empty, string.Empty));
|
||||
_items.Add(new ItemWrapper("Collect Settings", string.Empty));
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: da6402a4b93d31943b26fb99cebc0dfd
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,38 +0,0 @@
|
|||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CacheFileElement
|
||||
{
|
||||
public string PackageName { private set; get; }
|
||||
public string BundleGUID { private set; get; }
|
||||
public string FileRootPath { private set; get; }
|
||||
public string DataFilePath { private set; get; }
|
||||
public string InfoFilePath { private set; get; }
|
||||
|
||||
public EFileVerifyResult Result;
|
||||
public string DataFileCRC;
|
||||
public long DataFileSize;
|
||||
|
||||
public CacheFileElement(string packageName, string bundleGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
||||
{
|
||||
PackageName = packageName;
|
||||
BundleGUID = bundleGUID;
|
||||
FileRootPath = fileRootPath;
|
||||
DataFilePath = dataFilePath;
|
||||
InfoFilePath = infoFilePath;
|
||||
}
|
||||
|
||||
public void DeleteFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(FileRootPath, true);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
YooLogger.Warning($"Failed to delete cache bundle folder : {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c361449cdcbd8746ba3fb948798ae1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,25 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CacheHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取默认的缓存根目录
|
||||
/// </summary>
|
||||
public static string GetDefaultCacheRoot()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
|
||||
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
||||
projectPath = PathUtility.RegularPath(projectPath);
|
||||
return PathUtility.Combine(projectPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#elif UNITY_STANDALONE
|
||||
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#else
|
||||
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CacheWrapper
|
||||
{
|
||||
public string InfoFilePath { private set; get; }
|
||||
public string DataFilePath { private set; get; }
|
||||
public string DataFileCRC { private set; get; }
|
||||
public long DataFileSize { private set; get; }
|
||||
|
||||
public CacheWrapper(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
||||
{
|
||||
InfoFilePath = infoFilePath;
|
||||
DataFilePath = dataFilePath;
|
||||
DataFileCRC = dataFileCRC;
|
||||
DataFileSize = dataFileSize;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae2176c4ea6fbb3478bf8757def34cd7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ce78de82d3ce1a841a1e6bad099e0bab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,67 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface ICacheSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取缓存文件的根目录
|
||||
/// </summary>
|
||||
string GetCacheFileRoot();
|
||||
|
||||
/// <summary>
|
||||
/// 获取临时缓存文件路径
|
||||
/// </summary>
|
||||
string GetTempFilePath(PackageBundle bundle);
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据文件路径
|
||||
/// </summary>
|
||||
string GetDataFilePath(PackageBundle bundle);
|
||||
|
||||
/// <summary>
|
||||
/// 获取信息文件路径
|
||||
/// </summary>
|
||||
string GetInfoFilePath(PackageBundle bundle);
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有缓存文件的GUID
|
||||
/// </summary>
|
||||
List<string> GetAllCachedBundleGUIDs();
|
||||
|
||||
/// <summary>
|
||||
/// 是否记录了文件
|
||||
/// </summary>
|
||||
bool IsRecordFile(string bundleGUID);
|
||||
|
||||
/// <summary>
|
||||
/// 记录指定文件
|
||||
/// </summary>
|
||||
bool RecordFile(string bundleGUID, CacheWrapper wrapper);
|
||||
|
||||
/// <summary>
|
||||
/// 验证缓存文件
|
||||
/// </summary>
|
||||
EFileVerifyResult VerifyCacheFile(PackageBundle bundle);
|
||||
|
||||
/// <summary>
|
||||
/// 写入缓存文件
|
||||
/// </summary>
|
||||
bool WriteCacheFile(PackageBundle bundle, string copyPath);
|
||||
|
||||
/// <summary>
|
||||
/// 删除缓存文件
|
||||
/// </summary>
|
||||
bool DeleteCacheFile(string bundleGUID);
|
||||
|
||||
/// <summary>
|
||||
/// 写入文件信息
|
||||
/// </summary>
|
||||
void WriteInfoFile(string filePath, string dataFileCRC, long dataFileSize);
|
||||
|
||||
/// <summary>
|
||||
/// 读取文件信息
|
||||
/// </summary>
|
||||
void ReadInfoFile(string filePath, out string dataFileCRC, out long dataFileSize);
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8cae5a51fced527429445b140b8a0843
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,199 +0,0 @@
|
|||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DownloadNormalFileOperation : DefaultDownloadFileOperation
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private VerifyTempFileOperation _verifyOperation;
|
||||
private string _tempFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DownloadNormalFileOperation(IFileSystem fileSystem, ICacheSystem cacheSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_cacheSystem = cacheSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_tempFilePath = _cacheSystem.GetTempFilePath(Bundle);
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
// 检测文件是否存在
|
||||
if (_steps == ESteps.CheckExists)
|
||||
{
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
FileUtility.CreateFileDirectory(_tempFilePath);
|
||||
|
||||
// 删除临时文件
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
|
||||
// 获取请求地址
|
||||
_requestURL = GetRequestURL();
|
||||
|
||||
// 重置请求
|
||||
ResetRequestFiled();
|
||||
|
||||
// 创建下载器
|
||||
CreateWebRequest();
|
||||
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
DownloadProgress = _webRequest.downloadProgress;
|
||||
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
if (_webRequest.isDone == false)
|
||||
{
|
||||
CheckRequestTimeout();
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查网络错误
|
||||
if (CheckRequestResult())
|
||||
_steps = ESteps.VerifyTempFile;
|
||||
else
|
||||
_steps = ESteps.TryAgain;
|
||||
|
||||
// 注意:最终释放请求器
|
||||
DisposeWebRequest();
|
||||
}
|
||||
|
||||
// 验证下载文件
|
||||
if (_steps == ESteps.VerifyTempFile)
|
||||
{
|
||||
var element = new TempFileElement(_tempFilePath, Bundle.FileCRC, Bundle.FileSize);
|
||||
_verifyOperation = new VerifyTempFileOperation(element);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
||||
_steps = ESteps.CheckVerifyTempFile;
|
||||
}
|
||||
|
||||
// 等待验证完成
|
||||
if (_steps == ESteps.CheckVerifyTempFile)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_cacheSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{_fileSystem.GetType().FullName} failed to write file !";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.TryAgain;
|
||||
Error = _verifyOperation.Error;
|
||||
}
|
||||
|
||||
// 注意:验证完成后直接删除文件
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
}
|
||||
|
||||
// 重新尝试下载
|
||||
if (_steps == ESteps.TryAgain)
|
||||
{
|
||||
if (FailedTryAgain <= 0)
|
||||
{
|
||||
Status = EOperationStatus.Failed;
|
||||
_steps = ESteps.Done;
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_tryAgainTimer += Time.unscaledDeltaTime;
|
||||
if (_tryAgainTimer > 1f)
|
||||
{
|
||||
FailedTryAgain--;
|
||||
_steps = ESteps.CreateRequest;
|
||||
YooLogger.Warning(Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
bool isReuqestLocalFile = IsRequestLocalFile();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 注意:如果是导入或解压本地文件,执行等待完毕
|
||||
if (isReuqestLocalFile)
|
||||
{
|
||||
InternalOnUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateWebRequest()
|
||||
{
|
||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
|
||||
handler.removeFileOnAbort = true;
|
||||
_webRequest.downloadHandler = handler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
_webRequest.SendWebRequest();
|
||||
}
|
||||
private void DisposeWebRequest()
|
||||
{
|
||||
if (_webRequest != null)
|
||||
{
|
||||
//注意:引擎底层会自动调用Abort方法
|
||||
_webRequest.Dispose();
|
||||
_webRequest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 759967d543776a0469b625eff171d235
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9bfb785912326f942a31dc77762eb16a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class TempFileElement
|
||||
{
|
||||
public string TempFilePath { private set; get; }
|
||||
public string TempFileCRC { private set; get; }
|
||||
public long TempFileSize { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 注意:原子操作对象
|
||||
/// </summary>
|
||||
public int Result = 0;
|
||||
|
||||
public TempFileElement(string filePath, string fileCRC, long fileSize)
|
||||
{
|
||||
TempFilePath = filePath;
|
||||
TempFileCRC = fileCRC;
|
||||
TempFileSize = fileSize;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 220136fdc4a13d84e97b1249cfc65f3b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -10,6 +10,36 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
internal class DefaultBuildinFileSystem : IFileSystem
|
||||
{
|
||||
private class UnpackRemoteServices : IRemoteServices
|
||||
{
|
||||
private readonly string _buildinPackageRoot;
|
||||
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
|
||||
|
||||
public UnpackRemoteServices(string buildinPackRoot)
|
||||
{
|
||||
_buildinPackageRoot = buildinPackRoot;
|
||||
}
|
||||
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
|
||||
private string GetFileLoadURL(string fileName)
|
||||
{
|
||||
if (_mapping.TryGetValue(fileName, out string url) == false)
|
||||
{
|
||||
string filePath = PathUtility.Combine(_buildinPackageRoot, fileName);
|
||||
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_mapping.Add(fileName, url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public class FileWrapper
|
||||
{
|
||||
public string FileName { private set; get; }
|
||||
|
@ -190,7 +220,7 @@ namespace YooAsset
|
|||
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
||||
|
||||
// 创建解压文件系统
|
||||
var remoteServices = new DefaultUnpackRemoteServices(_packageRoot);
|
||||
var remoteServices = new UnpackRemoteServices(_packageRoot);
|
||||
_unpackFileSystem = new DefaultUnpackFileSystem();
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||
|
@ -201,7 +231,6 @@ namespace YooAsset
|
|||
}
|
||||
public virtual void OnUpdate()
|
||||
{
|
||||
_unpackFileSystem.OnUpdate();
|
||||
}
|
||||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
|
|
|
@ -10,18 +10,33 @@ namespace YooAsset
|
|||
/// 缓存文件系统
|
||||
/// 说明:正在进行的下载器会在ResourcePackage销毁的时候执行Abort操作!
|
||||
/// </summary>
|
||||
internal class DefaultCacheFileSystem : IFileSystem, ICacheSystem
|
||||
internal class DefaultCacheFileSystem : IFileSystem
|
||||
{
|
||||
protected readonly Dictionary<string, CacheWrapper> _wrappers = new Dictionary<string, CacheWrapper>(10000);
|
||||
public class FileWrapper
|
||||
{
|
||||
public string InfoFilePath { private set; get; }
|
||||
public string DataFilePath { private set; get; }
|
||||
public string DataFileCRC { private set; get; }
|
||||
public long DataFileSize { private set; get; }
|
||||
|
||||
public FileWrapper(string infoFilePath, string dataFilePath, string dataFileCRC, long dataFileSize)
|
||||
{
|
||||
InfoFilePath = infoFilePath;
|
||||
DataFilePath = dataFilePath;
|
||||
DataFileCRC = dataFileCRC;
|
||||
DataFileSize = dataFileSize;
|
||||
}
|
||||
}
|
||||
|
||||
protected readonly Dictionary<string, DefaultDownloadFileOperation> _downloaders = new Dictionary<string, DefaultDownloadFileOperation>(1000);
|
||||
protected readonly Dictionary<string, FileWrapper> _wrappers = new Dictionary<string, FileWrapper>(10000);
|
||||
protected readonly Dictionary<string, Stream> _loadedStream = new Dictionary<string, Stream>(10000);
|
||||
protected readonly Dictionary<string, string> _dataFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _infoFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, string> _tempFilePaths = new Dictionary<string, string>(10000);
|
||||
protected readonly Dictionary<string, DefaultDownloadFileOperation> _downloaders = new Dictionary<string, DefaultDownloadFileOperation>(1000);
|
||||
protected readonly List<string> _removeList = new List<string>(1000);
|
||||
|
||||
protected string _packageRoot;
|
||||
protected string _cacheFileRoot;
|
||||
protected string _saveFileRoot;
|
||||
protected string _tempFileRoot;
|
||||
protected string _manifestFileRoot;
|
||||
|
||||
|
@ -113,13 +128,13 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearAllCacheFilesOperation(this);
|
||||
var operation = new DCFSClearAllBundleFilesOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
||||
{
|
||||
var operation = new ClearUnusedCacheFilesOperation(this, manifest);
|
||||
var operation = new DCFSClearUnusedBundleFilesOperation(this, manifest);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -148,7 +163,7 @@ namespace YooAsset
|
|||
|
||||
if (bundle.FileSize >= ResumeDownloadMinimumSize)
|
||||
{
|
||||
var newDownloader = new DownloadResumeFileOperation(this, this, bundle, param, ResumeDownloadResponseCodes);
|
||||
var newDownloader = new DCFSDownloadResumeFileOperation(this, bundle, param);
|
||||
newDownloader.Reference();
|
||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||
OperationSystem.StartOperation(PackageName, newDownloader);
|
||||
|
@ -156,7 +171,7 @@ namespace YooAsset
|
|||
}
|
||||
else
|
||||
{
|
||||
var newDownloader = new DownloadNormalFileOperation(this, this, bundle, param);
|
||||
var newDownloader = new DCFSDownloadNormalFileOperation(this, bundle, param);
|
||||
newDownloader.Reference();
|
||||
_downloaders.Add(bundle.BundleGUID, newDownloader);
|
||||
OperationSystem.StartOperation(PackageName, newDownloader);
|
||||
|
@ -239,10 +254,10 @@ namespace YooAsset
|
|||
PackageName = packageName;
|
||||
|
||||
if (string.IsNullOrEmpty(rootDirectory))
|
||||
rootDirectory = CacheHelper.GetDefaultCacheRoot();
|
||||
rootDirectory = GetDefaultRoot();
|
||||
|
||||
_packageRoot = PathUtility.Combine(rootDirectory, packageName);
|
||||
_cacheFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName);
|
||||
_saveFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.SaveFilesFolderName);
|
||||
_tempFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.TempFilesFolderName);
|
||||
_manifestFileRoot = PathUtility.Combine(_packageRoot, DefaultCacheFileSystemDefine.ManifestFilesFolderName);
|
||||
}
|
||||
|
@ -357,10 +372,61 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
#region 缓存系统
|
||||
public string GetCacheFileRoot()
|
||||
#region 内部方法
|
||||
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
||||
public void WriteInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
||||
{
|
||||
return _cacheFileRoot;
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
_sharedBuffer.Clear();
|
||||
_sharedBuffer.WriteUTF8(dataFileCRC);
|
||||
_sharedBuffer.WriteInt64(dataFileSize);
|
||||
_sharedBuffer.WriteToStream(fs);
|
||||
fs.Flush();
|
||||
}
|
||||
}
|
||||
public void ReadInfoFile(string filePath, out string dataFileCRC, out long dataFileSize)
|
||||
{
|
||||
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
||||
BufferReader buffer = new BufferReader(binaryData);
|
||||
dataFileCRC = buffer.ReadUTF8();
|
||||
dataFileSize = buffer.ReadInt64();
|
||||
}
|
||||
|
||||
protected string GetDefaultRoot()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
// 注意:为了方便调试查看,编辑器下把存储目录放到项目里。
|
||||
string projectPath = Path.GetDirectoryName(UnityEngine.Application.dataPath);
|
||||
projectPath = PathUtility.RegularPath(projectPath);
|
||||
return PathUtility.Combine(projectPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#elif UNITY_STANDALONE
|
||||
return PathUtility.Combine(UnityEngine.Application.dataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#else
|
||||
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
#endif
|
||||
}
|
||||
protected string GetDataFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_dataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_saveFileRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.SaveBundleDataFileName);
|
||||
if (AppendFileExtension)
|
||||
filePath += bundle.FileExtension;
|
||||
_dataFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
protected string GetInfoFilePath(PackageBundle bundle)
|
||||
{
|
||||
if (_infoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_saveFileRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.SaveBundleInfoFileName);
|
||||
_infoFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetTempFilePath(PackageBundle bundle)
|
||||
{
|
||||
|
@ -371,38 +437,41 @@ namespace YooAsset
|
|||
}
|
||||
return filePath;
|
||||
}
|
||||
public string GetDataFilePath(PackageBundle bundle)
|
||||
public string GetCacheFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
if (_dataFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheFileRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.SaveBundleDataFileName);
|
||||
if (AppendFileExtension)
|
||||
filePath += bundle.FileExtension;
|
||||
_dataFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
return GetDataFilePath(bundle);
|
||||
}
|
||||
public string GetInfoFilePath(PackageBundle bundle)
|
||||
public string GetCacheFilesRoot()
|
||||
{
|
||||
if (_infoFilePaths.TryGetValue(bundle.BundleGUID, out string filePath) == false)
|
||||
{
|
||||
string folderName = bundle.FileHash.Substring(0, 2);
|
||||
filePath = PathUtility.Combine(_cacheFileRoot, folderName, bundle.BundleGUID, DefaultCacheFileSystemDefine.SaveBundleInfoFileName);
|
||||
_infoFilePaths.Add(bundle.BundleGUID, filePath);
|
||||
}
|
||||
return filePath;
|
||||
return _saveFileRoot;
|
||||
}
|
||||
public List<string> GetAllCachedBundleGUIDs()
|
||||
public string GetCachePackageHashFilePath(string packageVersion)
|
||||
{
|
||||
return _wrappers.Keys.ToList();
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_manifestFileRoot, fileName);
|
||||
}
|
||||
public string GetCachePackageManifestFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_manifestFileRoot, fileName);
|
||||
}
|
||||
public string GetSandboxAppFootPrintFilePath()
|
||||
{
|
||||
return PathUtility.Combine(_manifestFileRoot, DefaultCacheFileSystemDefine.AppFootPrintFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否已经记录了文件
|
||||
/// </summary>
|
||||
public bool IsRecordFile(string bundleGUID)
|
||||
{
|
||||
return _wrappers.ContainsKey(bundleGUID);
|
||||
}
|
||||
public bool RecordFile(string bundleGUID, CacheWrapper wrapper)
|
||||
|
||||
/// <summary>
|
||||
/// 记录文件信息
|
||||
/// </summary>
|
||||
public bool RecordFile(string bundleGUID, FileWrapper wrapper)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
|
@ -414,14 +483,21 @@ namespace YooAsset
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 验证缓存文件
|
||||
/// </summary>
|
||||
public EFileVerifyResult VerifyCacheFile(PackageBundle bundle)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundle.BundleGUID, out CacheWrapper wrapper) == false)
|
||||
if (_wrappers.TryGetValue(bundle.BundleGUID, out FileWrapper wrapper) == false)
|
||||
return EFileVerifyResult.CacheNotFound;
|
||||
|
||||
EFileVerifyResult result = FileVerifyHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||
EFileVerifyResult result = FileSystemHelper.FileVerify(wrapper.DataFilePath, wrapper.DataFileSize, wrapper.DataFileCRC, EFileVerifyLevel.High);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入缓存文件
|
||||
/// </summary>
|
||||
public bool WriteCacheFile(PackageBundle bundle, string copyPath)
|
||||
{
|
||||
if (_wrappers.ContainsKey(bundle.BundleGUID))
|
||||
|
@ -454,12 +530,16 @@ namespace YooAsset
|
|||
return false;
|
||||
}
|
||||
|
||||
var wrapper = new CacheWrapper(infoFilePath, dataFilePath, bundle.FileCRC, bundle.FileSize);
|
||||
FileWrapper wrapper = new FileWrapper(infoFilePath, dataFilePath, bundle.FileCRC, bundle.FileSize);
|
||||
return RecordFile(bundle.BundleGUID, wrapper);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除缓存文件
|
||||
/// </summary>
|
||||
public bool DeleteCacheFile(string bundleGUID)
|
||||
{
|
||||
if (_wrappers.TryGetValue(bundleGUID, out CacheWrapper wrapper))
|
||||
if (_wrappers.TryGetValue(bundleGUID, out FileWrapper wrapper))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -482,47 +562,6 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
private readonly BufferWriter _sharedBuffer = new BufferWriter(1024);
|
||||
public void WriteInfoFile(string filePath, string dataFileCRC, long dataFileSize)
|
||||
{
|
||||
using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
_sharedBuffer.Clear();
|
||||
_sharedBuffer.WriteUTF8(dataFileCRC);
|
||||
_sharedBuffer.WriteInt64(dataFileSize);
|
||||
_sharedBuffer.WriteToStream(fs);
|
||||
fs.Flush();
|
||||
}
|
||||
}
|
||||
public void ReadInfoFile(string filePath, out string dataFileCRC, out long dataFileSize)
|
||||
{
|
||||
byte[] binaryData = FileUtility.ReadAllBytes(filePath);
|
||||
BufferReader buffer = new BufferReader(binaryData);
|
||||
dataFileCRC = buffer.ReadUTF8();
|
||||
dataFileSize = buffer.ReadInt64();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 内部方法
|
||||
public string GetCacheFileLoadPath(PackageBundle bundle)
|
||||
{
|
||||
return GetDataFilePath(bundle);
|
||||
}
|
||||
public string GetCachePackageHashFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_manifestFileRoot, fileName);
|
||||
}
|
||||
public string GetCachePackageManifestFilePath(string packageVersion)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(PackageName, packageVersion);
|
||||
return PathUtility.Combine(_manifestFileRoot, fileName);
|
||||
}
|
||||
public string GetSandboxAppFootPrintFilePath()
|
||||
{
|
||||
return PathUtility.Combine(_manifestFileRoot, DefaultCacheFileSystemDefine.AppFootPrintFileName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除所有清单文件
|
||||
/// </summary>
|
||||
|
@ -534,6 +573,14 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有缓存文件GUID
|
||||
/// </summary>
|
||||
public List<string> GetAllCachedBundleGUIDs()
|
||||
{
|
||||
return _wrappers.Keys.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class ClearAllCacheFilesOperation : FSClearAllBundleFilesOperation
|
||||
internal sealed class DCFSClearAllBundleFilesOperation : FSClearAllBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -13,15 +13,15 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private List<string> _allBundleGUIDs;
|
||||
private int _fileTotalCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal ClearAllCacheFilesOperation(ICacheSystem cacheSystem)
|
||||
internal DCFSClearAllBundleFilesOperation(DefaultCacheFileSystem fileSystem)
|
||||
{
|
||||
_cacheSystem = cacheSystem;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.GetAllCacheFiles)
|
||||
{
|
||||
_allBundleGUIDs = _cacheSystem.GetAllCachedBundleGUIDs();
|
||||
_allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
||||
_fileTotalCount = _allBundleGUIDs.Count;
|
||||
_steps = ESteps.ClearAllCacheFiles;
|
||||
YooLogger.Log($"Found all cache files count : {_fileTotalCount}");
|
||||
|
@ -45,7 +45,7 @@ namespace YooAsset
|
|||
for (int i = _allBundleGUIDs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
string bundleGUID = _allBundleGUIDs[i];
|
||||
_cacheSystem.DeleteCacheFile(bundleGUID);
|
||||
_fileSystem.DeleteCacheFile(bundleGUID);
|
||||
_allBundleGUIDs.RemoveAt(i);
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class ClearUnusedCacheFilesOperation : FSClearUnusedBundleFilesOperation
|
||||
internal sealed class DCFSClearUnusedBundleFilesOperation : FSClearUnusedBundleFilesOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -13,16 +13,16 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private readonly PackageManifest _manifest;
|
||||
private List<string> _unusedBundleGUIDs;
|
||||
private int _unusedFileTotalCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal ClearUnusedCacheFilesOperation(ICacheSystem cacheSystem, PackageManifest manifest)
|
||||
internal DCFSClearUnusedBundleFilesOperation(DefaultCacheFileSystem fileSystem, PackageManifest manifest)
|
||||
{
|
||||
_cacheSystem = cacheSystem;
|
||||
_fileSystem = fileSystem;
|
||||
_manifest = manifest;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
|
@ -47,7 +47,7 @@ namespace YooAsset
|
|||
for (int i = _unusedBundleGUIDs.Count - 1; i >= 0; i--)
|
||||
{
|
||||
string bundleGUID = _unusedBundleGUIDs[i];
|
||||
_cacheSystem.DeleteCacheFile(bundleGUID);
|
||||
_fileSystem.DeleteCacheFile(bundleGUID);
|
||||
_unusedBundleGUIDs.RemoveAt(i);
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
|
@ -68,7 +68,7 @@ namespace YooAsset
|
|||
|
||||
private List<string> GetUnusedBundleGUIDs()
|
||||
{
|
||||
var allBundleGUIDs = _cacheSystem.GetAllCachedBundleGUIDs();
|
||||
var allBundleGUIDs = _fileSystem.GetAllCachedBundleGUIDs();
|
||||
List<string> result = new List<string>(allBundleGUIDs.Count);
|
||||
foreach (var bundleGUID in allBundleGUIDs)
|
||||
{
|
|
@ -1,15 +1,203 @@
|
|||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class DownloadResumeFileOperation : DefaultDownloadFileOperation
|
||||
internal sealed class DCFSDownloadNormalFileOperation : DefaultDownloadFileOperation
|
||||
{
|
||||
private readonly IFileSystem _fileSystem;
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private readonly List<long> _responseCodes;
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private VerifyTempFileOperation _verifyOperation;
|
||||
private string _tempFilePath;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal DCFSDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
// 检测文件是否存在
|
||||
if (_steps == ESteps.CheckExists)
|
||||
{
|
||||
if (_fileSystem.Exists(Bundle))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.CreateRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// 创建下载器
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
FileUtility.CreateFileDirectory(_tempFilePath);
|
||||
|
||||
// 删除临时文件
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
|
||||
// 获取请求地址
|
||||
_requestURL = GetRequestURL();
|
||||
|
||||
// 重置请求
|
||||
ResetRequestFiled();
|
||||
|
||||
// 创建下载器
|
||||
CreateWebRequest();
|
||||
|
||||
_steps = ESteps.CheckRequest;
|
||||
}
|
||||
|
||||
// 检测下载结果
|
||||
if (_steps == ESteps.CheckRequest)
|
||||
{
|
||||
DownloadProgress = _webRequest.downloadProgress;
|
||||
DownloadedBytes = (long)_webRequest.downloadedBytes;
|
||||
Progress = DownloadProgress;
|
||||
if (_webRequest.isDone == false)
|
||||
{
|
||||
CheckRequestTimeout();
|
||||
return;
|
||||
}
|
||||
|
||||
// 检查网络错误
|
||||
if (CheckRequestResult())
|
||||
_steps = ESteps.VerifyTempFile;
|
||||
else
|
||||
_steps = ESteps.TryAgain;
|
||||
|
||||
// 注意:最终释放请求器
|
||||
DisposeWebRequest();
|
||||
}
|
||||
|
||||
// 验证下载文件
|
||||
if (_steps == ESteps.VerifyTempFile)
|
||||
{
|
||||
var element = new TempFileElement(_tempFilePath, Bundle.FileCRC, Bundle.FileSize);
|
||||
_verifyOperation = new VerifyTempFileOperation(element);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyOperation);
|
||||
_steps = ESteps.CheckVerifyTempFile;
|
||||
}
|
||||
|
||||
// 等待验证完成
|
||||
if (_steps == ESteps.CheckVerifyTempFile)
|
||||
{
|
||||
if (IsWaitForAsyncComplete)
|
||||
_verifyOperation.WaitForAsyncComplete();
|
||||
|
||||
if (_verifyOperation.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_fileSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"{_fileSystem.GetType().FullName} failed to write file !";
|
||||
YooLogger.Error(Error);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.TryAgain;
|
||||
Error = _verifyOperation.Error;
|
||||
}
|
||||
|
||||
// 注意:验证完成后直接删除文件
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
||||
}
|
||||
|
||||
// 重新尝试下载
|
||||
if (_steps == ESteps.TryAgain)
|
||||
{
|
||||
if (FailedTryAgain <= 0)
|
||||
{
|
||||
Status = EOperationStatus.Failed;
|
||||
_steps = ESteps.Done;
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_tryAgainTimer += Time.unscaledDeltaTime;
|
||||
if (_tryAgainTimer > 1f)
|
||||
{
|
||||
FailedTryAgain--;
|
||||
_steps = ESteps.CreateRequest;
|
||||
YooLogger.Warning(Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalOnAbort()
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
DisposeWebRequest();
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
bool isReuqestLocalFile = IsRequestLocalFile();
|
||||
|
||||
while (true)
|
||||
{
|
||||
// 注意:如果是导入或解压本地文件,执行等待完毕
|
||||
if (isReuqestLocalFile)
|
||||
{
|
||||
InternalOnUpdate();
|
||||
if (IsDone)
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ExecuteWhileDone())
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateWebRequest()
|
||||
{
|
||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
|
||||
handler.removeFileOnAbort = true;
|
||||
_webRequest.downloadHandler = handler;
|
||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||
_webRequest.SendWebRequest();
|
||||
}
|
||||
private void DisposeWebRequest()
|
||||
{
|
||||
if (_webRequest != null)
|
||||
{
|
||||
//注意:引擎底层会自动调用Abort方法
|
||||
_webRequest.Dispose();
|
||||
_webRequest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class DCFSDownloadResumeFileOperation : DefaultDownloadFileOperation
|
||||
{
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private DownloadHandlerFileRange _downloadHandle;
|
||||
private VerifyTempFileOperation _verifyOperation;
|
||||
private long _fileOriginLength = 0;
|
||||
|
@ -17,15 +205,13 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DownloadResumeFileOperation(IFileSystem fileSystem, ICacheSystem cacheSystem, PackageBundle bundle, DownloadParam param, List<long> responseCodes) : base(bundle, param)
|
||||
internal DCFSDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_cacheSystem = cacheSystem;
|
||||
_responseCodes = responseCodes;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_tempFilePath = _cacheSystem.GetTempFilePath(Bundle);
|
||||
_tempFilePath = _fileSystem.GetTempFilePath(Bundle);
|
||||
_steps = ESteps.CheckExists;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
|
@ -127,7 +313,7 @@ namespace YooAsset
|
|||
|
||||
if (_verifyOperation.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
if (_cacheSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||
if (_fileSystem.WriteCacheFile(Bundle, _tempFilePath))
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
_steps = ESteps.Done;
|
||||
|
@ -232,11 +418,11 @@ namespace YooAsset
|
|||
}
|
||||
private void ClearTempFileWhenError()
|
||||
{
|
||||
if (_responseCodes == null)
|
||||
if (_fileSystem.ResumeDownloadResponseCodes == null)
|
||||
return;
|
||||
|
||||
//说明:如果遇到以下错误返回码,验证失败直接删除文件
|
||||
if (_responseCodes.Contains(HttpCode))
|
||||
if (_fileSystem.ResumeDownloadResponseCodes.Contains(HttpCode))
|
||||
{
|
||||
if (File.Exists(_tempFilePath))
|
||||
File.Delete(_tempFilePath);
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f878bc9a12f5d2d40aee754ddfaada86
|
||||
guid: d6f813e2460f55e4ba3f54527e6999e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -12,7 +12,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private readonly DefaultCacheFileSystem _fileSytem;
|
||||
private SearchCacheFilesOperation _searchCacheFilesOp;
|
||||
private VerifyCacheFilesOperation _verifyCacheFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
@ -20,7 +20,7 @@ namespace YooAsset
|
|||
|
||||
internal DCFSInitializeOperation(DefaultCacheFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_fileSytem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -39,14 +39,14 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.CheckAppFootPrint)
|
||||
{
|
||||
var appFootPrint = new ApplicationFootPrint(_fileSystem);
|
||||
appFootPrint.Load(_fileSystem.PackageName);
|
||||
var appFootPrint = new ApplicationFootPrint(_fileSytem);
|
||||
appFootPrint.Load(_fileSytem.PackageName);
|
||||
|
||||
// 如果水印发生变化,则说明覆盖安装后首次打开游戏
|
||||
if (appFootPrint.IsDirty())
|
||||
{
|
||||
_fileSystem.DeleteAllManifestFiles();
|
||||
appFootPrint.Coverage(_fileSystem.PackageName);
|
||||
_fileSytem.DeleteAllManifestFiles();
|
||||
appFootPrint.Coverage(_fileSytem.PackageName);
|
||||
YooLogger.Warning("Delete manifest files when application foot print dirty !");
|
||||
}
|
||||
|
||||
|
@ -57,8 +57,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_searchCacheFilesOp == null)
|
||||
{
|
||||
_searchCacheFilesOp = new SearchCacheFilesOperation(_fileSystem, _fileSystem.PackageName, _fileSystem.AppendFileExtension);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _searchCacheFilesOp);
|
||||
_searchCacheFilesOp = new SearchCacheFilesOperation(_fileSytem);
|
||||
OperationSystem.StartOperation(_fileSytem.PackageName, _searchCacheFilesOp);
|
||||
}
|
||||
|
||||
Progress = _searchCacheFilesOp.Progress;
|
||||
|
@ -72,8 +72,8 @@ namespace YooAsset
|
|||
{
|
||||
if (_verifyCacheFilesOp == null)
|
||||
{
|
||||
_verifyCacheFilesOp = new VerifyCacheFilesOperation(_fileSystem, _fileSystem.FileVerifyLevel, _searchCacheFilesOp.Result);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _verifyCacheFilesOp);
|
||||
_verifyCacheFilesOp = new VerifyCacheFilesOperation(_fileSytem, _searchCacheFilesOp.Result);
|
||||
OperationSystem.StartOperation(_fileSytem.PackageName, _verifyCacheFilesOp);
|
||||
}
|
||||
|
||||
Progress = _verifyCacheFilesOp.Progress;
|
||||
|
@ -84,7 +84,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
YooLogger.Log($"Package '{_fileSystem.PackageName}' cached files count : {_fileSystem.FileCount}");
|
||||
YooLogger.Log($"Package '{_fileSytem.PackageName}' cached files count : {_fileSytem.FileCount}");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -15,9 +15,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private readonly string _packageName;
|
||||
private readonly bool _appendFileExtension;
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private IEnumerator<DirectoryInfo> _filesEnumerator = null;
|
||||
private float _verifyStartTime;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
@ -28,11 +26,9 @@ namespace YooAsset
|
|||
public readonly List<CacheFileElement> Result = new List<CacheFileElement>(5000);
|
||||
|
||||
|
||||
internal SearchCacheFilesOperation(ICacheSystem cacheSystem, string packageName, bool appendFileExtension)
|
||||
internal SearchCacheFilesOperation(DefaultCacheFileSystem fileSystem)
|
||||
{
|
||||
_cacheSystem = cacheSystem;
|
||||
_packageName = packageName;
|
||||
_appendFileExtension = appendFileExtension;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -46,7 +42,7 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(_cacheSystem.GetCacheFileRoot());
|
||||
DirectoryInfo rootDirectory = new DirectoryInfo(_fileSystem.GetCacheFilesRoot());
|
||||
if (rootDirectory.Exists)
|
||||
{
|
||||
var directorieInfos = rootDirectory.EnumerateDirectories();
|
||||
|
@ -84,7 +80,7 @@ namespace YooAsset
|
|||
foreach (var chidDirectory in childDirectories)
|
||||
{
|
||||
string bundleGUID = chidDirectory.Name;
|
||||
if (_cacheSystem.IsRecordFile(bundleGUID))
|
||||
if (_fileSystem.IsRecordFile(bundleGUID))
|
||||
continue;
|
||||
|
||||
// 创建验证元素类
|
||||
|
@ -93,14 +89,14 @@ namespace YooAsset
|
|||
string infoFilePath = $"{fileRootPath}/{ DefaultCacheFileSystemDefine.SaveBundleInfoFileName}";
|
||||
|
||||
// 存储的数据文件追加文件格式
|
||||
if (_appendFileExtension)
|
||||
if (_fileSystem.AppendFileExtension)
|
||||
{
|
||||
string dataFileExtension = FindDataFileExtension(chidDirectory);
|
||||
if (string.IsNullOrEmpty(dataFileExtension) == false)
|
||||
dataFilePath += dataFileExtension;
|
||||
}
|
||||
|
||||
var element = new CacheFileElement(_packageName, bundleGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
var element = new CacheFileElement(_fileSystem.PackageName, bundleGUID, fileRootPath, dataFilePath, infoFilePath);
|
||||
Result.Add(element);
|
||||
}
|
||||
|
|
@ -6,10 +6,44 @@ using System.Threading;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CacheFileElement
|
||||
{
|
||||
public string PackageName { private set; get; }
|
||||
public string BundleGUID { private set; get; }
|
||||
public string FileRootPath { private set; get; }
|
||||
public string DataFilePath { private set; get; }
|
||||
public string InfoFilePath { private set; get; }
|
||||
|
||||
public EFileVerifyResult Result;
|
||||
public string DataFileCRC;
|
||||
public long DataFileSize;
|
||||
|
||||
public CacheFileElement(string packageName, string bundleGUID, string fileRootPath, string dataFilePath, string infoFilePath)
|
||||
{
|
||||
PackageName = packageName;
|
||||
BundleGUID = bundleGUID;
|
||||
FileRootPath = fileRootPath;
|
||||
DataFilePath = dataFilePath;
|
||||
InfoFilePath = infoFilePath;
|
||||
}
|
||||
|
||||
public void DeleteFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
Directory.Delete(FileRootPath, true);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
YooLogger.Warning($"Failed to delete cache bundle folder : {e}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 缓存文件验证(线程版)
|
||||
/// </summary>
|
||||
internal sealed class VerifyCacheFilesOperation : AsyncOperationBase
|
||||
internal class VerifyCacheFilesOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -20,10 +54,10 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
private readonly ThreadSyncContext _syncContext = new ThreadSyncContext();
|
||||
private readonly ICacheSystem _cacheSystem;
|
||||
private readonly EFileVerifyLevel _verifyLevel;
|
||||
private readonly DefaultCacheFileSystem _fileSystem;
|
||||
private List<CacheFileElement> _waitingList;
|
||||
private List<CacheFileElement> _verifyingList;
|
||||
private EFileVerifyLevel _verifyLevel = EFileVerifyLevel.Middle;
|
||||
private int _verifyMaxNum;
|
||||
private int _verifyTotalCount;
|
||||
private float _verifyStartTime;
|
||||
|
@ -32,11 +66,11 @@ namespace YooAsset
|
|||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal VerifyCacheFilesOperation(ICacheSystem cacheSystem, EFileVerifyLevel verifyLevel, List<CacheFileElement> elements)
|
||||
internal VerifyCacheFilesOperation(DefaultCacheFileSystem fileSystem, List<CacheFileElement> elements)
|
||||
{
|
||||
_cacheSystem = cacheSystem;
|
||||
_verifyLevel = verifyLevel;
|
||||
_fileSystem = fileSystem;
|
||||
_waitingList = elements;
|
||||
_verifyLevel = _fileSystem.FileVerifyLevel;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -124,8 +158,8 @@ namespace YooAsset
|
|||
if (element.Result == EFileVerifyResult.Succeed)
|
||||
{
|
||||
_succeedCount++;
|
||||
var fileWrapper = new CacheWrapper(element.InfoFilePath, element.DataFilePath, element.DataFileCRC, element.DataFileSize);
|
||||
_cacheSystem.RecordFile(element.BundleGUID, fileWrapper);
|
||||
var fileWrapper = new DefaultCacheFileSystem.FileWrapper(element.InfoFilePath, element.DataFilePath, element.DataFileCRC, element.DataFileSize);
|
||||
_fileSystem.RecordFile(element.BundleGUID, fileWrapper);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -157,7 +191,7 @@ namespace YooAsset
|
|||
return EFileVerifyResult.InfoFileNotExisted;
|
||||
|
||||
// 解析信息文件获取验证数据
|
||||
_cacheSystem.ReadInfoFile(element.InfoFilePath, out element.DataFileCRC, out element.DataFileSize);
|
||||
_fileSystem.ReadInfoFile(element.InfoFilePath, out element.DataFileCRC, out element.DataFileSize);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
|
@ -165,7 +199,7 @@ namespace YooAsset
|
|||
return EFileVerifyResult.Exception;
|
||||
}
|
||||
|
||||
return FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, verifyLevel);
|
||||
return FileSystemHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, verifyLevel);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,10 +3,29 @@ using System.Threading;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class TempFileElement
|
||||
{
|
||||
public string TempFilePath { private set; get; }
|
||||
public string TempFileCRC { private set; get; }
|
||||
public long TempFileSize { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 注意:原子操作对象
|
||||
/// </summary>
|
||||
public int Result = 0;
|
||||
|
||||
public TempFileElement(string filePath, string fileCRC, long fileSize)
|
||||
{
|
||||
TempFilePath = filePath;
|
||||
TempFileCRC = fileCRC;
|
||||
TempFileSize = fileSize;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载文件验证(线程版)
|
||||
/// </summary>
|
||||
internal sealed class VerifyTempFileOperation : AsyncOperationBase
|
||||
internal class VerifyTempFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -22,7 +41,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 验证结果
|
||||
/// </summary>
|
||||
public EFileVerifyResult VerifyResult { private set; get; }
|
||||
public EFileVerifyResult VerifyResult { protected set; get; }
|
||||
|
||||
|
||||
internal VerifyTempFileOperation(TempFileElement element)
|
||||
|
@ -84,7 +103,7 @@ namespace YooAsset
|
|||
private void VerifyInThread(object obj)
|
||||
{
|
||||
TempFileElement element = (TempFileElement)obj;
|
||||
int result = (int)FileVerifyHelper.FileVerify(element.TempFilePath, element.TempFileSize, element.TempFileCRC, EFileVerifyLevel.High);
|
||||
int result = (int)FileSystemHelper.FileVerify(element.TempFilePath, element.TempFileSize, element.TempFileCRC, EFileVerifyLevel.High);
|
||||
element.Result = result;
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ namespace YooAsset
|
|||
base.OnCreate(packageName, rootDirectory);
|
||||
|
||||
// 注意:重写保存根目录和临时目录
|
||||
_cacheFileRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
||||
_saveFileRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.SaveFilesFolderName);
|
||||
_tempFileRoot = PathUtility.Combine(_packageRoot, DefaultUnpackFileSystemDefine.TempFilesFolderName);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DefaultUnpackRemoteServices : IRemoteServices
|
||||
{
|
||||
private readonly string _buildinPackageRoot;
|
||||
protected readonly Dictionary<string, string> _mapping = new Dictionary<string, string>(10000);
|
||||
|
||||
public DefaultUnpackRemoteServices(string buildinPackRoot)
|
||||
{
|
||||
_buildinPackageRoot = buildinPackRoot;
|
||||
}
|
||||
string IRemoteServices.GetRemoteMainURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
string IRemoteServices.GetRemoteFallbackURL(string fileName)
|
||||
{
|
||||
return GetFileLoadURL(fileName);
|
||||
}
|
||||
|
||||
private string GetFileLoadURL(string fileName)
|
||||
{
|
||||
if (_mapping.TryGetValue(fileName, out string url) == false)
|
||||
{
|
||||
string filePath = PathUtility.Combine(_buildinPackageRoot, fileName);
|
||||
url = DownloadSystemHelper.ConvertToWWWPath(filePath);
|
||||
_mapping.Add(fileName, url);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 32c355598c9dff847af87f4a867a2d5c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -8,7 +8,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// Web文件系统
|
||||
/// </summary>
|
||||
internal class DefaultWebServerFileSystem : IFileSystem
|
||||
internal class DefaultWebFileSystem : IFileSystem
|
||||
{
|
||||
public class FileWrapper
|
||||
{
|
||||
|
@ -59,24 +59,24 @@ namespace YooAsset
|
|||
#endregion
|
||||
|
||||
|
||||
public DefaultWebServerFileSystem()
|
||||
public DefaultWebFileSystem()
|
||||
{
|
||||
}
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
{
|
||||
var operation = new DWSFSInitializeOperation(this);
|
||||
var operation = new DWFSInitializeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DWSFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||
var operation = new DWFSLoadPackageManifestOperation(this, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new DWSFSRequestPackageVersionOperation(this, timeout);
|
||||
var operation = new DWFSRequestPackageVersionOperation(this, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ namespace YooAsset
|
|||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
{
|
||||
var operation = new DWSFSLoadAssetBundleOperation(this, bundle);
|
||||
var operation = new DWFSLoadAssetBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
@ -214,7 +214,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_wrappers.ContainsKey(bundleGUID))
|
||||
{
|
||||
YooLogger.Error($"{nameof(DefaultWebServerFileSystem)} has element : {bundleGUID}");
|
||||
YooLogger.Error($"{nameof(DefaultWebFileSystem)} has element : {bundleGUID}");
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSInitializeOperation : FSInitializeFileSystemOperation
|
||||
internal class DWFSInitializeOperation : FSInitializeFileSystemOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -10,12 +10,12 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private LoadWebServerCatalogFileOperation _loadCatalogFileOp;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private LoadWebCatalogFileOperation _loadCatalogFileOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DWSFSInitializeOperation(DefaultWebServerFileSystem fileSystem)
|
||||
public DWFSInitializeOperation(DefaultWebFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace YooAsset
|
|||
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.PackageName, packageRoot);
|
||||
#endif
|
||||
|
||||
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
|
||||
_loadCatalogFileOp = new LoadWebCatalogFileOperation(_fileSystem);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadCatalogFileOp);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||
internal class DWFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -10,13 +10,13 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWSFSLoadAssetBundleOperation(DefaultWebServerFileSystem fileSystem, PackageBundle bundle)
|
||||
internal DWFSLoadAssetBundleOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
|
@ -38,7 +38,7 @@ namespace YooAsset
|
|||
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
||||
downloadParam.MainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
||||
downloadParam.FallbackURL = downloadParam.MainURL;
|
||||
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
||||
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem, _bundle, downloadParam);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadhanlderAssetBundleOp);
|
||||
}
|
||||
|
|
@ -1,44 +1,68 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWRFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||
internal class DWFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestWebPackageVersion,
|
||||
RequestWebPackageHash,
|
||||
LoadWebPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private RequestWebRemotePackageHashOperation _requestWebPackageHashOp;
|
||||
private LoadWebRemotePackageManifestOperation _loadWebPackageManifestOp;
|
||||
private RequestWebPackageVersionOperation _requestWebPackageVersionOp;
|
||||
private RequestWebPackageHashOperation _requestWebPackageHashOp;
|
||||
private LoadWebPackageManifestOperation _loadWebPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DWRFSLoadPackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, int timeout)
|
||||
public DWFSLoadPackageManifestOperation(DefaultWebFileSystem fileSystem, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.RequestWebPackageHash;
|
||||
_steps = ESteps.RequestWebPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestWebPackageVersion)
|
||||
{
|
||||
if (_requestWebPackageVersionOp == null)
|
||||
{
|
||||
_requestWebPackageVersionOp = new RequestWebPackageVersionOperation(_fileSystem, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||
}
|
||||
|
||||
if (_requestWebPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.RequestWebPackageHash;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestWebPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.RequestWebPackageHash)
|
||||
{
|
||||
if (_requestWebPackageHashOp == null)
|
||||
{
|
||||
_requestWebPackageHashOp = new RequestWebRemotePackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||
string packageVersion = _requestWebPackageVersionOp.PackageVersion;
|
||||
_requestWebPackageHashOp = new RequestWebPackageHashOperation(_fileSystem, packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageHashOp);
|
||||
}
|
||||
|
||||
|
@ -61,8 +85,9 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadWebPackageManifestOp == null)
|
||||
{
|
||||
string packageVersion = _requestWebPackageVersionOp.PackageVersion;
|
||||
string packageHash = _requestWebPackageHashOp.PackageHash;
|
||||
_loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
_loadWebPackageManifestOp = new LoadWebPackageManifestOperation(_fileSystem, packageVersion, packageHash);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadWebPackageManifestOp);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
internal class DWFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -10,13 +10,13 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private RequestWebServerPackageVersionOperation _requestWebPackageVersionOp;
|
||||
private RequestWebPackageVersionOperation _requestWebPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWSFSRequestPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||
internal DWFSRequestPackageVersionOperation(DefaultWebFileSystem fileSystem, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_timeout = timeout;
|
||||
|
@ -34,7 +34,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_requestWebPackageVersionOp == null)
|
||||
{
|
||||
_requestWebPackageVersionOp = new RequestWebServerPackageVersionOperation(_fileSystem, _timeout);
|
||||
_requestWebPackageVersionOp = new RequestWebPackageVersionOperation(_fileSystem, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||
}
|
||||
|
|
@ -5,16 +5,16 @@ namespace YooAsset
|
|||
{
|
||||
internal class DownloadHandlerAssetBundleOperation : DefaultDownloadFileOperation
|
||||
{
|
||||
private readonly bool _disableUnityWebCache;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private DownloadHandlerAssetBundle _downloadhandler;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
public AssetBundle Result { private set; get; }
|
||||
|
||||
|
||||
internal DownloadHandlerAssetBundleOperation(bool disableUnityWebCache, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||
internal DownloadHandlerAssetBundleOperation(DefaultWebFileSystem fileSystem, PackageBundle bundle, DownloadParam param) : base(bundle, param)
|
||||
{
|
||||
_disableUnityWebCache = disableUnityWebCache;
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
|
@ -113,7 +113,7 @@ namespace YooAsset
|
|||
}
|
||||
private DownloadHandlerAssetBundle CreateDownloadHandler()
|
||||
{
|
||||
if (_disableUnityWebCache)
|
||||
if (_fileSystem.DisableUnityWebCache)
|
||||
{
|
||||
var downloadhandler = new DownloadHandlerAssetBundle(_requestURL, 0);
|
||||
#if UNITY_2020_3_OR_NEWER
|
|
@ -6,7 +6,7 @@ using UnityEngine;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal sealed class LoadWebServerCatalogFileOperation : AsyncOperationBase
|
||||
internal sealed class LoadWebCatalogFileOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
|
@ -23,7 +23,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem)
|
||||
internal LoadWebCatalogFileOperation(DefaultWebFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Failed to load web server catalog file : {catalogFilePath}";
|
||||
Error = $"Failed to load web catalog file : {catalogFilePath}";
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -52,14 +52,14 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web server catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||
Error = $"Web catalog file package name {catalog.PackageName} cannot match the file system package name {_fileSystem.PackageName}";
|
||||
return;
|
||||
}
|
||||
|
||||
PackageVersion = catalog.PackageVersion;
|
||||
foreach (var wrapper in catalog.Wrappers)
|
||||
{
|
||||
var fileWrapper = new DefaultWebServerFileSystem.FileWrapper(wrapper.FileName);
|
||||
var fileWrapper = new DefaultWebFileSystem.FileWrapper(wrapper.FileName);
|
||||
_fileSystem.RecordFile(wrapper.BundleGUID, fileWrapper);
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadWebServerPackageManifestOperation : AsyncOperationBase
|
||||
internal class LoadWebPackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly string _packageHash;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
|
@ -25,7 +25,7 @@ namespace YooAsset
|
|||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
internal LoadWebPackageManifestOperation(DefaultWebFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
|
@ -76,7 +76,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify web server package manifest file!";
|
||||
Error = "Failed to verify web package manifest file!";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebServerPackageHashOperation : AsyncOperationBase
|
||||
internal class RequestWebPackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
|
@ -22,7 +22,7 @@ namespace YooAsset
|
|||
public string PackageHash { private set; get; }
|
||||
|
||||
|
||||
public RequestWebServerPackageHashOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, int timeout)
|
||||
public RequestWebPackageHashOperation(DefaultWebFileSystem fileSystem, string packageVersion, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
|
@ -58,7 +58,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web server package hash file content is empty !";
|
||||
Error = $"Web package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebServerPackageVersionOperation : AsyncOperationBase
|
||||
internal class RequestWebPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly DefaultWebFileSystem _fileSystem;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
@ -21,7 +21,7 @@ namespace YooAsset
|
|||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestWebServerPackageVersionOperation(DefaultWebServerFileSystem fileSystem, int timeout)
|
||||
internal RequestWebPackageVersionOperation(DefaultWebFileSystem fileSystem, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_timeout = timeout;
|
||||
|
@ -55,7 +55,7 @@ namespace YooAsset
|
|||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web server package version file content is empty !";
|
||||
Error = $"Web package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2bf1355f3cbe3d543b53bd9553bba02c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,162 +0,0 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// Web文件系统
|
||||
/// </summary>
|
||||
internal class DefaultWebRemoteFileSystem : IFileSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 包裹名称
|
||||
/// </summary>
|
||||
public string PackageName { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件根目录
|
||||
/// </summary>
|
||||
public string FileRoot
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件数量
|
||||
/// </summary>
|
||||
public int FileCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#region 自定义参数
|
||||
/// <summary>
|
||||
/// 禁用Unity的网络缓存
|
||||
/// </summary>
|
||||
public bool DisableUnityWebCache { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:跨域下载服务接口
|
||||
/// </summary>
|
||||
public IRemoteServices RemoteServices { private set; get; } = null;
|
||||
#endregion
|
||||
|
||||
|
||||
public DefaultWebRemoteFileSystem()
|
||||
{
|
||||
}
|
||||
public virtual FSInitializeFileSystemOperation InitializeFileSystemAsync()
|
||||
{
|
||||
var operation = new DWRFSInitializeOperation(this);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSLoadPackageManifestOperation LoadPackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
var operation = new DWRFSLoadPackageManifestOperation(this, packageVersion, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSRequestPackageVersionOperation RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
var operation = new DWRFSRequestPackageVersionOperation(this, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearAllBundleFilesOperation ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new FSClearAllBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearUnusedBundleFilesOperation ClearUnusedBundleFilesAsync(PackageManifest manifest)
|
||||
{
|
||||
var operation = new FSClearUnusedBundleFilesCompleteOperation();
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadParam param)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
{
|
||||
var operation = new DWRFSLoadAssetBundleOperation(this, bundle);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
public virtual void UnloadBundleFile(PackageBundle bundle, object result)
|
||||
{
|
||||
AssetBundle assetBundle = result as AssetBundle;
|
||||
if (assetBundle == null)
|
||||
return;
|
||||
|
||||
if (assetBundle != null)
|
||||
assetBundle.Unload(true);
|
||||
}
|
||||
|
||||
public virtual void SetParameter(string name, object value)
|
||||
{
|
||||
if (name == FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE)
|
||||
{
|
||||
DisableUnityWebCache = (bool)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.REMOTE_SERVICES)
|
||||
{
|
||||
RemoteServices = (IRemoteServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
YooLogger.Warning($"Invalid parameter : {name}");
|
||||
}
|
||||
}
|
||||
public virtual void OnCreate(string packageName, string rootDirectory)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
public virtual void OnUpdate()
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool Belong(PackageBundle bundle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public virtual bool Exists(PackageBundle bundle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public virtual bool NeedDownload(PackageBundle bundle)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool NeedUnpack(PackageBundle bundle)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
public virtual bool NeedImport(PackageBundle bundle)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual byte[] ReadFileData(PackageBundle bundle)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public virtual string ReadFileText(PackageBundle bundle)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
#region 内部方法
|
||||
#endregion
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f511714bfc7c1104aa6200ee0826e9e3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1086ea45b8b84fe43ba1ef69b4f813dc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,20 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWRFSInitializeOperation : FSInitializeFileSystemOperation
|
||||
{
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
|
||||
public DWRFSInitializeOperation(DefaultWebRemoteFileSystem fileSystem)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f30b92e4f3b9e594ca0481128b56cc21
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,83 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWRFSLoadAssetBundleOperation : FSLoadBundleOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
DownloadFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly PackageBundle _bundle;
|
||||
private DownloadHandlerAssetBundleOperation _downloadhanlderAssetBundleOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWRFSLoadAssetBundleOperation(DefaultWebRemoteFileSystem fileSystem, PackageBundle bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_bundle = bundle;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.DownloadFile;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadhanlderAssetBundleOp == null)
|
||||
{
|
||||
DownloadParam downloadParam = new DownloadParam(int.MaxValue, 60);
|
||||
downloadParam.MainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||
downloadParam.FallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||
_downloadhanlderAssetBundleOp = new DownloadHandlerAssetBundleOperation(_fileSystem.DisableUnityWebCache, _bundle, downloadParam);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _downloadhanlderAssetBundleOp);
|
||||
}
|
||||
|
||||
DownloadProgress = _downloadhanlderAssetBundleOp.DownloadProgress;
|
||||
DownloadedBytes = _downloadhanlderAssetBundleOp.DownloadedBytes;
|
||||
Progress = _downloadhanlderAssetBundleOp.Progress;
|
||||
if (_downloadhanlderAssetBundleOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_downloadhanlderAssetBundleOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Result = _downloadhanlderAssetBundleOp.Result;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _downloadhanlderAssetBundleOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
internal override void InternalWaitForAsyncComplete()
|
||||
{
|
||||
if (_steps != ESteps.Done)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "WebGL platform not support sync load method !";
|
||||
UnityEngine.Debug.LogError(Error);
|
||||
}
|
||||
}
|
||||
public override void AbortDownloadOperation()
|
||||
{
|
||||
if (_steps == ESteps.DownloadFile)
|
||||
{
|
||||
if (_downloadhanlderAssetBundleOp != null)
|
||||
_downloadhanlderAssetBundleOp.SetAbort();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 270b776fd379b0f45bc602c845720733
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2611f6fbc97de1a4d9a38116045d4faf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,62 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWRFSRequestPackageVersionOperation : FSRequestPackageVersionOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private RequestWebRemotePackageVersionOperation _requestWebPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DWRFSRequestPackageVersionOperation(DefaultWebRemoteFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_requestWebPackageVersionOp == null)
|
||||
{
|
||||
_requestWebPackageVersionOp = new RequestWebRemotePackageVersionOperation(_fileSystem, _appendTimeTicks, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageVersionOp);
|
||||
}
|
||||
|
||||
Progress = _requestWebPackageVersionOp.Progress;
|
||||
if (_requestWebPackageVersionOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestWebPackageVersionOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
PackageVersion = _requestWebPackageVersionOp.PackageVersion;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestWebPackageVersionOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d1c5335974b2432458ed902e20cc954e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9be3163f53935514d9e64e09686db957
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,122 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadWebRemotePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestFileData,
|
||||
VerifyFileData,
|
||||
LoadManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly string _packageHash;
|
||||
private UnityWebDataRequestOperation _webDataRequestOp;
|
||||
private DeserializeManifestOperation _deserializer;
|
||||
private int _requestCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹清单
|
||||
/// </summary>
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_packageHash = packageHash;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(LoadWebRemotePackageManifestOperation));
|
||||
_steps = ESteps.RequestFileData;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestFileData)
|
||||
{
|
||||
if (_webDataRequestOp == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
|
||||
string url = GetWebRequestURL(fileName);
|
||||
_webDataRequestOp = new UnityWebDataRequestOperation(url);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webDataRequestOp);
|
||||
}
|
||||
|
||||
if (_webDataRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_webDataRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.VerifyFileData;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webDataRequestOp.Error;
|
||||
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(LoadWebRemotePackageManifestOperation));
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
string fileHash = HashUtility.BytesMD5(_webDataRequestOp.Result);
|
||||
if (fileHash == _packageHash)
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to verify web remote package manifest file!";
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadManifest)
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_webDataRequestOp.Result);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _deserializer);
|
||||
}
|
||||
|
||||
Progress = _deserializer.Progress;
|
||||
if (_deserializer.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_deserializer.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Manifest = _deserializer.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _deserializer.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetWebRequestURL(string fileName)
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
if (_requestCount % 2 == 0)
|
||||
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||
else
|
||||
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8ac57bde14f2e1a4e9323751a7157ed7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,90 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebRemotePackageHashOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageHash,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹哈希值
|
||||
/// </summary>
|
||||
public string PackageHash { private set; get; }
|
||||
|
||||
|
||||
public RequestWebRemotePackageHashOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestWebRemotePackageHashOperation));
|
||||
_steps = ESteps.RequestPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageHash)
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_fileSystem.PackageName, _packageVersion);
|
||||
string url = GetWebRequestURL(fileName);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||
}
|
||||
|
||||
Progress = _webTextRequestOp.Progress;
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageHash = _webTextRequestOp.Result;
|
||||
if (string.IsNullOrEmpty(PackageHash))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web remote package hash file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webTextRequestOp.Error;
|
||||
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(RequestWebRemotePackageHashOperation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetWebRequestURL(string fileName)
|
||||
{
|
||||
// 轮流返回请求地址
|
||||
if (_requestCount % 2 == 0)
|
||||
return _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||
else
|
||||
return _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f2a5bb0106a45e540a43a05b72a75bcd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,98 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class RequestWebRemotePackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestPackageVersion,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebRemoteFileSystem _fileSystem;
|
||||
private readonly bool _appendTimeTicks;
|
||||
private readonly int _timeout;
|
||||
private UnityWebTextRequestOperation _webTextRequestOp;
|
||||
private int _requestCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestWebRemotePackageVersionOperation(DefaultWebRemoteFileSystem fileSystem, bool appendTimeTicks, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_appendTimeTicks = appendTimeTicks;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_requestCount = WebRequestCounter.GetRequestFailedCount(_fileSystem.PackageName, nameof(RequestWebRemotePackageVersionOperation));
|
||||
_steps = ESteps.RequestPackageVersion;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestPackageVersion)
|
||||
{
|
||||
if (_webTextRequestOp == null)
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(_fileSystem.PackageName);
|
||||
string url = GetWebRequestURL(fileName);
|
||||
_webTextRequestOp = new UnityWebTextRequestOperation(url, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _webTextRequestOp);
|
||||
}
|
||||
|
||||
Progress = _webTextRequestOp.Progress;
|
||||
if (_webTextRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_webTextRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
PackageVersion = _webTextRequestOp.Result;
|
||||
if (string.IsNullOrEmpty(PackageVersion))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"Web remote package version file content is empty !";
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _webTextRequestOp.Error;
|
||||
WebRequestCounter.RecordRequestFailed(_fileSystem.PackageName, nameof(RequestWebRemotePackageVersionOperation));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private string GetWebRequestURL(string fileName)
|
||||
{
|
||||
string url;
|
||||
|
||||
// 轮流返回请求地址
|
||||
if (_requestCount % 2 == 0)
|
||||
url = _fileSystem.RemoteServices.GetRemoteMainURL(fileName);
|
||||
else
|
||||
url = _fileSystem.RemoteServices.GetRemoteFallbackURL(fileName);
|
||||
|
||||
// 在URL末尾添加时间戳
|
||||
if (_appendTimeTicks)
|
||||
return $"{url}?{System.DateTime.UtcNow.Ticks}";
|
||||
else
|
||||
return url;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a38597f546a46a429b24abd595c76e4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,88 +0,0 @@
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DWSFSLoadPackageManifestOperation : FSLoadPackageManifestOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
RequestWebPackageHash,
|
||||
LoadWebPackageManifest,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly DefaultWebServerFileSystem _fileSystem;
|
||||
private readonly string _packageVersion;
|
||||
private readonly int _timeout;
|
||||
private RequestWebServerPackageHashOperation _requestWebPackageHashOp;
|
||||
private LoadWebServerPackageManifestOperation _loadWebPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
public DWSFSLoadPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, int timeout)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_packageVersion = packageVersion;
|
||||
_timeout = timeout;
|
||||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.RequestWebPackageHash;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.RequestWebPackageHash)
|
||||
{
|
||||
if (_requestWebPackageHashOp == null)
|
||||
{
|
||||
_requestWebPackageHashOp = new RequestWebServerPackageHashOperation(_fileSystem, _packageVersion, _timeout);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _requestWebPackageHashOp);
|
||||
}
|
||||
|
||||
if (_requestWebPackageHashOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_requestWebPackageHashOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.LoadWebPackageManifest;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _requestWebPackageHashOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.LoadWebPackageManifest)
|
||||
{
|
||||
if (_loadWebPackageManifestOp == null)
|
||||
{
|
||||
string packageHash = _requestWebPackageHashOp.PackageHash;
|
||||
_loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash);
|
||||
OperationSystem.StartOperation(_fileSystem.PackageName, _loadWebPackageManifestOp);
|
||||
}
|
||||
|
||||
Progress = _loadWebPackageManifestOp.Progress;
|
||||
if (_loadWebPackageManifestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_loadWebPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Manifest = _loadWebPackageManifestOp.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _loadWebPackageManifestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@ using System.IO;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class FileVerifyHelper
|
||||
internal class FileSystemHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件校验
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: db3336ad3b5a8f349a3144e77f23fcf8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -165,30 +165,16 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebServer文件系统参数
|
||||
/// 创建默认的Web文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||
public static FileSystemParameters CreateDefaultWebFileSystemParameters(bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
string fileSystemClass = typeof(DefaultWebFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建默认的WebRemote文件系统参数
|
||||
/// </summary>
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -220,6 +206,7 @@ namespace YooAsset
|
|||
public class HostPlayModeParameters : InitializeParameters
|
||||
{
|
||||
public FileSystemParameters BuildinFileSystemParameters;
|
||||
public FileSystemParameters DeliveryFileSystemParameters;
|
||||
public FileSystemParameters CacheFileSystemParameters;
|
||||
}
|
||||
|
||||
|
@ -228,7 +215,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public class WebPlayModeParameters : InitializeParameters
|
||||
{
|
||||
public FileSystemParameters WebServerFileSystemParameters;
|
||||
public FileSystemParameters WebRemoteFileSystemParameters;
|
||||
public FileSystemParameters WebFileSystemParameters;
|
||||
}
|
||||
}
|
|
@ -42,7 +42,6 @@ namespace YooAsset
|
|||
buffer.WriteUTF8(manifest.BuildPipeline);
|
||||
buffer.WriteUTF8(manifest.PackageName);
|
||||
buffer.WriteUTF8(manifest.PackageVersion);
|
||||
buffer.WriteUTF8(manifest.PackageNote);
|
||||
|
||||
// 写入资源列表
|
||||
buffer.WriteInt32(manifest.AssetList.Count);
|
||||
|
@ -114,7 +113,6 @@ namespace YooAsset
|
|||
manifest.BuildPipeline = buffer.ReadUTF8();
|
||||
manifest.PackageName = buffer.ReadUTF8();
|
||||
manifest.PackageVersion = buffer.ReadUTF8();
|
||||
manifest.PackageNote = buffer.ReadUTF8();
|
||||
|
||||
// 检测配置
|
||||
if (manifest.EnableAddressable && manifest.LocationToLower)
|
||||
|
|
|
@ -171,9 +171,9 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateBuildinFileSystem,
|
||||
CreateFileSystem,
|
||||
InitBuildinFileSystem,
|
||||
CreateCacheFileSystem,
|
||||
InitDeliveryFileSystem,
|
||||
InitCacheFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
@ -181,6 +181,7 @@ namespace YooAsset
|
|||
private readonly HostPlayModeImpl _impl;
|
||||
private readonly HostPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initBuildinFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initDeliveryFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initCacheFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
@ -191,55 +192,14 @@ namespace YooAsset
|
|||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.CreateBuildinFileSystem;
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CreateBuildinFileSystem)
|
||||
{
|
||||
if (_parameters.BuildinFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitBuildinFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitBuildinFileSystem)
|
||||
{
|
||||
if (_initBuildinFileSystemOp == null)
|
||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initBuildinFileSystemOp.Progress;
|
||||
if (_initBuildinFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CreateCacheFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initBuildinFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CreateCacheFileSystem)
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
{
|
||||
if (_parameters.CacheFileSystemParameters == null)
|
||||
{
|
||||
|
@ -249,6 +209,30 @@ namespace YooAsset
|
|||
return;
|
||||
}
|
||||
|
||||
if (_parameters.BuildinFileSystemParameters != null)
|
||||
{
|
||||
_impl.BuildinFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.BuildinFileSystemParameters);
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create buildin file system";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (_parameters.DeliveryFileSystemParameters != null)
|
||||
{
|
||||
_impl.DeliveryFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.DeliveryFileSystemParameters);
|
||||
if (_impl.DeliveryFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create delivery file system";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_impl.CacheFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.CacheFileSystemParameters);
|
||||
if (_impl.CacheFileSystem == null)
|
||||
{
|
||||
|
@ -258,7 +242,63 @@ namespace YooAsset
|
|||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitCacheFileSystem;
|
||||
_steps = ESteps.InitBuildinFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitBuildinFileSystem)
|
||||
{
|
||||
// 注意:内置文件系统可以为空
|
||||
if (_impl.BuildinFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.InitDeliveryFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
if (_initBuildinFileSystemOp == null)
|
||||
_initBuildinFileSystemOp = _impl.BuildinFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initBuildinFileSystemOp.Progress;
|
||||
if (_initBuildinFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initBuildinFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.InitDeliveryFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initBuildinFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitDeliveryFileSystem)
|
||||
{
|
||||
// 注意:分发文件系统可以为空
|
||||
if (_impl.DeliveryFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.InitCacheFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
Progress = _initDeliveryFileSystemOp.Progress;
|
||||
if (_initDeliveryFileSystemOp == null)
|
||||
_initDeliveryFileSystemOp = _impl.DeliveryFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
if (_initDeliveryFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initDeliveryFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.InitCacheFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initDeliveryFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitCacheFileSystem)
|
||||
|
@ -293,18 +333,14 @@ namespace YooAsset
|
|||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CreateWebServerFileSystem,
|
||||
InitWebServerFileSystem,
|
||||
CreateWebRemoteFileSystem,
|
||||
InitWebRemoteFileSystem,
|
||||
CheckResult,
|
||||
CreateFileSystem,
|
||||
InitWebFileSystem,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly WebPlayModeImpl _impl;
|
||||
private readonly WebPlayModeParameters _parameters;
|
||||
private FSInitializeFileSystemOperation _initWebServerFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initWebRemoteFileSystemOp;
|
||||
private FSInitializeFileSystemOperation _initWebFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal WebPlayModeInitializationOperation(WebPlayModeImpl impl, WebPlayModeParameters parameters)
|
||||
|
@ -314,108 +350,55 @@ namespace YooAsset
|
|||
}
|
||||
internal override void InternalOnStart()
|
||||
{
|
||||
_steps = ESteps.CreateWebServerFileSystem;
|
||||
_steps = ESteps.CreateFileSystem;
|
||||
}
|
||||
internal override void InternalOnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CreateWebServerFileSystem)
|
||||
if (_steps == ESteps.CreateFileSystem)
|
||||
{
|
||||
if (_parameters.WebServerFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebServerFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebServerFileSystemParameters);
|
||||
if (_impl.WebServerFileSystem == null)
|
||||
if (_parameters.WebFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web server file system";
|
||||
Error = "Web file system parameters is null";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebServerFileSystem;
|
||||
_impl.WebFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebFileSystemParameters);
|
||||
if (_impl.WebFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitWebServerFileSystem)
|
||||
if (_steps == ESteps.InitWebFileSystem)
|
||||
{
|
||||
if (_initWebServerFileSystemOp == null)
|
||||
_initWebServerFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||
if (_initWebFileSystemOp == null)
|
||||
_initWebFileSystemOp = _impl.WebFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initWebServerFileSystemOp.Progress;
|
||||
if (_initWebServerFileSystemOp.IsDone == false)
|
||||
Progress = _initWebFileSystemOp.Progress;
|
||||
if (_initWebFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initWebServerFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CreateWebRemoteFileSystem;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebServerFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CreateWebRemoteFileSystem)
|
||||
{
|
||||
if (_parameters.WebRemoteFileSystemParameters == null)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.WebRemoteFileSystem = PlayModeHelper.CreateFileSystem(_impl.PackageName, _parameters.WebRemoteFileSystemParameters);
|
||||
if (_impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Failed to create web remote file system";
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.InitWebRemoteFileSystem;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.InitWebRemoteFileSystem)
|
||||
{
|
||||
if (_initWebRemoteFileSystemOp == null)
|
||||
_initWebRemoteFileSystemOp = _impl.WebServerFileSystem.InitializeFileSystemAsync();
|
||||
|
||||
Progress = _initWebRemoteFileSystemOp.Progress;
|
||||
if (_initWebRemoteFileSystemOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_initWebRemoteFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CheckResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebRemoteFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckResult)
|
||||
{
|
||||
if (_impl.WebServerFileSystem == null && _impl.WebRemoteFileSystem == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = "Not found any file system !";
|
||||
}
|
||||
else
|
||||
if (_initWebFileSystemOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _initWebFileSystemOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,6 @@ namespace YooAsset
|
|||
Manifest.BuildPipeline = _buffer.ReadUTF8();
|
||||
Manifest.PackageName = _buffer.ReadUTF8();
|
||||
Manifest.PackageVersion = _buffer.ReadUTF8();
|
||||
Manifest.PackageNote = _buffer.ReadUTF8();
|
||||
|
||||
// 检测配置
|
||||
if (Manifest.EnableAddressable && Manifest.LocationToLower)
|
||||
|
|
|
@ -225,7 +225,7 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(_manifest, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -237,7 +237,7 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, new string[] { tag }, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ namespace YooAsset
|
|||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(_manifest, tags, _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ namespace YooAsset
|
|||
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
|
||||
assetInfos.Add(assetInfo);
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -284,7 +284,7 @@ namespace YooAsset
|
|||
assetInfos.Add(assetInfo);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), _impl.BuildinFileSystem, _impl.DeliveryFileSystem, _impl.CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
|
|
@ -52,11 +52,6 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public string PackageVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包裹的备注信息
|
||||
/// </summary>
|
||||
public string PackageNote;
|
||||
|
||||
/// <summary>
|
||||
/// 资源列表(主动收集的资源列表)
|
||||
/// </summary>
|
||||
|
@ -210,24 +205,10 @@ namespace YooAsset
|
|||
return BundleDic3.ContainsKey(bundleGUID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源信息
|
||||
/// </summary>
|
||||
public AssetInfo[] GetAllAssetInfos()
|
||||
{
|
||||
List<AssetInfo> result = new List<AssetInfo>(AssetList.Count);
|
||||
foreach (var packageAsset in AssetList)
|
||||
{
|
||||
AssetInfo assetInfo = new AssetInfo(PackageName, packageAsset, null);
|
||||
result.Add(assetInfo);
|
||||
}
|
||||
return result.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
public AssetInfo[] GetAssetInfosByTags(string[] tags)
|
||||
public AssetInfo[] GetAssetsInfoByTags(string[] tags)
|
||||
{
|
||||
List<AssetInfo> result = new List<AssetInfo>(100);
|
||||
foreach (var packageAsset in AssetList)
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace YooAsset
|
|||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem BuildinFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem DeliveryFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem CacheFileSystem { set; get; }
|
||||
|
||||
|
||||
|
@ -34,6 +35,9 @@ namespace YooAsset
|
|||
if (BuildinFileSystem != null)
|
||||
BuildinFileSystem.OnUpdate();
|
||||
|
||||
if (DeliveryFileSystem != null)
|
||||
DeliveryFileSystem.OnUpdate();
|
||||
|
||||
if (CacheFileSystem != null)
|
||||
CacheFileSystem.OnUpdate();
|
||||
}
|
||||
|
@ -59,50 +63,50 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, CacheFileSystem, null);
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, CacheFileSystem);
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, BuildinFileSystem, DeliveryFileSystem, CacheFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -119,6 +123,11 @@ namespace YooAsset
|
|||
BundleInfo bundleInfo = new BundleInfo(BuildinFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
if (DeliveryFileSystem != null && DeliveryFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(DeliveryFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
if (CacheFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(CacheFileSystem, packageBundle);
|
||||
|
|
|
@ -7,8 +7,7 @@ namespace YooAsset
|
|||
internal class WebPlayModeImpl : IPlayMode, IBundleQuery
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public IFileSystem WebServerFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem WebRemoteFileSystem { set; get; } //可以为空!
|
||||
public IFileSystem WebFileSystem { set; get; }
|
||||
|
||||
|
||||
public WebPlayModeImpl(string packageName)
|
||||
|
@ -31,42 +30,21 @@ namespace YooAsset
|
|||
|
||||
void IPlayMode.UpdatePlayMode()
|
||||
{
|
||||
if (WebServerFileSystem != null)
|
||||
WebServerFileSystem.OnUpdate();
|
||||
|
||||
if (WebRemoteFileSystem != null)
|
||||
WebRemoteFileSystem.OnUpdate();
|
||||
if (WebFileSystem != null)
|
||||
WebFileSystem.OnUpdate();
|
||||
}
|
||||
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(bool appendTimeTicks, int timeout)
|
||||
{
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(WebRemoteFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(WebServerFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
var operation = new RequestPackageVersionImplOperation(WebFileSystem, appendTimeTicks, timeout);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
UpdatePackageManifestOperation IPlayMode.UpdatePackageManifestAsync(string packageVersion, int timeout)
|
||||
{
|
||||
if (WebRemoteFileSystem != null)
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebRemoteFileSystem, packageVersion, timeout); ;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
{
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebServerFileSystem, packageVersion, timeout); ;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
var operation = new UpdatePackageManifestImplOperation(this, WebFileSystem, packageVersion, timeout);;
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(string packageVersion, int timeout)
|
||||
{
|
||||
|
@ -77,50 +55,50 @@ namespace YooAsset
|
|||
|
||||
ClearAllBundleFilesOperation IPlayMode.ClearAllBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||
var operation = new ClearAllBundleFilesImplOperation(this, WebFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
ClearUnusedBundleFilesOperation IPlayMode.ClearUnusedBundleFilesAsync()
|
||||
{
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebServerFileSystem, WebRemoteFileSystem, null);
|
||||
var operation = new ClearUnusedBundleFilesImplOperation(this, WebFileSystem, null, null);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByAll(ActiveManifest, WebFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByTags(ActiveManifest, tags, WebFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> downloadList = PlayModeHelper.GetDownloadListByPaths(ActiveManifest, assetInfos, WebFileSystem);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByAll(ActiveManifest, WebFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> unpcakList = PlayModeHelper.GetUnpackListByTags(ActiveManifest, tags, WebFileSystem);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout)
|
||||
{
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, WebServerFileSystem, WebRemoteFileSystem);
|
||||
List<BundleInfo> importerList = PlayModeHelper.GetImporterListByFilePaths(ActiveManifest, filePaths, WebFileSystem);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
|
@ -132,15 +110,9 @@ namespace YooAsset
|
|||
if (packageBundle == null)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
if (WebServerFileSystem != null && WebServerFileSystem.Belong(packageBundle))
|
||||
if (WebFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(WebServerFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
if (WebRemoteFileSystem != null && WebRemoteFileSystem.Belong(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(WebRemoteFileSystem, packageBundle);
|
||||
BundleInfo bundleInfo = new BundleInfo(WebFileSystem, packageBundle);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,6 +176,16 @@ namespace YooAsset
|
|||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// 检测文件系统参数
|
||||
if (_playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
var webPlayModeParams = parameters as WebPlayModeParameters;
|
||||
var fileSystemClassName = webPlayModeParams.WebFileSystemParameters.FileSystemClass;
|
||||
if (fileSystemClassName == typeof(DefaultCacheFileSystem).FullName
|
||||
|| fileSystemClassName == typeof(DefaultBuildinFileSystem).FullName)
|
||||
throw new Exception($"{fileSystemClassName} not support {nameof(EPlayMode.WebPlayMode)}");
|
||||
}
|
||||
}
|
||||
private void InitializeOperation_Completed(AsyncOperationBase op)
|
||||
{
|
||||
|
@ -262,15 +272,6 @@ namespace YooAsset
|
|||
return _playModeImpl.ActiveManifest.PackageVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取本地包裹的备注信息
|
||||
/// </summary>
|
||||
public string GetPackageNote()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.PackageNote;
|
||||
}
|
||||
|
||||
#region 资源回收
|
||||
/// <summary>
|
||||
/// 强制回收所有资源
|
||||
|
@ -339,15 +340,6 @@ namespace YooAsset
|
|||
return IsNeedDownloadFromRemoteInternal(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有的资源信息
|
||||
/// </summary>
|
||||
public AssetInfo[] GetAllAssetInfos()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetAllAssetInfos();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
|
@ -356,7 +348,7 @@ namespace YooAsset
|
|||
{
|
||||
DebugCheckInitialize();
|
||||
string[] tags = new string[] { tag };
|
||||
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
return _playModeImpl.ActiveManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -366,7 +358,7 @@ namespace YooAsset
|
|||
public AssetInfo[] GetAssetInfos(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
return _playModeImpl.ActiveManifest.GetAssetsInfoByTags(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -29,7 +29,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 清单文件格式版本
|
||||
/// </summary>
|
||||
public const string ManifestFileVersion = "2.2.5";
|
||||
public const string ManifestFileVersion = "2.0.0";
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
public static class AssetHandleExtension
|
||||
public static class AssetOperationHandleExtension
|
||||
{
|
||||
/// <summary>
|
||||
/// 等待异步执行完毕
|
|
@ -1,159 +0,0 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Security.Policy;
|
||||
using UnityEngine;
|
||||
using YooAsset;
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置清单文件到沙盒目录
|
||||
/// </summary>
|
||||
public class CopyBuildinManifestOperation : GameAsyncOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
None,
|
||||
CheckHashFile,
|
||||
UnpackHashFile,
|
||||
CheckManifestFile,
|
||||
UnpackManifestFile,
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly string _packageName;
|
||||
private readonly string _packageVersion;
|
||||
private ESteps _steps = ESteps.None;
|
||||
private UnityWebFileRequestOperation _hashFileRequestOp;
|
||||
private UnityWebFileRequestOperation _manifestFileRequestOp;
|
||||
|
||||
public CopyBuildinManifestOperation(string packageName, string packageVersion)
|
||||
{
|
||||
_packageName = packageName;
|
||||
_packageVersion = packageVersion;
|
||||
}
|
||||
protected override void OnStart()
|
||||
{
|
||||
_steps = ESteps.CheckHashFile;
|
||||
}
|
||||
protected override void OnUpdate()
|
||||
{
|
||||
if (_steps == ESteps.None || _steps == ESteps.Done)
|
||||
return;
|
||||
|
||||
if (_steps == ESteps.CheckHashFile)
|
||||
{
|
||||
string hashFilePath = GetCacheHashFilePath();
|
||||
if (File.Exists(hashFilePath))
|
||||
{
|
||||
_steps = ESteps.CheckManifestFile;
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.UnpackHashFile;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnpackHashFile)
|
||||
{
|
||||
if(_hashFileRequestOp == null)
|
||||
{
|
||||
string sourcePath = GetBuildinHashFilePath();
|
||||
string destPath = GetCacheHashFilePath();
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||
OperationSystem.StartOperation(_packageName, _hashFileRequestOp);
|
||||
}
|
||||
|
||||
if (_hashFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_hashFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.CheckManifestFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _hashFileRequestOp.Error;
|
||||
}
|
||||
}
|
||||
|
||||
if (_steps == ESteps.CheckManifestFile)
|
||||
{
|
||||
string manifestFilePath = GetCacheManifestFilePath();
|
||||
if (File.Exists(manifestFilePath))
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
}
|
||||
|
||||
_steps = ESteps.UnpackManifestFile;
|
||||
}
|
||||
|
||||
if (_steps == ESteps.UnpackManifestFile)
|
||||
{
|
||||
if (_manifestFileRequestOp == null)
|
||||
{
|
||||
string sourcePath = GetBuildinManifestFilePath();
|
||||
string destPath = GetCacheManifestFilePath();
|
||||
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
|
||||
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath);
|
||||
OperationSystem.StartOperation(_packageName, _manifestFileRequestOp);
|
||||
}
|
||||
|
||||
if (_manifestFileRequestOp.IsDone == false)
|
||||
return;
|
||||
|
||||
if (_manifestFileRequestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = _manifestFileRequestOp.Error;
|
||||
}
|
||||
}
|
||||
}
|
||||
protected override void OnAbort()
|
||||
{
|
||||
}
|
||||
|
||||
private string GetBuildinYooRoot()
|
||||
{
|
||||
return PathUtility.Combine(Application.streamingAssetsPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
}
|
||||
private string GetBuildinHashFilePath()
|
||||
{
|
||||
string fileRoot = GetBuildinYooRoot();
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
|
||||
return PathUtility.Combine(fileRoot, fileName);
|
||||
}
|
||||
private string GetBuildinManifestFilePath()
|
||||
{
|
||||
string fileRoot = GetBuildinYooRoot();
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
||||
return PathUtility.Combine(fileRoot, fileName);
|
||||
}
|
||||
|
||||
private string GetCacheYooRoot()
|
||||
{
|
||||
return PathUtility.Combine(UnityEngine.Application.persistentDataPath, YooAssetSettingsData.Setting.DefaultYooFolderName);
|
||||
}
|
||||
private string GetCacheHashFilePath()
|
||||
{
|
||||
string fileRoot = GetCacheYooRoot();
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(_packageName, _packageVersion);
|
||||
return PathUtility.Combine(fileRoot, fileName);
|
||||
}
|
||||
private string GetCacheManifestFilePath()
|
||||
{
|
||||
string fileRoot = GetCacheYooRoot();
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_packageName, _packageVersion);
|
||||
return PathUtility.Combine(fileRoot, fileName);
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41ab464f315df234fb40b0c24e97ee23
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -92,7 +92,7 @@ internal class FsmInitializePackage : IStateNode
|
|||
IRemoteServices remoteServices = new RemoteServices(defaultHostServer, fallbackHostServer);
|
||||
createParameters.WebFileSystemParameters = WechatFileSystemCreater.CreateWechatFileSystemParameters(remoteServices);
|
||||
#else
|
||||
createParameters.WebServerFileSystemParameters = FileSystemParameters.CreateDefaultWebServerFileSystemParameters();
|
||||
createParameters.WebFileSystemParameters = FileSystemParameters.CreateDefaultWebFileSystemParameters();
|
||||
#endif
|
||||
initializationOperation = package.InitializeAsync(createParameters);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue