update runtime code

代码里移除了Patch敏感字。
pull/82/head
hevinci 2023-03-11 00:06:40 +08:00
parent 10e04c7645
commit 67d09d95fa
38 changed files with 692 additions and 580 deletions

View File

@ -1,8 +1,8 @@
 using UnityEngine;
namespace YooAsset namespace YooAsset
{ {
public class AssetReference public class AssetReference
{ {
} }
} }

View File

@ -110,7 +110,7 @@ namespace YooAsset
if (_steps == ESteps.Unpack) if (_steps == ESteps.Unpack)
{ {
int failedTryAgain = 1; int failedTryAgain = 1;
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
_steps = ESteps.CheckUnpack; _steps = ESteps.CheckUnpack;
} }

View File

@ -92,7 +92,7 @@ namespace YooAsset
if (_steps == ESteps.Unpack) if (_steps == ESteps.Unpack)
{ {
int failedTryAgain = 1; int failedTryAgain = 1;
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
_steps = ESteps.CheckUnpack; _steps = ESteps.CheckUnpack;
} }

View File

@ -90,7 +90,7 @@ namespace YooAsset
if (_steps == ESteps.Website) if (_steps == ESteps.Website)
{ {
int failedTryAgain = 1; int failedTryAgain = 1;
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle); var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
_website = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain); _website = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
_steps = ESteps.CheckWebsite; _steps = ESteps.CheckWebsite;
} }

View File

@ -133,7 +133,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 获取未被使用的缓存文件 /// 获取未被使用的缓存文件
/// </summary> /// </summary>
public static List<string> GetUnusedCacheGUIDs(AssetsPackage package) public static List<string> GetUnusedCacheGUIDs(ResourcePackage package)
{ {
var cache = GetOrCreateCache(package.PackageName); var cache = GetOrCreateCache(package.PackageName);
var keys = cache.GetAllKeys(); var keys = cache.GetAllKeys();

View File

@ -17,12 +17,12 @@ namespace YooAsset
Done, Done,
} }
private readonly AssetsPackage _package; private readonly ResourcePackage _package;
private List<string> _unusedCacheGUIDs; private List<string> _unusedCacheGUIDs;
private int _unusedFileTotalCount = 0; private int _unusedFileTotalCount = 0;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal ClearUnusedCacheFilesOperation(AssetsPackage package) internal ClearUnusedCacheFilesOperation(ResourcePackage package)
{ {
_package = package; _package = package;
} }

View File

@ -53,7 +53,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 用于模拟运行的资源清单路径 /// 用于模拟运行的资源清单路径
/// </summary> /// </summary>
public string SimulatePatchManifestPath = string.Empty; public string SimulateManifestFilePath = string.Empty;
} }
/// <summary> /// <summary>

View File

@ -3,7 +3,7 @@ namespace YooAsset
{ {
public class AssetInfo public class AssetInfo
{ {
private readonly PatchAsset _patchAsset; private readonly PackageAsset _packageAsset;
private string _providerGUID; private string _providerGUID;
/// <summary> /// <summary>
@ -42,7 +42,7 @@ namespace YooAsset
{ {
get get
{ {
return _patchAsset == null; return _packageAsset == null;
} }
} }
@ -53,9 +53,9 @@ namespace YooAsset
{ {
get get
{ {
if (_patchAsset == null) if (_packageAsset == null)
return string.Empty; return string.Empty;
return _patchAsset.Address; return _packageAsset.Address;
} }
} }
@ -66,9 +66,9 @@ namespace YooAsset
{ {
get get
{ {
if (_patchAsset == null) if (_packageAsset == null)
return string.Empty; return string.Empty;
return _patchAsset.AssetPath; return _packageAsset.AssetPath;
} }
} }
@ -77,30 +77,30 @@ namespace YooAsset
{ {
// 注意:禁止从外部创建该类 // 注意:禁止从外部创建该类
} }
internal AssetInfo(PatchAsset patchAsset, System.Type assetType) internal AssetInfo(PackageAsset packageAsset, System.Type assetType)
{ {
if (patchAsset == null) if (packageAsset == null)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
_providerGUID = string.Empty; _providerGUID = string.Empty;
_patchAsset = patchAsset; _packageAsset = packageAsset;
AssetType = assetType; AssetType = assetType;
Error = string.Empty; Error = string.Empty;
} }
internal AssetInfo(PatchAsset patchAsset) internal AssetInfo(PackageAsset packageAsset)
{ {
if (patchAsset == null) if (packageAsset == null)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
_providerGUID = string.Empty; _providerGUID = string.Empty;
_patchAsset = patchAsset; _packageAsset = packageAsset;
AssetType = null; AssetType = null;
Error = string.Empty; Error = string.Empty;
} }
internal AssetInfo(string error) internal AssetInfo(string error)
{ {
_providerGUID = string.Empty; _providerGUID = string.Empty;
_patchAsset = null; _packageAsset = null;
AssetType = null; AssetType = null;
Error = error; Error = error;
} }

View File

@ -12,7 +12,7 @@ namespace YooAsset
LoadFromEditor, LoadFromEditor,
} }
public readonly PatchBundle Bundle; public readonly PackageBundle Bundle;
public readonly ELoadMode LoadMode; public readonly ELoadMode LoadMode;
/// <summary> /// <summary>
@ -34,25 +34,25 @@ namespace YooAsset
private BundleInfo() private BundleInfo()
{ {
} }
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string mainURL, string fallbackURL) public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string mainURL, string fallbackURL)
{ {
Bundle = patchBundle; Bundle = bundle;
LoadMode = loadMode; LoadMode = loadMode;
RemoteMainURL = mainURL; RemoteMainURL = mainURL;
RemoteFallbackURL = fallbackURL; RemoteFallbackURL = fallbackURL;
EditorAssetPath = string.Empty; EditorAssetPath = string.Empty;
} }
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode, string editorAssetPath) public BundleInfo(PackageBundle bundle, ELoadMode loadMode, string editorAssetPath)
{ {
Bundle = patchBundle; Bundle = bundle;
LoadMode = loadMode; LoadMode = loadMode;
RemoteMainURL = string.Empty; RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty; RemoteFallbackURL = string.Empty;
EditorAssetPath = editorAssetPath; EditorAssetPath = editorAssetPath;
} }
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode) public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
{ {
Bundle = patchBundle; Bundle = bundle;
LoadMode = loadMode; LoadMode = loadMode;
RemoteMainURL = string.Empty; RemoteMainURL = string.Empty;
RemoteFallbackURL = string.Empty; RemoteFallbackURL = string.Empty;

View File

@ -0,0 +1,193 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
internal static class ManifestTools
{
#if UNITY_EDITOR
/// <summary>
/// 序列化JSON文件
/// </summary>
public static void SerializeToJson(string savePath, PackageManifest manifest)
{
string json = JsonUtility.ToJson(manifest, true);
FileUtility.CreateFile(savePath, json);
}
/// <summary>
/// 序列化(二进制文件)
/// </summary>
public static void SerializeToBinary(string savePath, PackageManifest manifest)
{
using (FileStream fs = new FileStream(savePath, FileMode.Create))
{
// 创建缓存器
BufferWriter buffer = new BufferWriter(YooAssetSettings.ManifestFileMaxSize);
// 写入文件标记
buffer.WriteUInt32(YooAssetSettings.ManifestFileSign);
// 写入文件版本
buffer.WriteUTF8(manifest.FileVersion);
// 写入文件头信息
buffer.WriteBool(manifest.EnableAddressable);
buffer.WriteInt32(manifest.OutputNameStyle);
buffer.WriteUTF8(manifest.PackageName);
buffer.WriteUTF8(manifest.PackageVersion);
// 写入资源列表
buffer.WriteInt32(manifest.AssetList.Count);
for (int i = 0; i < manifest.AssetList.Count; i++)
{
var packageAsset = manifest.AssetList[i];
buffer.WriteUTF8(packageAsset.Address);
buffer.WriteUTF8(packageAsset.AssetPath);
buffer.WriteUTF8Array(packageAsset.AssetTags);
buffer.WriteInt32(packageAsset.BundleID);
buffer.WriteInt32Array(packageAsset.DependIDs);
}
// 写入资源包列表
buffer.WriteInt32(manifest.BundleList.Count);
for (int i = 0; i < manifest.BundleList.Count; i++)
{
var packageBundle = manifest.BundleList[i];
buffer.WriteUTF8(packageBundle.BundleName);
buffer.WriteUTF8(packageBundle.FileHash);
buffer.WriteUTF8(packageBundle.FileCRC);
buffer.WriteInt64(packageBundle.FileSize);
buffer.WriteBool(packageBundle.IsRawFile);
buffer.WriteByte(packageBundle.LoadMethod);
buffer.WriteUTF8Array(packageBundle.Tags);
buffer.WriteInt32Array(packageBundle.ReferenceIDs);
}
// 写入文件流
buffer.WriteToStream(fs);
fs.Flush();
}
}
/// <summary>
/// 反序列化(二进制文件)
/// </summary>
public static PackageManifest DeserializeFromBinary(byte[] binaryData)
{
// 创建缓存器
BufferReader buffer = new BufferReader(binaryData);
// 读取文件标记
uint fileSign = buffer.ReadUInt32();
if (fileSign != YooAssetSettings.ManifestFileSign)
throw new Exception("Invalid manifest file !");
// 读取文件版本
string fileVersion = buffer.ReadUTF8();
if (fileVersion != YooAssetSettings.ManifestFileVersion)
throw new Exception($"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.ManifestFileVersion}");
PackageManifest manifest = new PackageManifest();
{
// 读取文件头信息
manifest.FileVersion = fileVersion;
manifest.EnableAddressable = buffer.ReadBool();
manifest.OutputNameStyle = buffer.ReadInt32();
manifest.PackageName = buffer.ReadUTF8();
manifest.PackageVersion = buffer.ReadUTF8();
// 读取资源列表
int packageAssetCount = buffer.ReadInt32();
manifest.AssetList = new List<PackageAsset>(packageAssetCount);
for (int i = 0; i < packageAssetCount; i++)
{
var packageAsset = new PackageAsset();
packageAsset.Address = buffer.ReadUTF8();
packageAsset.AssetPath = buffer.ReadUTF8();
packageAsset.AssetTags = buffer.ReadUTF8Array();
packageAsset.BundleID = buffer.ReadInt32();
packageAsset.DependIDs = buffer.ReadInt32Array();
manifest.AssetList.Add(packageAsset);
}
// 读取资源包列表
int packageBundleCount = buffer.ReadInt32();
manifest.BundleList = new List<PackageBundle>(packageBundleCount);
for (int i = 0; i < packageBundleCount; i++)
{
var packageBundle = new PackageBundle();
packageBundle.BundleName = buffer.ReadUTF8();
packageBundle.FileHash = buffer.ReadUTF8();
packageBundle.FileCRC = buffer.ReadUTF8();
packageBundle.FileSize = buffer.ReadInt64();
packageBundle.IsRawFile = buffer.ReadBool();
packageBundle.LoadMethod = buffer.ReadByte();
packageBundle.Tags = buffer.ReadUTF8Array();
packageBundle.ReferenceIDs = buffer.ReadInt32Array();
manifest.BundleList.Add(packageBundle);
}
}
// BundleDic
manifest.BundleDic = new Dictionary<string, PackageBundle>(manifest.BundleList.Count);
foreach (var packageBundle in manifest.BundleList)
{
packageBundle.ParseBundle(manifest.PackageName, manifest.OutputNameStyle);
manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
}
// AssetDic
manifest.AssetDic = new Dictionary<string, PackageAsset>(manifest.AssetList.Count);
foreach (var packageAsset in manifest.AssetList)
{
// 注意:我们不允许原始路径存在重名
string assetPath = packageAsset.AssetPath;
if (manifest.AssetDic.ContainsKey(assetPath))
throw new Exception($"AssetPath have existed : {assetPath}");
else
manifest.AssetDic.Add(assetPath, packageAsset);
}
return manifest;
}
#endif
public static string GetRemoteBundleFileExtension(string bundleName)
{
string fileExtension = Path.GetExtension(bundleName);
return fileExtension;
}
public static string GetRemoteBundleFileName(int nameStyle, string bundleName, string fileExtension, string fileHash)
{
if (nameStyle == 1) //HashName
{
return StringUtility.Format("{0}{1}", fileHash, fileExtension);
}
else if (nameStyle == 4) //BundleName_HashName
{
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
return StringUtility.Format("{0}_{1}{2}", fileName, fileHash, fileExtension);
}
else
{
throw new NotImplementedException($"Invalid name style : {nameStyle}");
}
}
/// <summary>
/// 获取解压BundleInfo
/// </summary>
public static BundleInfo GetUnpackInfo(PackageBundle packageBundle)
{
// 注意:我们把流加载路径指定为远端下载地址
string streamingPath = PathHelper.ConvertToWWWPath(packageBundle.StreamingFilePath);
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
return bundleInfo;
}
}
}

View File

@ -94,9 +94,9 @@ namespace YooAsset
if (downloadList != null) if (downloadList != null)
{ {
TotalDownloadCount = downloadList.Count; TotalDownloadCount = downloadList.Count;
foreach (var patchBundle in downloadList) foreach (var packageBundle in downloadList)
{ {
TotalDownloadBytes += patchBundle.Bundle.FileSize; TotalDownloadBytes += packageBundle.Bundle.FileSize;
} }
} }
} }
@ -249,9 +249,9 @@ namespace YooAsset
} }
} }
public sealed class PatchDownloaderOperation : DownloaderOperation public sealed class ResourceDownloaderOperation : DownloaderOperation
{ {
internal PatchDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal ResourceDownloaderOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{ {
} }
@ -259,16 +259,16 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建空的下载器 /// 创建空的下载器
/// </summary> /// </summary>
internal static PatchDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout) internal static ResourceDownloaderOperation CreateEmptyDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
} }
public sealed class PatchUnpackerOperation : DownloaderOperation public sealed class ResourceUnpackerOperation : DownloaderOperation
{ {
internal PatchUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal ResourceUnpackerOperation(List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout)
: base(downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(downloadList, downloadingMaxNumber, failedTryAgain, timeout)
{ {
} }
@ -276,10 +276,10 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建空的解压器 /// 创建空的解压器
/// </summary> /// </summary>
internal static PatchUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout) internal static ResourceUnpackerOperation CreateEmptyUnpacker(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue); var operation = new ResourceUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
return operation; return operation;
} }
} }

View File

@ -26,14 +26,14 @@ namespace YooAsset
} }
private readonly EditorSimulateModeImpl _impl; private readonly EditorSimulateModeImpl _impl;
private readonly string _simulateManifestPath; private readonly string _simulateManifestFilePath;
private LoadEditorManifestOperation _loadEditorManifestOp; private LoadEditorManifestOperation _loadEditorManifestOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestPath) internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestFilePath)
{ {
_impl = impl; _impl = impl;
_simulateManifestPath = simulateManifestPath; _simulateManifestFilePath = simulateManifestFilePath;
} }
internal override void Start() internal override void Start()
{ {
@ -45,7 +45,7 @@ namespace YooAsset
{ {
if (_loadEditorManifestOp == null) if (_loadEditorManifestOp == null)
{ {
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestPath); _loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestFilePath);
OperationSystem.StartOperation(_loadEditorManifestOp); OperationSystem.StartOperation(_loadEditorManifestOp);
} }

View File

@ -18,15 +18,15 @@ namespace YooAsset
} }
private readonly BufferReader _buffer; private readonly BufferReader _buffer;
private int _patchAssetCount; private int _packageAssetCount;
private int _patchBundleCount; private int _packageBundleCount;
private int _progressTotalValue; private int _progressTotalValue;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
/// <summary> /// <summary>
/// 解析的清单实例 /// 解析的清单实例
/// </summary> /// </summary>
public PatchManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
public DeserializeManifestOperation(byte[] binaryData) public DeserializeManifestOperation(byte[] binaryData)
{ {
@ -55,7 +55,7 @@ namespace YooAsset
// 读取文件标记 // 读取文件标记
uint fileSign = _buffer.ReadUInt32(); uint fileSign = _buffer.ReadUInt32();
if (fileSign != YooAssetSettings.PatchManifestFileSign) if (fileSign != YooAssetSettings.ManifestFileSign)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
@ -65,16 +65,16 @@ namespace YooAsset
// 读取文件版本 // 读取文件版本
string fileVersion = _buffer.ReadUTF8(); string fileVersion = _buffer.ReadUTF8();
if (fileVersion != YooAssetSettings.PatchManifestFileVersion) if (fileVersion != YooAssetSettings.ManifestFileVersion)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.PatchManifestFileVersion}"; Error = $"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.ManifestFileVersion}";
return; return;
} }
// 读取文件头信息 // 读取文件头信息
Manifest = new PatchManifest(); Manifest = new PackageManifest();
Manifest.FileVersion = fileVersion; Manifest.FileVersion = fileVersion;
Manifest.EnableAddressable = _buffer.ReadBool(); Manifest.EnableAddressable = _buffer.ReadBool();
Manifest.OutputNameStyle = _buffer.ReadInt32(); Manifest.OutputNameStyle = _buffer.ReadInt32();
@ -86,38 +86,38 @@ namespace YooAsset
if (_steps == ESteps.PrepareAssetList) if (_steps == ESteps.PrepareAssetList)
{ {
_patchAssetCount = _buffer.ReadInt32(); _packageAssetCount = _buffer.ReadInt32();
Manifest.AssetList = new List<PatchAsset>(_patchAssetCount); Manifest.AssetList = new List<PackageAsset>(_packageAssetCount);
Manifest.AssetDic = new Dictionary<string, PatchAsset>(_patchAssetCount); Manifest.AssetDic = new Dictionary<string, PackageAsset>(_packageAssetCount);
_progressTotalValue = _patchAssetCount; _progressTotalValue = _packageAssetCount;
_steps = ESteps.DeserializeAssetList; _steps = ESteps.DeserializeAssetList;
} }
if (_steps == ESteps.DeserializeAssetList) if (_steps == ESteps.DeserializeAssetList)
{ {
while (_patchAssetCount > 0) while (_packageAssetCount > 0)
{ {
var patchAsset = new PatchAsset(); var packageAsset = new PackageAsset();
patchAsset.Address = _buffer.ReadUTF8(); packageAsset.Address = _buffer.ReadUTF8();
patchAsset.AssetPath = _buffer.ReadUTF8(); packageAsset.AssetPath = _buffer.ReadUTF8();
patchAsset.AssetTags = _buffer.ReadUTF8Array(); packageAsset.AssetTags = _buffer.ReadUTF8Array();
patchAsset.BundleID = _buffer.ReadInt32(); packageAsset.BundleID = _buffer.ReadInt32();
patchAsset.DependIDs = _buffer.ReadInt32Array(); packageAsset.DependIDs = _buffer.ReadInt32Array();
Manifest.AssetList.Add(patchAsset); Manifest.AssetList.Add(packageAsset);
// 注意:我们不允许原始路径存在重名 // 注意:我们不允许原始路径存在重名
string assetPath = patchAsset.AssetPath; string assetPath = packageAsset.AssetPath;
if (Manifest.AssetDic.ContainsKey(assetPath)) if (Manifest.AssetDic.ContainsKey(assetPath))
throw new System.Exception($"AssetPath have existed : {assetPath}"); throw new System.Exception($"AssetPath have existed : {assetPath}");
else else
Manifest.AssetDic.Add(assetPath, patchAsset); Manifest.AssetDic.Add(assetPath, packageAsset);
_patchAssetCount--; _packageAssetCount--;
Progress = 1f - _patchAssetCount / _progressTotalValue; Progress = 1f - _packageAssetCount / _progressTotalValue;
if (OperationSystem.IsBusy) if (OperationSystem.IsBusy)
break; break;
} }
if (_patchAssetCount <= 0) if (_packageAssetCount <= 0)
{ {
_steps = ESteps.PrepareBundleList; _steps = ESteps.PrepareBundleList;
} }
@ -125,37 +125,37 @@ namespace YooAsset
if (_steps == ESteps.PrepareBundleList) if (_steps == ESteps.PrepareBundleList)
{ {
_patchBundleCount = _buffer.ReadInt32(); _packageBundleCount = _buffer.ReadInt32();
Manifest.BundleList = new List<PatchBundle>(_patchBundleCount); Manifest.BundleList = new List<PackageBundle>(_packageBundleCount);
Manifest.BundleDic = new Dictionary<string, PatchBundle>(_patchBundleCount); Manifest.BundleDic = new Dictionary<string, PackageBundle>(_packageBundleCount);
_progressTotalValue = _patchBundleCount; _progressTotalValue = _packageBundleCount;
_steps = ESteps.DeserializeBundleList; _steps = ESteps.DeserializeBundleList;
} }
if (_steps == ESteps.DeserializeBundleList) if (_steps == ESteps.DeserializeBundleList)
{ {
while (_patchBundleCount > 0) while (_packageBundleCount > 0)
{ {
var patchBundle = new PatchBundle(); var packageBundle = new PackageBundle();
patchBundle.BundleName = _buffer.ReadUTF8(); packageBundle.BundleName = _buffer.ReadUTF8();
patchBundle.FileHash = _buffer.ReadUTF8(); packageBundle.FileHash = _buffer.ReadUTF8();
patchBundle.FileCRC = _buffer.ReadUTF8(); packageBundle.FileCRC = _buffer.ReadUTF8();
patchBundle.FileSize = _buffer.ReadInt64(); packageBundle.FileSize = _buffer.ReadInt64();
patchBundle.IsRawFile = _buffer.ReadBool(); packageBundle.IsRawFile = _buffer.ReadBool();
patchBundle.LoadMethod = _buffer.ReadByte(); packageBundle.LoadMethod = _buffer.ReadByte();
patchBundle.Tags = _buffer.ReadUTF8Array(); packageBundle.Tags = _buffer.ReadUTF8Array();
patchBundle.ReferenceIDs = _buffer.ReadInt32Array(); packageBundle.ReferenceIDs = _buffer.ReadInt32Array();
Manifest.BundleList.Add(patchBundle); Manifest.BundleList.Add(packageBundle);
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle); packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
Manifest.BundleDic.Add(patchBundle.BundleName, patchBundle); Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
_patchBundleCount--; _packageBundleCount--;
Progress = 1f - _patchBundleCount / _progressTotalValue; Progress = 1f - _packageBundleCount / _progressTotalValue;
if (OperationSystem.IsBusy) if (OperationSystem.IsBusy)
break; break;
} }
if (_patchBundleCount <= 0) if (_packageBundleCount <= 0)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;

View File

@ -20,7 +20,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 加载的清单实例 /// 加载的清单实例
/// </summary> /// </summary>
public PatchManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
public LoadBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion) public LoadBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)

View File

@ -24,7 +24,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 加载的清单实例 /// 加载的清单实例
/// </summary> /// </summary>
public PatchManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
public LoadCacheManifestOperation(string packageName, string packageVersion) public LoadCacheManifestOperation(string packageName, string packageVersion)

View File

@ -19,7 +19,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 加载的清单实例 /// 加载的清单实例
/// </summary> /// </summary>
public PatchManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
public LoadEditorManifestOperation(string manifestFilePath) public LoadEditorManifestOperation(string manifestFilePath)

View File

@ -4,57 +4,69 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
public abstract class PreDownloadPackageOperation : AsyncOperationBase public abstract class PreDownloadContentOperation : AsyncOperationBase
{ {
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定资源版本所有的资源包文件 /// 创建资源下载器,用于下载当前资源版本所有的资源包文件
/// </summary> /// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public virtual ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
/// </summary> /// </summary>
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public virtual ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
/// </summary> /// </summary>
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public virtual ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件 /// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary> /// </summary>
/// <param name="locations">资源定位列表</param> /// <param name="location">资源定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public virtual PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public virtual ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public virtual ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
} }
public class EditorPlayModePreDownloadPackageOperation : PreDownloadPackageOperation internal class EditorPlayModePreDownloadContentOperation : PreDownloadContentOperation
{ {
internal override void Start() internal override void Start()
{ {
@ -64,7 +76,7 @@ namespace YooAsset
{ {
} }
} }
public class OfflinePlayModePreDownloadPackageOperation : PreDownloadPackageOperation internal class OfflinePlayModePreDownloadContentOperation : PreDownloadContentOperation
{ {
internal override void Start() internal override void Start()
{ {
@ -74,7 +86,7 @@ namespace YooAsset
{ {
} }
} }
public class HostPlayModePreDownloadPackageOperation : PreDownloadPackageOperation internal class HostPlayModePreDownloadContentOperation : PreDownloadContentOperation
{ {
private enum ESteps private enum ESteps
{ {
@ -94,11 +106,11 @@ namespace YooAsset
private LoadCacheManifestOperation _tryLoadCacheManifestOp; private LoadCacheManifestOperation _tryLoadCacheManifestOp;
private LoadCacheManifestOperation _loadCacheManifestOp; private LoadCacheManifestOperation _loadCacheManifestOp;
private DownloadManifestOperation _downloadManifestOp; private DownloadManifestOperation _downloadManifestOp;
private PatchManifest _manifest; private PackageManifest _manifest;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal HostPlayModePreDownloadPackageOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout) internal HostPlayModePreDownloadContentOperation(HostPlayModeImpl impl, string packageName, string packageVersion, int timeout)
{ {
_impl = impl; _impl = impl;
_packageName = packageName; _packageName = packageName;
@ -202,48 +214,64 @@ namespace YooAsset
} }
} }
public override PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public override ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest); List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public override PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public override ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag }); List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public override PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public override ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags); List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public override PatchDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public override ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
}
List<AssetInfo> assetInfos = new List<AssetInfo>();
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray());
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation;
}
public override ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
if (Status != EOperationStatus.Succeed)
{
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length); List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@ -254,7 +282,7 @@ namespace YooAsset
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray()); List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray());
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
} }

View File

@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
/// <summary> /// <summary>
/// 向远端请求并更新补丁清单 /// 向远端请求并更新清单
/// </summary> /// </summary>
public abstract class UpdatePackageManifestOperation : AsyncOperationBase public abstract class UpdatePackageManifestOperation : AsyncOperationBase
{ {

View File

@ -4,7 +4,7 @@ using System.Linq;
namespace YooAsset namespace YooAsset
{ {
[Serializable] [Serializable]
internal class PatchAsset internal class PackageAsset
{ {
/// <summary> /// <summary>
/// 可寻址地址 /// 可寻址地址

View File

@ -4,7 +4,7 @@ using System.Linq;
namespace YooAsset namespace YooAsset
{ {
[Serializable] [Serializable]
internal class PatchBundle internal class PackageBundle
{ {
/// <summary> /// <summary>
/// 资源包名称 /// 资源包名称
@ -173,7 +173,7 @@ namespace YooAsset
} }
public PatchBundle() public PackageBundle()
{ {
} }
@ -183,8 +183,8 @@ namespace YooAsset
public void ParseBundle(string packageName, int nameStype) public void ParseBundle(string packageName, int nameStype)
{ {
PackageName = packageName; PackageName = packageName;
_fileExtension = PatchManifestTools.GetRemoteBundleFileExtension(BundleName); _fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName);
_fileName = PatchManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash); _fileName = ManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash);
} }
/// <summary> /// <summary>
@ -219,7 +219,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 检测资源包文件内容是否相同 /// 检测资源包文件内容是否相同
/// </summary> /// </summary>
public bool Equals(PatchBundle otherBundle) public bool Equals(PackageBundle otherBundle)
{ {
if (FileHash == otherBundle.FileHash) if (FileHash == otherBundle.FileHash)
return true; return true;

View File

@ -7,10 +7,10 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
/// <summary> /// <summary>
/// 补丁清单文件 /// 清单文件
/// </summary> /// </summary>
[Serializable] [Serializable]
internal class PatchManifest internal class PackageManifest
{ {
/// <summary> /// <summary>
/// 文件版本 /// 文件版本
@ -40,25 +40,25 @@ namespace YooAsset
/// <summary> /// <summary>
/// 资源列表(主动收集的资源列表) /// 资源列表(主动收集的资源列表)
/// </summary> /// </summary>
public List<PatchAsset> AssetList = new List<PatchAsset>(); public List<PackageAsset> AssetList = new List<PackageAsset>();
/// <summary> /// <summary>
/// 资源包列表 /// 资源包列表
/// </summary> /// </summary>
public List<PatchBundle> BundleList = new List<PatchBundle>(); public List<PackageBundle> BundleList = new List<PackageBundle>();
/// <summary> /// <summary>
/// 资源包集合提供BundleName获取PatchBundle /// 资源包集合提供BundleName获取PackageBundle
/// </summary> /// </summary>
[NonSerialized] [NonSerialized]
public Dictionary<string, PatchBundle> BundleDic; public Dictionary<string, PackageBundle> BundleDic;
/// <summary> /// <summary>
/// 资源映射集合提供AssetPath获取PatchAsset /// 资源映射集合提供AssetPath获取PackageAsset
/// </summary> /// </summary>
[NonSerialized] [NonSerialized]
public Dictionary<string, PatchAsset> AssetDic; public Dictionary<string, PackageAsset> AssetDic;
/// <summary> /// <summary>
/// 资源路径映射集合 /// 资源路径映射集合
@ -86,22 +86,22 @@ namespace YooAsset
YooLogger.Error("Addressable not support location to lower !"); YooLogger.Error("Addressable not support location to lower !");
AssetPathMapping = new Dictionary<string, string>(AssetList.Count); AssetPathMapping = new Dictionary<string, string>(AssetList.Count);
foreach (var patchAsset in AssetList) foreach (var packageAsset in AssetList)
{ {
string location = patchAsset.Address; string location = packageAsset.Address;
if (AssetPathMapping.ContainsKey(location)) if (AssetPathMapping.ContainsKey(location))
throw new Exception($"Address have existed : {location}"); throw new Exception($"Address have existed : {location}");
else else
AssetPathMapping.Add(location, patchAsset.AssetPath); AssetPathMapping.Add(location, packageAsset.AssetPath);
} }
} }
else else
{ {
_locationToLower = locationToLower; _locationToLower = locationToLower;
AssetPathMapping = new Dictionary<string, string>(AssetList.Count * 2); AssetPathMapping = new Dictionary<string, string>(AssetList.Count * 2);
foreach (var patchAsset in AssetList) foreach (var packageAsset in AssetList)
{ {
string location = patchAsset.AssetPath; string location = packageAsset.AssetPath;
if (locationToLower) if (locationToLower)
location = location.ToLower(); location = location.ToLower();
@ -109,7 +109,7 @@ namespace YooAsset
if (AssetPathMapping.ContainsKey(location)) if (AssetPathMapping.ContainsKey(location))
throw new Exception($"AssetPath have existed : {location}"); throw new Exception($"AssetPath have existed : {location}");
else else
AssetPathMapping.Add(location, patchAsset.AssetPath); AssetPathMapping.Add(location, packageAsset.AssetPath);
// 添加无后缀名路径的映射 // 添加无后缀名路径的映射
if (Path.HasExtension(location)) if (Path.HasExtension(location))
@ -118,7 +118,7 @@ namespace YooAsset
if (AssetPathMapping.ContainsKey(locationWithoutExtension)) if (AssetPathMapping.ContainsKey(locationWithoutExtension))
YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}"); YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
else else
AssetPathMapping.Add(locationWithoutExtension, patchAsset.AssetPath); AssetPathMapping.Add(locationWithoutExtension, packageAsset.AssetPath);
} }
} }
} }
@ -170,15 +170,15 @@ namespace YooAsset
/// 获取主资源包 /// 获取主资源包
/// 注意:传入的资源路径一定合法有效! /// 注意:传入的资源路径一定合法有效!
/// </summary> /// </summary>
public PatchBundle GetMainPatchBundle(string assetPath) public PackageBundle GetMainPackageBundle(string assetPath)
{ {
if (AssetDic.TryGetValue(assetPath, out PatchAsset patchAsset)) if (AssetDic.TryGetValue(assetPath, out PackageAsset packageAsset))
{ {
int bundleID = patchAsset.BundleID; int bundleID = packageAsset.BundleID;
if (bundleID >= 0 && bundleID < BundleList.Count) if (bundleID >= 0 && bundleID < BundleList.Count)
{ {
var patchBundle = BundleList[bundleID]; var packageBundle = BundleList[bundleID];
return patchBundle; return packageBundle;
} }
else else
{ {
@ -195,17 +195,17 @@ namespace YooAsset
/// 获取资源依赖列表 /// 获取资源依赖列表
/// 注意:传入的资源路径一定合法有效! /// 注意:传入的资源路径一定合法有效!
/// </summary> /// </summary>
public PatchBundle[] GetAllDependencies(string assetPath) public PackageBundle[] GetAllDependencies(string assetPath)
{ {
if (AssetDic.TryGetValue(assetPath, out PatchAsset patchAsset)) if (AssetDic.TryGetValue(assetPath, out PackageAsset packageAsset))
{ {
List<PatchBundle> result = new List<PatchBundle>(patchAsset.DependIDs.Length); List<PackageBundle> result = new List<PackageBundle>(packageAsset.DependIDs.Length);
foreach (var dependID in patchAsset.DependIDs) foreach (var dependID in packageAsset.DependIDs)
{ {
if (dependID >= 0 && dependID < BundleList.Count) if (dependID >= 0 && dependID < BundleList.Count)
{ {
var dependPatchBundle = BundleList[dependID]; var dependBundle = BundleList[dependID];
result.Add(dependPatchBundle); result.Add(dependBundle);
} }
else else
{ {
@ -227,8 +227,8 @@ namespace YooAsset
{ {
if (bundleID >= 0 && bundleID < BundleList.Count) if (bundleID >= 0 && bundleID < BundleList.Count)
{ {
var patchBundle = BundleList[bundleID]; var packageBundle = BundleList[bundleID];
return patchBundle.BundleName; return packageBundle.BundleName;
} }
else else
{ {
@ -237,17 +237,17 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 尝试获取补丁资源 /// 尝试获取包裹的资源
/// </summary> /// </summary>
public bool TryGetPatchAsset(string assetPath, out PatchAsset result) public bool TryGetPackageAsset(string assetPath, out PackageAsset result)
{ {
return AssetDic.TryGetValue(assetPath, out result); return AssetDic.TryGetValue(assetPath, out result);
} }
/// <summary> /// <summary>
/// 尝试获取补丁资源包 /// 尝试获取包裹的资源包
/// </summary> /// </summary>
public bool TryGetPatchBundle(string bundleName, out PatchBundle result) public bool TryGetPackageBundle(string bundleName, out PackageBundle result)
{ {
return BundleDic.TryGetValue(bundleName, out result); return BundleDic.TryGetValue(bundleName, out result);
} }
@ -257,9 +257,9 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsIncludeBundleFile(string cacheGUID) public bool IsIncludeBundleFile(string cacheGUID)
{ {
foreach (var patchBundle in BundleList) foreach (var packageBundle in BundleList)
{ {
if (patchBundle.CacheGUID == cacheGUID) if (packageBundle.CacheGUID == cacheGUID)
return true; return true;
} }
return false; return false;
@ -271,11 +271,11 @@ namespace YooAsset
public AssetInfo[] GetAssetsInfoByTags(string[] tags) public AssetInfo[] GetAssetsInfoByTags(string[] tags)
{ {
List<AssetInfo> result = new List<AssetInfo>(100); List<AssetInfo> result = new List<AssetInfo>(100);
foreach (var patchAsset in AssetList) foreach (var packageAsset in AssetList)
{ {
if (patchAsset.HasTag(tags)) if (packageAsset.HasTag(tags))
{ {
AssetInfo assetInfo = new AssetInfo(patchAsset); AssetInfo assetInfo = new AssetInfo(packageAsset);
result.Add(assetInfo); result.Add(assetInfo);
} }
} }
@ -291,9 +291,9 @@ namespace YooAsset
DebugCheckLocation(location); DebugCheckLocation(location);
string assetPath = MappingToAssetPath(location); string assetPath = MappingToAssetPath(location);
if (TryGetPatchAsset(assetPath, out PatchAsset patchAsset)) if (TryGetPackageAsset(assetPath, out PackageAsset packageAsset))
{ {
AssetInfo assetInfo = new AssetInfo(patchAsset, assetType); AssetInfo assetInfo = new AssetInfo(packageAsset, assetType);
return assetInfo; return assetInfo;
} }
else else

View File

@ -1,193 +0,0 @@
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
internal static class PatchManifestTools
{
#if UNITY_EDITOR
/// <summary>
/// 序列化JSON文件
/// </summary>
public static void SerializeToJson(string savePath, PatchManifest manifest)
{
string json = JsonUtility.ToJson(manifest, true);
FileUtility.CreateFile(savePath, json);
}
/// <summary>
/// 序列化(二进制文件)
/// </summary>
public static void SerializeToBinary(string savePath, PatchManifest patchManifest)
{
using (FileStream fs = new FileStream(savePath, FileMode.Create))
{
// 创建缓存器
BufferWriter buffer = new BufferWriter(YooAssetSettings.PatchManifestFileMaxSize);
// 写入文件标记
buffer.WriteUInt32(YooAssetSettings.PatchManifestFileSign);
// 写入文件版本
buffer.WriteUTF8(patchManifest.FileVersion);
// 写入文件头信息
buffer.WriteBool(patchManifest.EnableAddressable);
buffer.WriteInt32(patchManifest.OutputNameStyle);
buffer.WriteUTF8(patchManifest.PackageName);
buffer.WriteUTF8(patchManifest.PackageVersion);
// 写入资源列表
buffer.WriteInt32(patchManifest.AssetList.Count);
for (int i = 0; i < patchManifest.AssetList.Count; i++)
{
var patchAsset = patchManifest.AssetList[i];
buffer.WriteUTF8(patchAsset.Address);
buffer.WriteUTF8(patchAsset.AssetPath);
buffer.WriteUTF8Array(patchAsset.AssetTags);
buffer.WriteInt32(patchAsset.BundleID);
buffer.WriteInt32Array(patchAsset.DependIDs);
}
// 写入资源包列表
buffer.WriteInt32(patchManifest.BundleList.Count);
for (int i = 0; i < patchManifest.BundleList.Count; i++)
{
var patchBundle = patchManifest.BundleList[i];
buffer.WriteUTF8(patchBundle.BundleName);
buffer.WriteUTF8(patchBundle.FileHash);
buffer.WriteUTF8(patchBundle.FileCRC);
buffer.WriteInt64(patchBundle.FileSize);
buffer.WriteBool(patchBundle.IsRawFile);
buffer.WriteByte(patchBundle.LoadMethod);
buffer.WriteUTF8Array(patchBundle.Tags);
buffer.WriteInt32Array(patchBundle.ReferenceIDs);
}
// 写入文件流
buffer.WriteToStream(fs);
fs.Flush();
}
}
/// <summary>
/// 反序列化(二进制文件)
/// </summary>
public static PatchManifest DeserializeFromBinary(byte[] binaryData)
{
// 创建缓存器
BufferReader buffer = new BufferReader(binaryData);
// 读取文件标记
uint fileSign = buffer.ReadUInt32();
if (fileSign != YooAssetSettings.PatchManifestFileSign)
throw new Exception("Invalid manifest file !");
// 读取文件版本
string fileVersion = buffer.ReadUTF8();
if (fileVersion != YooAssetSettings.PatchManifestFileVersion)
throw new Exception($"The manifest file version are not compatible : {fileVersion} != {YooAssetSettings.PatchManifestFileVersion}");
PatchManifest manifest = new PatchManifest();
{
// 读取文件头信息
manifest.FileVersion = fileVersion;
manifest.EnableAddressable = buffer.ReadBool();
manifest.OutputNameStyle = buffer.ReadInt32();
manifest.PackageName = buffer.ReadUTF8();
manifest.PackageVersion = buffer.ReadUTF8();
// 读取资源列表
int patchAssetCount = buffer.ReadInt32();
manifest.AssetList = new List<PatchAsset>(patchAssetCount);
for (int i = 0; i < patchAssetCount; i++)
{
var patchAsset = new PatchAsset();
patchAsset.Address = buffer.ReadUTF8();
patchAsset.AssetPath = buffer.ReadUTF8();
patchAsset.AssetTags = buffer.ReadUTF8Array();
patchAsset.BundleID = buffer.ReadInt32();
patchAsset.DependIDs = buffer.ReadInt32Array();
manifest.AssetList.Add(patchAsset);
}
// 读取资源包列表
int patchBundleCount = buffer.ReadInt32();
manifest.BundleList = new List<PatchBundle>(patchBundleCount);
for (int i = 0; i < patchBundleCount; i++)
{
var patchBundle = new PatchBundle();
patchBundle.BundleName = buffer.ReadUTF8();
patchBundle.FileHash = buffer.ReadUTF8();
patchBundle.FileCRC = buffer.ReadUTF8();
patchBundle.FileSize = buffer.ReadInt64();
patchBundle.IsRawFile = buffer.ReadBool();
patchBundle.LoadMethod = buffer.ReadByte();
patchBundle.Tags = buffer.ReadUTF8Array();
patchBundle.ReferenceIDs = buffer.ReadInt32Array();
manifest.BundleList.Add(patchBundle);
}
}
// BundleDic
manifest.BundleDic = new Dictionary<string, PatchBundle>(manifest.BundleList.Count);
foreach (var patchBundle in manifest.BundleList)
{
patchBundle.ParseBundle(manifest.PackageName, manifest.OutputNameStyle);
manifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
}
// AssetDic
manifest.AssetDic = new Dictionary<string, PatchAsset>(manifest.AssetList.Count);
foreach (var patchAsset in manifest.AssetList)
{
// 注意:我们不允许原始路径存在重名
string assetPath = patchAsset.AssetPath;
if (manifest.AssetDic.ContainsKey(assetPath))
throw new Exception($"AssetPath have existed : {assetPath}");
else
manifest.AssetDic.Add(assetPath, patchAsset);
}
return manifest;
}
#endif
public static string GetRemoteBundleFileExtension(string bundleName)
{
string fileExtension = Path.GetExtension(bundleName);
return fileExtension;
}
public static string GetRemoteBundleFileName(int nameStyle, string bundleName, string fileExtension, string fileHash)
{
if (nameStyle == 1) //HashName
{
return StringUtility.Format("{0}{1}", fileHash, fileExtension);
}
else if (nameStyle == 4) //BundleName_HashName
{
string fileName = bundleName.Remove(bundleName.LastIndexOf('.'));
return StringUtility.Format("{0}_{1}{2}", fileName, fileHash, fileExtension);
}
else
{
throw new NotImplementedException($"Invalid name style : {nameStyle}");
}
}
/// <summary>
/// 获取解压BundleInfo
/// </summary>
public static BundleInfo GetUnpackInfo(PatchBundle patchBundle)
{
// 注意:我们把流加载路径指定为远端下载地址
string streamingPath = PathHelper.ConvertToWWWPath(patchBundle.StreamingFilePath);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming, streamingPath, streamingPath);
return bundleInfo;
}
}
}

View File

@ -8,7 +8,7 @@ namespace YooAsset
private static System.Type _classType; private static System.Type _classType;
/// <summary> /// <summary>
/// 编辑器下模拟构建补丁清单 /// 编辑器下模拟构建清单
/// </summary> /// </summary>
public static string SimulateBuild(string packageName) public static string SimulateBuild(string packageName)
{ {
@ -37,7 +37,7 @@ namespace YooAsset
public static class EditorSimulateModeHelper public static class EditorSimulateModeHelper
{ {
/// <summary> /// <summary>
/// 编辑器下模拟构建补丁清单 /// 编辑器下模拟构建清单
/// </summary> /// </summary>
public static string SimulateBuild(string packageName) { throw new System.Exception("Only support in unity editor !"); } public static string SimulateBuild(string packageName) { throw new System.Exception("Only support in unity editor !"); }
} }

View File

@ -6,22 +6,22 @@ namespace YooAsset
{ {
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
{ {
private PatchManifest _activeManifest; private PackageManifest _activeManifest;
private bool _locationToLower; private bool _locationToLower;
/// <summary> /// <summary>
/// 异步初始化 /// 异步初始化
/// </summary> /// </summary>
public InitializationOperation InitializeAsync(bool locationToLower, string simulatePatchManifestPath) public InitializationOperation InitializeAsync(bool locationToLower, string simulateManifestFilePath)
{ {
_locationToLower = locationToLower; _locationToLower = locationToLower;
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath); var operation = new EditorSimulateModeInitializationOperation(this, simulateManifestFilePath);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
#region IPlayModeServices接口 #region IPlayModeServices接口
public PatchManifest ActiveManifest public PackageManifest ActiveManifest
{ {
set set
{ {
@ -33,7 +33,7 @@ namespace YooAsset
return _activeManifest; return _activeManifest;
} }
} }
public bool IsBuildinPatchBundle(PatchBundle patchBundle) public bool IsBuildinPackageBundle(PackageBundle packageBundle)
{ {
return true; return true;
} }
@ -50,33 +50,33 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PreDownloadPackageOperation IPlayModeServices.PreDownloadPackageAsync(string packageVersion, int timeout) PreDownloadContentOperation IPlayModeServices.PreDownloadContentAsync(string packageVersion, int timeout)
{ {
var operation = new EditorPlayModePreDownloadPackageOperation(); var operation = new EditorPlayModePreDownloadContentOperation();
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
#endregion #endregion
@ -86,9 +86,9 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
return bundleInfo; return bundleInfo;
} }
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)

View File

@ -6,7 +6,7 @@ namespace YooAsset
{ {
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices, IRemoteServices internal class HostPlayModeImpl : IPlayModeServices, IBundleServices, IRemoteServices
{ {
private PatchManifest _activeManifest; private PackageManifest _activeManifest;
// 参数相关 // 参数相关
private string _packageName; private string _packageName;
@ -32,38 +32,38 @@ namespace YooAsset
} }
// 下载相关 // 下载相关
private List<BundleInfo> ConvertToDownloadList(List<PatchBundle> downloadList) private List<BundleInfo> ConvertToDownloadList(List<PackageBundle> downloadList)
{ {
List<BundleInfo> result = new List<BundleInfo>(downloadList.Count); List<BundleInfo> result = new List<BundleInfo>(downloadList.Count);
foreach (var patchBundle in downloadList) foreach (var packageBundle in downloadList)
{ {
var bundleInfo = ConvertToDownloadInfo(patchBundle); var bundleInfo = ConvertToDownloadInfo(packageBundle);
result.Add(bundleInfo); result.Add(bundleInfo);
} }
return result; return result;
} }
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle) private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
{ {
string remoteMainURL = GetRemoteMainURL(patchBundle.FileName); string remoteMainURL = GetRemoteMainURL(packageBundle.FileName);
string remoteFallbackURL = GetRemoteFallbackURL(patchBundle.FileName); string remoteFallbackURL = GetRemoteFallbackURL(packageBundle.FileName);
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
return bundleInfo; return bundleInfo;
} }
// 解压相关 // 解压相关
private List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList) private List<BundleInfo> ConvertToUnpackList(List<PackageBundle> unpackList)
{ {
List<BundleInfo> result = new List<BundleInfo>(unpackList.Count); List<BundleInfo> result = new List<BundleInfo>(unpackList.Count);
foreach (var patchBundle in unpackList) foreach (var packageBundle in unpackList)
{ {
var bundleInfo = ConvertToUnpackInfo(patchBundle); var bundleInfo = ConvertToUnpackInfo(packageBundle);
result.Add(bundleInfo); result.Add(bundleInfo);
} }
return result; return result;
} }
private BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle) private BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle)
{ {
return PatchManifestTools.GetUnpackInfo(patchBundle); return ManifestTools.GetUnpackInfo(packageBundle);
} }
#region IRemoteServices接口 #region IRemoteServices接口
@ -78,7 +78,7 @@ namespace YooAsset
#endregion #endregion
#region IPlayModeServices接口 #region IPlayModeServices接口
public PatchManifest ActiveManifest public PackageManifest ActiveManifest
{ {
set set
{ {
@ -91,13 +91,13 @@ namespace YooAsset
return _activeManifest; return _activeManifest;
} }
} }
public bool IsBuildinPatchBundle(PatchBundle patchBundle) public bool IsBuildinPackageBundle(PackageBundle packageBundle)
{ {
return _queryServices.QueryStreamingAssets(patchBundle.FileName); return _queryServices.QueryStreamingAssets(packageBundle.FileName);
} }
public bool IsCachedPatchBundle(PatchBundle patchBundle) public bool IsCachedPackageBundle(PackageBundle packageBundle)
{ {
return CacheSystem.IsCached(patchBundle.PackageName, patchBundle.CacheGUID); return CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID);
} }
UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout) UpdatePackageVersionOperation IPlayModeServices.UpdatePackageVersionAsync(bool appendTimeTicks, int timeout)
@ -112,68 +112,68 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PreDownloadPackageOperation IPlayModeServices.PreDownloadPackageAsync(string packageVersion, int timeout) PreDownloadContentOperation IPlayModeServices.PreDownloadContentAsync(string packageVersion, int timeout)
{ {
var operation = new HostPlayModePreDownloadPackageOperation(this, _packageName, packageVersion, timeout); var operation = new HostPlayModePreDownloadContentOperation(this, _packageName, packageVersion, timeout);
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByAll(_activeManifest); List<BundleInfo> downloadList = GetDownloadListByAll(_activeManifest);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public List<BundleInfo> GetDownloadListByAll(PatchManifest patchManifest) public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var patchBundle in patchManifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByTags(_activeManifest, tags); List<BundleInfo> downloadList = GetDownloadListByTags(_activeManifest, tags);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public List<BundleInfo> GetDownloadListByTags(PatchManifest patchManifest, string[] tags) public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var patchBundle in patchManifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;
// 如果未带任何标记,则统一下载 // 如果未带任何标记,则统一下载
if (patchBundle.HasAnyTags() == false) if (packageBundle.HasAnyTags() == false)
{ {
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
else else
{ {
// 查询DLC资源 // 查询DLC资源
if (patchBundle.HasTag(tags)) if (packageBundle.HasTag(tags))
{ {
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
} }
} }
@ -181,16 +181,16 @@ namespace YooAsset
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> downloadList = GetDownloadListByPaths(_activeManifest, assetInfos); List<BundleInfo> downloadList = GetDownloadListByPaths(_activeManifest, assetInfos);
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
public List<BundleInfo> GetDownloadListByPaths(PatchManifest patchManifest, AssetInfo[] assetInfos) public List<BundleInfo> GetDownloadListByPaths(PackageManifest manifest, AssetInfo[] assetInfos)
{ {
// 获取资源对象的资源包和所有依赖资源包 // 获取资源对象的资源包和所有依赖资源包
List<PatchBundle> checkList = new List<PatchBundle>(); List<PackageBundle> checkList = new List<PackageBundle>();
foreach (var assetInfo in assetInfos) foreach (var assetInfo in assetInfos)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
@ -199,13 +199,13 @@ namespace YooAsset
continue; continue;
} }
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
PatchBundle mainBundle = patchManifest.GetMainPatchBundle(assetInfo.AssetPath); PackageBundle mainBundle = manifest.GetMainPackageBundle(assetInfo.AssetPath);
if (checkList.Contains(mainBundle) == false) if (checkList.Contains(mainBundle) == false)
checkList.Add(mainBundle); checkList.Add(mainBundle);
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
PatchBundle[] dependBundles = patchManifest.GetAllDependencies(assetInfo.AssetPath); PackageBundle[] dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
foreach (var dependBundle in dependBundles) foreach (var dependBundle in dependBundles)
{ {
if (checkList.Contains(dependBundle) == false) if (checkList.Contains(dependBundle) == false)
@ -213,68 +213,68 @@ namespace YooAsset
} }
} }
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var patchBundle in checkList) foreach (var packageBundle in checkList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
continue; continue;
// 忽略APP资源 // 忽略APP资源
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
continue; continue;
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
return ConvertToDownloadList(downloadList); return ConvertToDownloadList(downloadList);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> unpcakList = GetUnpackListByAll(_activeManifest); List<BundleInfo> unpcakList = GetUnpackListByAll(_activeManifest);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout); var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetUnpackListByAll(PatchManifest patchManifest) private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var patchBundle in patchManifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
continue; continue;
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
{ {
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
} }
return ConvertToUnpackList(downloadList); return ConvertToUnpackList(downloadList);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
List<BundleInfo> unpcakList = GetUnpackListByTags(_activeManifest, tags); List<BundleInfo> unpcakList = GetUnpackListByTags(_activeManifest, tags);
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout); var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
return operation; return operation;
} }
private List<BundleInfo> GetUnpackListByTags(PatchManifest patchManifest, string[] tags) private List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
{ {
List<PatchBundle> downloadList = new List<PatchBundle>(1000); List<PackageBundle> downloadList = new List<PackageBundle>(1000);
foreach (var patchBundle in patchManifest.BundleList) foreach (var packageBundle in manifest.BundleList)
{ {
// 忽略缓存文件 // 忽略缓存文件
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
continue; continue;
// 查询DLC资源 // 查询DLC资源
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
{ {
if (patchBundle.HasTag(tags)) if (packageBundle.HasTag(tags))
{ {
downloadList.Add(patchBundle); downloadList.Add(packageBundle);
} }
} }
} }
@ -284,48 +284,48 @@ namespace YooAsset
#endregion #endregion
#region IBundleServices接口 #region IBundleServices接口
private BundleInfo CreateBundleInfo(PatchBundle patchBundle) private BundleInfo CreateBundleInfo(PackageBundle packageBundle)
{ {
if (patchBundle == null) if (packageBundle == null)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 查询沙盒资源 // 查询沙盒资源
if (IsCachedPatchBundle(patchBundle)) if (IsCachedPackageBundle(packageBundle))
{ {
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromCache);
return bundleInfo; return bundleInfo;
} }
// 查询APP资源 // 查询APP资源
if (IsBuildinPatchBundle(patchBundle)) if (IsBuildinPackageBundle(packageBundle))
{ {
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming);
return bundleInfo; return bundleInfo;
} }
// 从服务端下载 // 从服务端下载
return ConvertToDownloadInfo(patchBundle); return ConvertToDownloadInfo(packageBundle);
} }
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo) BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(patchBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath); var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
List<BundleInfo> result = new List<BundleInfo>(depends.Length); List<BundleInfo> result = new List<BundleInfo>(depends.Length);
foreach (var patchBundle in depends) foreach (var packageBundle in depends)
{ {
BundleInfo bundleInfo = CreateBundleInfo(patchBundle); BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
result.Add(bundleInfo); result.Add(bundleInfo);
} }
return result.ToArray(); return result.ToArray();

View File

@ -6,7 +6,7 @@ namespace YooAsset
{ {
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
{ {
private PatchManifest _activeManifest; private PackageManifest _activeManifest;
private bool _locationToLower; private bool _locationToLower;
/// <summary> /// <summary>
@ -21,7 +21,7 @@ namespace YooAsset
} }
#region IPlayModeServices接口 #region IPlayModeServices接口
public PatchManifest ActiveManifest public PackageManifest ActiveManifest
{ {
set set
{ {
@ -33,7 +33,7 @@ namespace YooAsset
return _activeManifest; return _activeManifest;
} }
} }
public bool IsBuildinPatchBundle(PatchBundle patchBundle) public bool IsBuildinPackageBundle(PackageBundle packageBundle)
{ {
return true; return true;
} }
@ -50,52 +50,52 @@ namespace YooAsset
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PreDownloadPackageOperation IPlayModeServices.PreDownloadPackageAsync(string packageVersion, int timeout) PreDownloadContentOperation IPlayModeServices.PreDownloadContentAsync(string packageVersion, int timeout)
{ {
var operation = new OfflinePlayModePreDownloadPackageOperation(); var operation = new OfflinePlayModePreDownloadContentOperation();
OperationSystem.StartOperation(operation); OperationSystem.StartOperation(operation);
return operation; return operation;
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchDownloaderOperation IPlayModeServices.CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayModeServices.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
PatchUnpackerOperation IPlayModeServices.CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayModeServices.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout)
{ {
return PatchUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout); return ResourceUnpackerOperation.CreateEmptyUnpacker(upackingMaxNumber, failedTryAgain, timeout);
} }
#endregion #endregion
#region IBundleServices接口 #region IBundleServices接口
private BundleInfo CreateBundleInfo(PatchBundle patchBundle) private BundleInfo CreateBundleInfo(PackageBundle packageBundle)
{ {
if (patchBundle == null) if (packageBundle == null)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 查询沙盒资源 // 查询沙盒资源
if (CacheSystem.IsCached(patchBundle.PackageName, patchBundle.CacheGUID)) if (CacheSystem.IsCached(packageBundle.PackageName, packageBundle.CacheGUID))
{ {
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromCache);
return bundleInfo; return bundleInfo;
} }
// 查询APP资源 // 查询APP资源
{ {
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming); BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming);
return bundleInfo; return bundleInfo;
} }
} }
@ -104,21 +104,21 @@ namespace YooAsset
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath); var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
return CreateBundleInfo(patchBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo) BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果补丁清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath); var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
List<BundleInfo> result = new List<BundleInfo>(depends.Length); List<BundleInfo> result = new List<BundleInfo>(depends.Length);
foreach (var patchBundle in depends) foreach (var packageBundle in depends)
{ {
BundleInfo bundleInfo = CreateBundleInfo(patchBundle); BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
result.Add(bundleInfo); result.Add(bundleInfo);
} }
return result.ToArray(); return result.ToArray();

View File

@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
namespace YooAsset namespace YooAsset
{ {
public class AssetsPackage public class ResourcePackage
{ {
private bool _isInitialize = false; private bool _isInitialize = false;
private string _initializeError = string.Empty; private string _initializeError = string.Empty;
@ -30,10 +30,10 @@ namespace YooAsset
} }
private AssetsPackage() private ResourcePackage()
{ {
} }
internal AssetsPackage(string packageName) internal ResourcePackage(string packageName)
{ {
PackageName = packageName; PackageName = packageName;
} }
@ -90,7 +90,7 @@ namespace YooAsset
_assetSystemImpl.Initialize(PackageName, true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices); _assetSystemImpl.Initialize(PackageName, true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
var initializeParameters = parameters as EditorSimulateModeParameters; var initializeParameters = parameters as EditorSimulateModeParameters;
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulatePatchManifestPath); initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulateManifestFilePath);
} }
else if (_playMode == EPlayMode.OfflinePlayMode) else if (_playMode == EPlayMode.OfflinePlayMode)
{ {
@ -143,10 +143,10 @@ namespace YooAsset
private void CheckInitializeParameters(InitializeParameters parameters) private void CheckInitializeParameters(InitializeParameters parameters)
{ {
if (_isInitialize) if (_isInitialize)
throw new Exception($"{nameof(AssetsPackage)} is initialized yet."); throw new Exception($"{nameof(ResourcePackage)} is initialized yet.");
if (parameters == null) if (parameters == null)
throw new Exception($"{nameof(AssetsPackage)} create parameters is null."); throw new Exception($"{nameof(ResourcePackage)} create parameters is null.");
#if !UNITY_EDITOR #if !UNITY_EDITOR
if (parameters is EditorSimulateModeParameters) if (parameters is EditorSimulateModeParameters)
@ -156,8 +156,8 @@ namespace YooAsset
if (parameters is EditorSimulateModeParameters) if (parameters is EditorSimulateModeParameters)
{ {
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters; var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath)) if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulateManifestFilePath))
throw new Exception($"{nameof(editorSimulateModeParameters.SimulatePatchManifestPath)} is null or empty."); throw new Exception($"{nameof(editorSimulateModeParameters.SimulateManifestFilePath)} is null or empty.");
} }
if (parameters is HostPlayModeParameters) if (parameters is HostPlayModeParameters)
@ -206,7 +206,7 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 向网络端请求并更新补丁清单 /// 向网络端请求并更新清单
/// </summary> /// </summary>
/// <param name="packageVersion">更新的包裹版本</param> /// <param name="packageVersion">更新的包裹版本</param>
/// <param name="autoActiveManifest">自动激活清单</param> /// <param name="autoActiveManifest">自动激活清单</param>
@ -223,10 +223,10 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="packageVersion">下载的包裹版本</param> /// <param name="packageVersion">下载的包裹版本</param>
/// <param name="timeout">超时时间默认值60秒</param> /// <param name="timeout">超时时间默认值60秒</param>
public PreDownloadPackageOperation PreDownloadPackageAsync(string packageVersion, int timeout = 60) public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.PreDownloadPackageAsync(packageVersion, timeout); return _playModeServices.PreDownloadContentAsync(packageVersion, timeout);
} }
/// <summary> /// <summary>
@ -630,91 +630,139 @@ namespace YooAsset
#region 资源下载 #region 资源下载
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载当前资源版本所有的资源包文件
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
return _playModeServices.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
/// </summary> /// </summary>
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout); return _playModeServices.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
/// </summary> /// </summary>
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout); return _playModeServices.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件 /// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary> /// </summary>
/// <param name="location">资源的定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout); var assetInfo = ConvertLocationToAssetInfo(location, null);
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeServices.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件 /// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源的定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
foreach (var location in locations)
{
var assetInfo = ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo);
}
return _playModeServices.CreateResourceDownloaderByPaths(assetInfos.ToArray(), downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="assetInfo">资源信息</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{
DebugCheckInitialize();
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeServices.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary> /// </summary>
/// <param name="assetInfos">资源信息列表</param> /// <param name="assetInfos">资源信息列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> /// <param name="timeout">超时时间</param>
public PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout); return _playModeServices.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
} }
#endregion #endregion
#region 资源解压 #region 资源解压
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeServices.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
} }
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeServices.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
} }
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeServices.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeServices.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
} }
#endregion #endregion

View File

@ -6,12 +6,12 @@ namespace YooAsset
/// <summary> /// <summary>
/// 激活的清单 /// 激活的清单
/// </summary> /// </summary>
PatchManifest ActiveManifest { set; get; } PackageManifest ActiveManifest { set; get; }
/// <summary> /// <summary>
/// 是否为内置资源文件 /// 是否为内置资源文件
/// </summary> /// </summary>
bool IsBuildinPatchBundle(PatchBundle patchBundle); bool IsBuildinPackageBundle(PackageBundle packageBundle);
/// <summary> /// <summary>
/// 向网络端请求最新的资源版本 /// 向网络端请求最新的资源版本
@ -19,22 +19,22 @@ namespace YooAsset
UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks, int timeout); UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks, int timeout);
/// <summary> /// <summary>
/// 向网络端请求并更新补丁清单 /// 向网络端请求并更新清单
/// </summary> /// </summary>
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout); UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout);
/// <summary> /// <summary>
/// 预下载指定版本的包裹资源 /// 预下载指定版本的包裹内容
/// </summary> /// </summary>
PreDownloadPackageOperation PreDownloadPackageAsync(string packageVersion, int timeout); PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout);
// 下载相关 // 下载相关
PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
// 解压相关 // 解压相关
PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout); ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout); ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
} }
} }

View File

@ -8,23 +8,23 @@ namespace YooAsset
/// <summary> /// <summary>
/// 清单文件名称 /// 清单文件名称
/// </summary> /// </summary>
public string PatchManifestFileName = "PatchManifest"; public string ManifestFileName = "PackageManifest";
/// <summary> /// <summary>
/// 清单文件头标记 /// 清单文件头标记
/// </summary> /// </summary>
public const uint PatchManifestFileSign = 0x594F4F; public const uint ManifestFileSign = 0x594F4F;
/// <summary> /// <summary>
/// 清单文件极限大小100MB /// 清单文件极限大小100MB
/// </summary> /// </summary>
public const int PatchManifestFileMaxSize = 104857600; public const int ManifestFileMaxSize = 104857600;
/// <summary> /// <summary>
/// 清单文件格式版本 /// 清单文件格式版本
/// </summary> /// </summary>
public const string PatchManifestFileVersion = "1.4.6"; public const string ManifestFileVersion = "1.4.6";
/// <summary> /// <summary>

View File

@ -45,7 +45,7 @@ namespace YooAsset
/// </summary> /// </summary>
public static string GetManifestBinaryFileName(string packageName, string packageVersion) public static string GetManifestBinaryFileName(string packageName, string packageVersion)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.bytes"; return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.bytes";
} }
/// <summary> /// <summary>
@ -53,7 +53,7 @@ namespace YooAsset
/// </summary> /// </summary>
public static string GetManifestJsonFileName(string packageName, string packageVersion) public static string GetManifestJsonFileName(string packageName, string packageVersion)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.json"; return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.json";
} }
/// <summary> /// <summary>
@ -61,7 +61,7 @@ namespace YooAsset
/// </summary> /// </summary>
public static string GetPackageHashFileName(string packageName, string packageVersion) public static string GetPackageHashFileName(string packageName, string packageVersion)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.hash"; return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.hash";
} }
/// <summary> /// <summary>
@ -69,7 +69,7 @@ namespace YooAsset
/// </summary> /// </summary>
public static string GetPackageVersionFileName(string packageName) public static string GetPackageVersionFileName(string packageName)
{ {
return $"{Setting.PatchManifestFileName}_{packageName}.version"; return $"{Setting.ManifestFileName}_{packageName}.version";
} }
} }
} }

View File

@ -10,7 +10,7 @@ namespace YooAsset
{ {
private static bool _isInitialize = false; private static bool _isInitialize = false;
private static GameObject _driver = null; private static GameObject _driver = null;
private static readonly List<AssetsPackage> _packages = new List<AssetsPackage>(); private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
/// <summary> /// <summary>
/// 初始化资源系统 /// 初始化资源系统
@ -88,7 +88,7 @@ namespace YooAsset
/// 创建资源包 /// 创建资源包
/// </summary> /// </summary>
/// <param name="packageName">资源包名称</param> /// <param name="packageName">资源包名称</param>
public static AssetsPackage CreateAssetsPackage(string packageName) public static ResourcePackage CreatePackage(string packageName)
{ {
if (_isInitialize == false) if (_isInitialize == false)
throw new Exception($"{nameof(YooAssets)} not initialize !"); throw new Exception($"{nameof(YooAssets)} not initialize !");
@ -96,23 +96,23 @@ namespace YooAsset
if (string.IsNullOrEmpty(packageName)) if (string.IsNullOrEmpty(packageName))
throw new Exception("Package name is null or empty !"); throw new Exception("Package name is null or empty !");
if (HasAssetsPackage(packageName)) if (HasPackage(packageName))
throw new Exception($"Package {packageName} already existed !"); throw new Exception($"Package {packageName} already existed !");
AssetsPackage assetsPackage = new AssetsPackage(packageName); ResourcePackage package = new ResourcePackage(packageName);
_packages.Add(assetsPackage); _packages.Add(package);
return assetsPackage; return package;
} }
/// <summary> /// <summary>
/// 获取资源包 /// 获取资源包
/// </summary> /// </summary>
/// <param name="packageName">资源包名称</param> /// <param name="packageName">资源包名称</param>
public static AssetsPackage GetAssetsPackage(string packageName) public static ResourcePackage GetPackage(string packageName)
{ {
var package = TryGetAssetsPackage(packageName); var package = TryGetPackage(packageName);
if (package == null) if (package == null)
YooLogger.Warning($"Not found assets package : {packageName}"); YooLogger.Error($"Not found assets package : {packageName}");
return package; return package;
} }
@ -120,7 +120,7 @@ namespace YooAsset
/// 尝试获取资源包 /// 尝试获取资源包
/// </summary> /// </summary>
/// <param name="packageName">资源包名称</param> /// <param name="packageName">资源包名称</param>
public static AssetsPackage TryGetAssetsPackage(string packageName) public static ResourcePackage TryGetPackage(string packageName)
{ {
if (_isInitialize == false) if (_isInitialize == false)
throw new Exception($"{nameof(YooAssets)} not initialize !"); throw new Exception($"{nameof(YooAssets)} not initialize !");
@ -140,7 +140,7 @@ namespace YooAsset
/// 检测资源包是否存在 /// 检测资源包是否存在
/// </summary> /// </summary>
/// <param name="packageName">资源包名称</param> /// <param name="packageName">资源包名称</param>
public static bool HasAssetsPackage(string packageName) public static bool HasPackage(string packageName)
{ {
if (_isInitialize == false) if (_isInitialize == false)
throw new Exception($"{nameof(YooAssets)} not initialize !"); throw new Exception($"{nameof(YooAssets)} not initialize !");

View File

@ -8,14 +8,14 @@ namespace YooAsset
{ {
public static partial class YooAssets public static partial class YooAssets
{ {
private static AssetsPackage _defaultPackage; private static ResourcePackage _defaultPackage;
/// <summary> /// <summary>
/// 设置默认的资源包 /// 设置默认的资源包
/// </summary> /// </summary>
public static void SetDefaultAssetsPackage(AssetsPackage assetsPackage) public static void SetDefaultPackage(ResourcePackage package)
{ {
_defaultPackage = assetsPackage; _defaultPackage = package;
} }
#region 资源信息 #region 资源信息
@ -286,47 +286,83 @@ namespace YooAsset
#region 资源下载 #region 资源下载
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载当前资源版本所有的资源包文件
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
public static ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.CreateResourceDownloader(downloadingMaxNumber, failedTryAgain);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
/// </summary> /// </summary>
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
public static PatchDownloaderOperation CreatePatchDownloader(string tag, int downloadingMaxNumber, int failedTryAgain) public static ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain); return _defaultPackage.CreateResourceDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件 /// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
/// </summary> /// </summary>
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
public static PatchDownloaderOperation CreatePatchDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain) public static ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchDownloader(tags, downloadingMaxNumber, failedTryAgain); return _defaultPackage.CreateResourceDownloader(tags, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件 /// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary> /// </summary>
/// <param name="location">资源定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain) public static ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain); return _defaultPackage.CreateBundleDownloader(location, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
/// 创建补丁下载器,用于下载更新指定的资源列表依赖的资源包文件 /// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary>
/// <param name="locations">资源定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
public static ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.CreateBundleDownloader(locations, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
/// </summary>
/// <param name="assetInfo">资源信息</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
public static ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain)
{
DebugCheckDefaultPackageValid();
return _defaultPackage.CreateBundleDownloader(assetInfo, downloadingMaxNumber, failedTryAgain);
}
/// <summary>
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
/// </summary> /// </summary>
/// <param name="assetInfos">资源信息列表</param> /// <param name="assetInfos">资源信息列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
public static PatchDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain) public static ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain); return _defaultPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain);
@ -335,38 +371,38 @@ namespace YooAsset
#region 资源解压 #region 资源解压
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public static PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain) public static ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchUnpacker(tag, unpackingMaxNumber, failedTryAgain); return _defaultPackage.CreateResourceUnpacker(tag, unpackingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public static PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain) public static ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchUnpacker(tags, unpackingMaxNumber, failedTryAgain); return _defaultPackage.CreateResourceUnpacker(tags, unpackingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
/// 创建补丁解压器 /// 创建内置资源解压器
/// </summary> /// </summary>
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param> /// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
/// <param name="failedTryAgain">解压失败的重试次数</param> /// <param name="failedTryAgain">解压失败的重试次数</param>
public static PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain) public static ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckDefaultPackageValid(); DebugCheckDefaultPackageValid();
return _defaultPackage.CreatePatchUnpacker(unpackingMaxNumber, failedTryAgain); return _defaultPackage.CreateResourceUnpacker(unpackingMaxNumber, failedTryAgain);
} }
#endregion #endregion
@ -375,7 +411,7 @@ namespace YooAsset
private static void DebugCheckDefaultPackageValid() private static void DebugCheckDefaultPackageValid()
{ {
if (_defaultPackage == null) if (_defaultPackage == null)
throw new Exception($"Default package is null. Please use {nameof(YooAssets.SetDefaultAssetsPackage)} !"); throw new Exception($"Default package is null. Please use {nameof(YooAssets.SetDefaultPackage)} !");
} }
#endregion #endregion
} }