mirror of https://github.com/tuyoogame/YooAsset
parent
10e04c7645
commit
67d09d95fa
|
@ -1,8 +1,8 @@
|
|||
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class AssetReference
|
||||
{
|
||||
|
||||
}
|
||||
}
|
|
@ -110,7 +110,7 @@ namespace YooAsset
|
|||
if (_steps == ESteps.Unpack)
|
||||
{
|
||||
int failedTryAgain = 1;
|
||||
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||
_steps = ESteps.CheckUnpack;
|
||||
}
|
||||
|
|
|
@ -92,7 +92,7 @@ namespace YooAsset
|
|||
if (_steps == ESteps.Unpack)
|
||||
{
|
||||
int failedTryAgain = 1;
|
||||
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
_unpacker = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||
_steps = ESteps.CheckUnpack;
|
||||
}
|
||||
|
|
|
@ -90,7 +90,7 @@ namespace YooAsset
|
|||
if (_steps == ESteps.Website)
|
||||
{
|
||||
int failedTryAgain = 1;
|
||||
var bundleInfo = PatchManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
var bundleInfo = ManifestTools.GetUnpackInfo(MainBundleInfo.Bundle);
|
||||
_website = DownloadSystem.BeginDownload(bundleInfo, failedTryAgain);
|
||||
_steps = ESteps.CheckWebsite;
|
||||
}
|
||||
|
|
|
@ -133,7 +133,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 获取未被使用的缓存文件
|
||||
/// </summary>
|
||||
public static List<string> GetUnusedCacheGUIDs(AssetsPackage package)
|
||||
public static List<string> GetUnusedCacheGUIDs(ResourcePackage package)
|
||||
{
|
||||
var cache = GetOrCreateCache(package.PackageName);
|
||||
var keys = cache.GetAllKeys();
|
||||
|
|
|
@ -17,12 +17,12 @@ namespace YooAsset
|
|||
Done,
|
||||
}
|
||||
|
||||
private readonly AssetsPackage _package;
|
||||
private readonly ResourcePackage _package;
|
||||
private List<string> _unusedCacheGUIDs;
|
||||
private int _unusedFileTotalCount = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal ClearUnusedCacheFilesOperation(AssetsPackage package)
|
||||
internal ClearUnusedCacheFilesOperation(ResourcePackage package)
|
||||
{
|
||||
_package = package;
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 用于模拟运行的资源清单路径
|
||||
/// </summary>
|
||||
public string SimulatePatchManifestPath = string.Empty;
|
||||
public string SimulateManifestFilePath = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -3,7 +3,7 @@ namespace YooAsset
|
|||
{
|
||||
public class AssetInfo
|
||||
{
|
||||
private readonly PatchAsset _patchAsset;
|
||||
private readonly PackageAsset _packageAsset;
|
||||
private string _providerGUID;
|
||||
|
||||
/// <summary>
|
||||
|
@ -42,7 +42,7 @@ namespace YooAsset
|
|||
{
|
||||
get
|
||||
{
|
||||
return _patchAsset == null;
|
||||
return _packageAsset == null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,9 +53,9 @@ namespace YooAsset
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_patchAsset == null)
|
||||
if (_packageAsset == null)
|
||||
return string.Empty;
|
||||
return _patchAsset.Address;
|
||||
return _packageAsset.Address;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -66,9 +66,9 @@ namespace YooAsset
|
|||
{
|
||||
get
|
||||
{
|
||||
if (_patchAsset == null)
|
||||
if (_packageAsset == null)
|
||||
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 !");
|
||||
|
||||
_providerGUID = string.Empty;
|
||||
_patchAsset = patchAsset;
|
||||
_packageAsset = packageAsset;
|
||||
AssetType = assetType;
|
||||
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 !");
|
||||
|
||||
_providerGUID = string.Empty;
|
||||
_patchAsset = patchAsset;
|
||||
_packageAsset = packageAsset;
|
||||
AssetType = null;
|
||||
Error = string.Empty;
|
||||
}
|
||||
internal AssetInfo(string error)
|
||||
{
|
||||
_providerGUID = string.Empty;
|
||||
_patchAsset = null;
|
||||
_packageAsset = null;
|
||||
AssetType = null;
|
||||
Error = error;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace YooAsset
|
|||
LoadFromEditor,
|
||||
}
|
||||
|
||||
public readonly PatchBundle Bundle;
|
||||
public readonly PackageBundle Bundle;
|
||||
public readonly ELoadMode LoadMode;
|
||||
|
||||
/// <summary>
|
||||
|
@ -34,25 +34,25 @@ namespace YooAsset
|
|||
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;
|
||||
RemoteMainURL = mainURL;
|
||||
RemoteFallbackURL = fallbackURL;
|
||||
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;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
EditorAssetPath = editorAssetPath;
|
||||
}
|
||||
public BundleInfo(PatchBundle patchBundle, ELoadMode loadMode)
|
||||
public BundleInfo(PackageBundle bundle, ELoadMode loadMode)
|
||||
{
|
||||
Bundle = patchBundle;
|
||||
Bundle = bundle;
|
||||
LoadMode = loadMode;
|
||||
RemoteMainURL = string.Empty;
|
||||
RemoteFallbackURL = string.Empty;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -94,9 +94,9 @@ namespace YooAsset
|
|||
if (downloadList != null)
|
||||
{
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
@ -259,16 +259,16 @@ namespace YooAsset
|
|||
/// <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>();
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
@ -276,10 +276,10 @@ namespace YooAsset
|
|||
/// <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>();
|
||||
var operation = new PatchUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
var operation = new ResourceUnpackerOperation(downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,14 +26,14 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
private readonly EditorSimulateModeImpl _impl;
|
||||
private readonly string _simulateManifestPath;
|
||||
private readonly string _simulateManifestFilePath;
|
||||
private LoadEditorManifestOperation _loadEditorManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestPath)
|
||||
internal EditorSimulateModeInitializationOperation(EditorSimulateModeImpl impl, string simulateManifestFilePath)
|
||||
{
|
||||
_impl = impl;
|
||||
_simulateManifestPath = simulateManifestPath;
|
||||
_simulateManifestFilePath = simulateManifestFilePath;
|
||||
}
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ namespace YooAsset
|
|||
{
|
||||
if (_loadEditorManifestOp == null)
|
||||
{
|
||||
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestPath);
|
||||
_loadEditorManifestOp = new LoadEditorManifestOperation(_simulateManifestFilePath);
|
||||
OperationSystem.StartOperation(_loadEditorManifestOp);
|
||||
}
|
||||
|
||||
|
|
|
@ -18,15 +18,15 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
private readonly BufferReader _buffer;
|
||||
private int _patchAssetCount;
|
||||
private int _patchBundleCount;
|
||||
private int _packageAssetCount;
|
||||
private int _packageBundleCount;
|
||||
private int _progressTotalValue;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
/// <summary>
|
||||
/// 解析的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
public DeserializeManifestOperation(byte[] binaryData)
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ namespace YooAsset
|
|||
|
||||
// 读取文件标记
|
||||
uint fileSign = _buffer.ReadUInt32();
|
||||
if (fileSign != YooAssetSettings.PatchManifestFileSign)
|
||||
if (fileSign != YooAssetSettings.ManifestFileSign)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
|
@ -65,16 +65,16 @@ namespace YooAsset
|
|||
|
||||
// 读取文件版本
|
||||
string fileVersion = _buffer.ReadUTF8();
|
||||
if (fileVersion != YooAssetSettings.PatchManifestFileVersion)
|
||||
if (fileVersion != YooAssetSettings.ManifestFileVersion)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
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;
|
||||
}
|
||||
|
||||
// 读取文件头信息
|
||||
Manifest = new PatchManifest();
|
||||
Manifest = new PackageManifest();
|
||||
Manifest.FileVersion = fileVersion;
|
||||
Manifest.EnableAddressable = _buffer.ReadBool();
|
||||
Manifest.OutputNameStyle = _buffer.ReadInt32();
|
||||
|
@ -86,38 +86,38 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.PrepareAssetList)
|
||||
{
|
||||
_patchAssetCount = _buffer.ReadInt32();
|
||||
Manifest.AssetList = new List<PatchAsset>(_patchAssetCount);
|
||||
Manifest.AssetDic = new Dictionary<string, PatchAsset>(_patchAssetCount);
|
||||
_progressTotalValue = _patchAssetCount;
|
||||
_packageAssetCount = _buffer.ReadInt32();
|
||||
Manifest.AssetList = new List<PackageAsset>(_packageAssetCount);
|
||||
Manifest.AssetDic = new Dictionary<string, PackageAsset>(_packageAssetCount);
|
||||
_progressTotalValue = _packageAssetCount;
|
||||
_steps = ESteps.DeserializeAssetList;
|
||||
}
|
||||
if (_steps == ESteps.DeserializeAssetList)
|
||||
{
|
||||
while (_patchAssetCount > 0)
|
||||
while (_packageAssetCount > 0)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
// 注意:我们不允许原始路径存在重名
|
||||
string assetPath = patchAsset.AssetPath;
|
||||
string assetPath = packageAsset.AssetPath;
|
||||
if (Manifest.AssetDic.ContainsKey(assetPath))
|
||||
throw new System.Exception($"AssetPath have existed : {assetPath}");
|
||||
else
|
||||
Manifest.AssetDic.Add(assetPath, patchAsset);
|
||||
Manifest.AssetDic.Add(assetPath, packageAsset);
|
||||
|
||||
_patchAssetCount--;
|
||||
Progress = 1f - _patchAssetCount / _progressTotalValue;
|
||||
_packageAssetCount--;
|
||||
Progress = 1f - _packageAssetCount / _progressTotalValue;
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_patchAssetCount <= 0)
|
||||
if (_packageAssetCount <= 0)
|
||||
{
|
||||
_steps = ESteps.PrepareBundleList;
|
||||
}
|
||||
|
@ -125,37 +125,37 @@ namespace YooAsset
|
|||
|
||||
if (_steps == ESteps.PrepareBundleList)
|
||||
{
|
||||
_patchBundleCount = _buffer.ReadInt32();
|
||||
Manifest.BundleList = new List<PatchBundle>(_patchBundleCount);
|
||||
Manifest.BundleDic = new Dictionary<string, PatchBundle>(_patchBundleCount);
|
||||
_progressTotalValue = _patchBundleCount;
|
||||
_packageBundleCount = _buffer.ReadInt32();
|
||||
Manifest.BundleList = new List<PackageBundle>(_packageBundleCount);
|
||||
Manifest.BundleDic = new Dictionary<string, PackageBundle>(_packageBundleCount);
|
||||
_progressTotalValue = _packageBundleCount;
|
||||
_steps = ESteps.DeserializeBundleList;
|
||||
}
|
||||
if (_steps == ESteps.DeserializeBundleList)
|
||||
{
|
||||
while (_patchBundleCount > 0)
|
||||
while (_packageBundleCount > 0)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
|
||||
patchBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
||||
Manifest.BundleDic.Add(patchBundle.BundleName, patchBundle);
|
||||
packageBundle.ParseBundle(Manifest.PackageName, Manifest.OutputNameStyle);
|
||||
Manifest.BundleDic.Add(packageBundle.BundleName, packageBundle);
|
||||
|
||||
_patchBundleCount--;
|
||||
Progress = 1f - _patchBundleCount / _progressTotalValue;
|
||||
_packageBundleCount--;
|
||||
Progress = 1f - _packageBundleCount / _progressTotalValue;
|
||||
if (OperationSystem.IsBusy)
|
||||
break;
|
||||
}
|
||||
|
||||
if (_patchBundleCount <= 0)
|
||||
if (_packageBundleCount <= 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
|
|
|
@ -20,7 +20,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public LoadBuildinManifestOperation(string buildinPackageName, string buildinPackageVersion)
|
||||
|
|
|
@ -24,7 +24,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public LoadCacheManifestOperation(string packageName, string packageVersion)
|
||||
|
|
|
@ -19,7 +19,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 加载的清单实例
|
||||
/// </summary>
|
||||
public PatchManifest Manifest { private set; get; }
|
||||
public PackageManifest Manifest { private set; get; }
|
||||
|
||||
|
||||
public LoadEditorManifestOperation(string manifestFilePath)
|
||||
|
|
|
@ -4,57 +4,69 @@ using System.Collections.Generic;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class PreDownloadPackageOperation : AsyncOperationBase
|
||||
public abstract class PreDownloadContentOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新指定资源版本所有的资源包文件
|
||||
/// 创建资源下载器,用于下载当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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>
|
||||
/// <param name="locations">资源定位列表</param>
|
||||
/// <param name="location">资源定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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()
|
||||
{
|
||||
|
@ -64,7 +76,7 @@ namespace YooAsset
|
|||
{
|
||||
}
|
||||
}
|
||||
public class OfflinePlayModePreDownloadPackageOperation : PreDownloadPackageOperation
|
||||
internal class OfflinePlayModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
{
|
||||
internal override void Start()
|
||||
{
|
||||
|
@ -74,7 +86,7 @@ namespace YooAsset
|
|||
{
|
||||
}
|
||||
}
|
||||
public class HostPlayModePreDownloadPackageOperation : PreDownloadPackageOperation
|
||||
internal class HostPlayModePreDownloadContentOperation : PreDownloadContentOperation
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
|
@ -94,11 +106,11 @@ namespace YooAsset
|
|||
private LoadCacheManifestOperation _tryLoadCacheManifestOp;
|
||||
private LoadCacheManifestOperation _loadCacheManifestOp;
|
||||
private DownloadManifestOperation _downloadManifestOp;
|
||||
private PatchManifest _manifest;
|
||||
private PackageManifest _manifest;
|
||||
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;
|
||||
_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)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
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)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadPackageOperation)} status is not succeed !");
|
||||
return PatchDownloaderOperation.CreateEmptyDownloader(downloadingMaxNumber, failedTryAgain, timeout);
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
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);
|
||||
|
@ -254,7 +282,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 向远端请求并更新补丁清单
|
||||
/// 向远端请求并更新清单
|
||||
/// </summary>
|
||||
public abstract class UpdatePackageManifestOperation : AsyncOperationBase
|
||||
{
|
||||
|
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
namespace YooAsset
|
||||
{
|
||||
[Serializable]
|
||||
internal class PatchAsset
|
||||
internal class PackageAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 可寻址地址
|
|
@ -4,7 +4,7 @@ using System.Linq;
|
|||
namespace YooAsset
|
||||
{
|
||||
[Serializable]
|
||||
internal class PatchBundle
|
||||
internal class PackageBundle
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
|
@ -173,7 +173,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
|
||||
public PatchBundle()
|
||||
public PackageBundle()
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -183,8 +183,8 @@ namespace YooAsset
|
|||
public void ParseBundle(string packageName, int nameStype)
|
||||
{
|
||||
PackageName = packageName;
|
||||
_fileExtension = PatchManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||
_fileName = PatchManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash);
|
||||
_fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||
_fileName = ManifestTools.GetRemoteBundleFileName(nameStype, BundleName, _fileExtension, FileHash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -219,7 +219,7 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 检测资源包文件内容是否相同
|
||||
/// </summary>
|
||||
public bool Equals(PatchBundle otherBundle)
|
||||
public bool Equals(PackageBundle otherBundle)
|
||||
{
|
||||
if (FileHash == otherBundle.FileHash)
|
||||
return true;
|
|
@ -7,10 +7,10 @@ using System.Collections.Generic;
|
|||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 补丁清单文件
|
||||
/// 清单文件
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
internal class PatchManifest
|
||||
internal class PackageManifest
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件版本
|
||||
|
@ -40,25 +40,25 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 资源列表(主动收集的资源列表)
|
||||
/// </summary>
|
||||
public List<PatchAsset> AssetList = new List<PatchAsset>();
|
||||
public List<PackageAsset> AssetList = new List<PackageAsset>();
|
||||
|
||||
/// <summary>
|
||||
/// 资源包列表
|
||||
/// </summary>
|
||||
public List<PatchBundle> BundleList = new List<PatchBundle>();
|
||||
public List<PackageBundle> BundleList = new List<PackageBundle>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 资源包集合(提供BundleName获取PatchBundle)
|
||||
/// 资源包集合(提供BundleName获取PackageBundle)
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public Dictionary<string, PatchBundle> BundleDic;
|
||||
public Dictionary<string, PackageBundle> BundleDic;
|
||||
|
||||
/// <summary>
|
||||
/// 资源映射集合(提供AssetPath获取PatchAsset)
|
||||
/// 资源映射集合(提供AssetPath获取PackageAsset)
|
||||
/// </summary>
|
||||
[NonSerialized]
|
||||
public Dictionary<string, PatchAsset> AssetDic;
|
||||
public Dictionary<string, PackageAsset> AssetDic;
|
||||
|
||||
/// <summary>
|
||||
/// 资源路径映射集合
|
||||
|
@ -86,22 +86,22 @@ namespace YooAsset
|
|||
YooLogger.Error("Addressable not support location to lower !");
|
||||
|
||||
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))
|
||||
throw new Exception($"Address have existed : {location}");
|
||||
else
|
||||
AssetPathMapping.Add(location, patchAsset.AssetPath);
|
||||
AssetPathMapping.Add(location, packageAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
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)
|
||||
location = location.ToLower();
|
||||
|
||||
|
@ -109,7 +109,7 @@ namespace YooAsset
|
|||
if (AssetPathMapping.ContainsKey(location))
|
||||
throw new Exception($"AssetPath have existed : {location}");
|
||||
else
|
||||
AssetPathMapping.Add(location, patchAsset.AssetPath);
|
||||
AssetPathMapping.Add(location, packageAsset.AssetPath);
|
||||
|
||||
// 添加无后缀名路径的映射
|
||||
if (Path.HasExtension(location))
|
||||
|
@ -118,7 +118,7 @@ namespace YooAsset
|
|||
if (AssetPathMapping.ContainsKey(locationWithoutExtension))
|
||||
YooLogger.Warning($"AssetPath have existed : {locationWithoutExtension}");
|
||||
else
|
||||
AssetPathMapping.Add(locationWithoutExtension, patchAsset.AssetPath);
|
||||
AssetPathMapping.Add(locationWithoutExtension, packageAsset.AssetPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -170,15 +170,15 @@ namespace YooAsset
|
|||
/// 获取主资源包
|
||||
/// 注意:传入的资源路径一定合法有效!
|
||||
/// </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)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
return patchBundle;
|
||||
var packageBundle = BundleList[bundleID];
|
||||
return packageBundle;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -195,17 +195,17 @@ namespace YooAsset
|
|||
/// 获取资源依赖列表
|
||||
/// 注意:传入的资源路径一定合法有效!
|
||||
/// </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);
|
||||
foreach (var dependID in patchAsset.DependIDs)
|
||||
List<PackageBundle> result = new List<PackageBundle>(packageAsset.DependIDs.Length);
|
||||
foreach (var dependID in packageAsset.DependIDs)
|
||||
{
|
||||
if (dependID >= 0 && dependID < BundleList.Count)
|
||||
{
|
||||
var dependPatchBundle = BundleList[dependID];
|
||||
result.Add(dependPatchBundle);
|
||||
var dependBundle = BundleList[dependID];
|
||||
result.Add(dependBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -227,8 +227,8 @@ namespace YooAsset
|
|||
{
|
||||
if (bundleID >= 0 && bundleID < BundleList.Count)
|
||||
{
|
||||
var patchBundle = BundleList[bundleID];
|
||||
return patchBundle.BundleName;
|
||||
var packageBundle = BundleList[bundleID];
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -237,17 +237,17 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取补丁资源
|
||||
/// 尝试获取包裹的资源
|
||||
/// </summary>
|
||||
public bool TryGetPatchAsset(string assetPath, out PatchAsset result)
|
||||
public bool TryGetPackageAsset(string assetPath, out PackageAsset result)
|
||||
{
|
||||
return AssetDic.TryGetValue(assetPath, out result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 尝试获取补丁资源包
|
||||
/// 尝试获取包裹的资源包
|
||||
/// </summary>
|
||||
public bool TryGetPatchBundle(string bundleName, out PatchBundle result)
|
||||
public bool TryGetPackageBundle(string bundleName, out PackageBundle result)
|
||||
{
|
||||
return BundleDic.TryGetValue(bundleName, out result);
|
||||
}
|
||||
|
@ -257,9 +257,9 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
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 false;
|
||||
|
@ -271,11 +271,11 @@ namespace YooAsset
|
|||
public AssetInfo[] GetAssetsInfoByTags(string[] tags)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -291,9 +291,9 @@ namespace YooAsset
|
|||
DebugCheckLocation(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;
|
||||
}
|
||||
else
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -8,7 +8,7 @@ namespace YooAsset
|
|||
private static System.Type _classType;
|
||||
|
||||
/// <summary>
|
||||
/// 编辑器下模拟构建补丁清单
|
||||
/// 编辑器下模拟构建清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string packageName)
|
||||
{
|
||||
|
@ -37,7 +37,7 @@ namespace YooAsset
|
|||
public static class EditorSimulateModeHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 编辑器下模拟构建补丁清单
|
||||
/// 编辑器下模拟构建清单
|
||||
/// </summary>
|
||||
public static string SimulateBuild(string packageName) { throw new System.Exception("Only support in unity editor !"); }
|
||||
}
|
||||
|
|
|
@ -6,22 +6,22 @@ namespace YooAsset
|
|||
{
|
||||
internal class EditorSimulateModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PatchManifest _activeManifest;
|
||||
private PackageManifest _activeManifest;
|
||||
private bool _locationToLower;
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化
|
||||
/// </summary>
|
||||
public InitializationOperation InitializeAsync(bool locationToLower, string simulatePatchManifestPath)
|
||||
public InitializationOperation InitializeAsync(bool locationToLower, string simulateManifestFilePath)
|
||||
{
|
||||
_locationToLower = locationToLower;
|
||||
var operation = new EditorSimulateModeInitializationOperation(this, simulatePatchManifestPath);
|
||||
var operation = new EditorSimulateModeInitializationOperation(this, simulateManifestFilePath);
|
||||
OperationSystem.StartOperation(operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActiveManifest
|
||||
public PackageManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace YooAsset
|
|||
return _activeManifest;
|
||||
}
|
||||
}
|
||||
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
public bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -50,33 +50,33 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(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);
|
||||
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
|
||||
|
||||
|
@ -86,9 +86,9 @@ namespace YooAsset
|
|||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromEditor, assetInfo.AssetPath);
|
||||
return bundleInfo;
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
|||
{
|
||||
internal class HostPlayModeImpl : IPlayModeServices, IBundleServices, IRemoteServices
|
||||
{
|
||||
private PatchManifest _activeManifest;
|
||||
private PackageManifest _activeManifest;
|
||||
|
||||
// 参数相关
|
||||
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);
|
||||
foreach (var patchBundle in downloadList)
|
||||
foreach (var packageBundle in downloadList)
|
||||
{
|
||||
var bundleInfo = ConvertToDownloadInfo(patchBundle);
|
||||
var bundleInfo = ConvertToDownloadInfo(packageBundle);
|
||||
result.Add(bundleInfo);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private BundleInfo ConvertToDownloadInfo(PatchBundle patchBundle)
|
||||
private BundleInfo ConvertToDownloadInfo(PackageBundle packageBundle)
|
||||
{
|
||||
string remoteMainURL = GetRemoteMainURL(patchBundle.FileName);
|
||||
string remoteFallbackURL = GetRemoteFallbackURL(patchBundle.FileName);
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||
string remoteMainURL = GetRemoteMainURL(packageBundle.FileName);
|
||||
string remoteFallbackURL = GetRemoteFallbackURL(packageBundle.FileName);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromRemote, remoteMainURL, remoteFallbackURL);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
// 解压相关
|
||||
private List<BundleInfo> ConvertToUnpackList(List<PatchBundle> unpackList)
|
||||
private List<BundleInfo> ConvertToUnpackList(List<PackageBundle> unpackList)
|
||||
{
|
||||
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);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private BundleInfo ConvertToUnpackInfo(PatchBundle patchBundle)
|
||||
private BundleInfo ConvertToUnpackInfo(PackageBundle packageBundle)
|
||||
{
|
||||
return PatchManifestTools.GetUnpackInfo(patchBundle);
|
||||
return ManifestTools.GetUnpackInfo(packageBundle);
|
||||
}
|
||||
|
||||
#region IRemoteServices接口
|
||||
|
@ -78,7 +78,7 @@ namespace YooAsset
|
|||
#endregion
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActiveManifest
|
||||
public PackageManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
|
@ -91,13 +91,13 @@ namespace YooAsset
|
|||
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)
|
||||
|
@ -112,68 +112,68 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(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);
|
||||
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);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
public List<BundleInfo> GetDownloadListByAll(PatchManifest patchManifest)
|
||||
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
if (IsBuildinPatchBundle(patchBundle))
|
||||
if (IsBuildinPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
downloadList.Add(patchBundle);
|
||||
downloadList.Add(packageBundle);
|
||||
}
|
||||
|
||||
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);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
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);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
if (IsBuildinPatchBundle(patchBundle))
|
||||
if (IsBuildinPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 如果未带任何标记,则统一下载
|
||||
if (patchBundle.HasAnyTags() == false)
|
||||
if (packageBundle.HasAnyTags() == false)
|
||||
{
|
||||
downloadList.Add(patchBundle);
|
||||
downloadList.Add(packageBundle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 查询DLC资源
|
||||
if (patchBundle.HasTag(tags))
|
||||
if (packageBundle.HasTag(tags))
|
||||
{
|
||||
downloadList.Add(patchBundle);
|
||||
downloadList.Add(packageBundle);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,16 +181,16 @@ namespace YooAsset
|
|||
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);
|
||||
var operation = new PatchDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceDownloaderOperation(downloadList, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
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)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
|
@ -199,13 +199,13 @@ namespace YooAsset
|
|||
continue;
|
||||
}
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
PatchBundle mainBundle = patchManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle mainBundle = manifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
if (checkList.Contains(mainBundle) == false)
|
||||
checkList.Add(mainBundle);
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
PatchBundle[] dependBundles = patchManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
PackageBundle[] dependBundles = manifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
foreach (var dependBundle in dependBundles)
|
||||
{
|
||||
if (checkList.Contains(dependBundle) == false)
|
||||
|
@ -213,68 +213,68 @@ namespace YooAsset
|
|||
}
|
||||
}
|
||||
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in checkList)
|
||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in checkList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 忽略APP资源
|
||||
if (IsBuildinPatchBundle(patchBundle))
|
||||
if (IsBuildinPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
downloadList.Add(patchBundle);
|
||||
downloadList.Add(packageBundle);
|
||||
}
|
||||
|
||||
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);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
return operation;
|
||||
}
|
||||
private List<BundleInfo> GetUnpackListByAll(PatchManifest patchManifest)
|
||||
private List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||
{
|
||||
List<PatchBundle> downloadList = new List<PatchBundle>(1000);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
if (IsBuildinPatchBundle(patchBundle))
|
||||
if (IsBuildinPackageBundle(packageBundle))
|
||||
{
|
||||
downloadList.Add(patchBundle);
|
||||
downloadList.Add(packageBundle);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
var operation = new PatchUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
var operation = new ResourceUnpackerOperation(unpcakList, upackingMaxNumber, failedTryAgain, timeout);
|
||||
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);
|
||||
foreach (var patchBundle in patchManifest.BundleList)
|
||||
List<PackageBundle> downloadList = new List<PackageBundle>(1000);
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
// 忽略缓存文件
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
continue;
|
||||
|
||||
// 查询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
|
||||
|
||||
#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 !");
|
||||
|
||||
// 查询沙盒资源
|
||||
if (IsCachedPatchBundle(patchBundle))
|
||||
if (IsCachedPackageBundle(packageBundle))
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromCache);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromCache);
|
||||
return bundleInfo;
|
||||
}
|
||||
|
||||
// 查询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 ConvertToDownloadInfo(patchBundle);
|
||||
return ConvertToDownloadInfo(packageBundle);
|
||||
}
|
||||
BundleInfo IBundleServices.GetBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(patchBundle);
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
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);
|
||||
}
|
||||
return result.ToArray();
|
||||
|
|
|
@ -6,7 +6,7 @@ namespace YooAsset
|
|||
{
|
||||
internal class OfflinePlayModeImpl : IPlayModeServices, IBundleServices
|
||||
{
|
||||
private PatchManifest _activeManifest;
|
||||
private PackageManifest _activeManifest;
|
||||
private bool _locationToLower;
|
||||
|
||||
/// <summary>
|
||||
|
@ -21,7 +21,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
#region IPlayModeServices接口
|
||||
public PatchManifest ActiveManifest
|
||||
public PackageManifest ActiveManifest
|
||||
{
|
||||
set
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ namespace YooAsset
|
|||
return _activeManifest;
|
||||
}
|
||||
}
|
||||
public bool IsBuildinPatchBundle(PatchBundle patchBundle)
|
||||
public bool IsBuildinPackageBundle(PackageBundle packageBundle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -50,52 +50,52 @@ namespace YooAsset
|
|||
OperationSystem.StartOperation(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);
|
||||
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
|
||||
|
||||
#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 !");
|
||||
|
||||
// 查询沙盒资源
|
||||
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;
|
||||
}
|
||||
|
||||
// 查询APP资源
|
||||
{
|
||||
BundleInfo bundleInfo = new BundleInfo(patchBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||
BundleInfo bundleInfo = new BundleInfo(packageBundle, BundleInfo.ELoadMode.LoadFromStreaming);
|
||||
return bundleInfo;
|
||||
}
|
||||
}
|
||||
|
@ -104,21 +104,21 @@ namespace YooAsset
|
|||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
var patchBundle = _activeManifest.GetMainPatchBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(patchBundle);
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = _activeManifest.GetMainPackageBundle(assetInfo.AssetPath);
|
||||
return CreateBundleInfo(packageBundle);
|
||||
}
|
||||
BundleInfo[] IBundleServices.GetAllDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo.IsInvalid)
|
||||
throw new Exception("Should never get here !");
|
||||
|
||||
// 注意:如果补丁清单里未找到资源包会抛出异常!
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var depends = _activeManifest.GetAllDependencies(assetInfo.AssetPath);
|
||||
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);
|
||||
}
|
||||
return result.ToArray();
|
||||
|
|
|
@ -6,7 +6,7 @@ using UnityEngine.SceneManagement;
|
|||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class AssetsPackage
|
||||
public class ResourcePackage
|
||||
{
|
||||
private bool _isInitialize = false;
|
||||
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;
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ namespace YooAsset
|
|||
_assetSystemImpl.Initialize(PackageName, true, parameters.AssetLoadingMaxNumber, parameters.DecryptionServices, _bundleServices);
|
||||
|
||||
var initializeParameters = parameters as EditorSimulateModeParameters;
|
||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulatePatchManifestPath);
|
||||
initializeOperation = editorSimulateModeImpl.InitializeAsync(initializeParameters.LocationToLower, initializeParameters.SimulateManifestFilePath);
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
|
@ -143,10 +143,10 @@ namespace YooAsset
|
|||
private void CheckInitializeParameters(InitializeParameters parameters)
|
||||
{
|
||||
if (_isInitialize)
|
||||
throw new Exception($"{nameof(AssetsPackage)} is initialized yet.");
|
||||
throw new Exception($"{nameof(ResourcePackage)} is initialized yet.");
|
||||
|
||||
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 (parameters is EditorSimulateModeParameters)
|
||||
|
@ -156,8 +156,8 @@ namespace YooAsset
|
|||
if (parameters is EditorSimulateModeParameters)
|
||||
{
|
||||
var editorSimulateModeParameters = parameters as EditorSimulateModeParameters;
|
||||
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulatePatchManifestPath))
|
||||
throw new Exception($"{nameof(editorSimulateModeParameters.SimulatePatchManifestPath)} is null or empty.");
|
||||
if (string.IsNullOrEmpty(editorSimulateModeParameters.SimulateManifestFilePath))
|
||||
throw new Exception($"{nameof(editorSimulateModeParameters.SimulateManifestFilePath)} is null or empty.");
|
||||
}
|
||||
|
||||
if (parameters is HostPlayModeParameters)
|
||||
|
@ -206,7 +206,7 @@ namespace YooAsset
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求并更新补丁清单
|
||||
/// 向网络端请求并更新清单
|
||||
/// </summary>
|
||||
/// <param name="packageVersion">更新的包裹版本</param>
|
||||
/// <param name="autoActiveManifest">自动激活清单</param>
|
||||
|
@ -223,12 +223,12 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
/// <param name="packageVersion">下载的包裹版本</param>
|
||||
/// <param name="timeout">超时时间(默认值:60秒)</param>
|
||||
public PreDownloadPackageOperation PreDownloadPackageAsync(string packageVersion, int timeout = 60)
|
||||
public PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout = 60)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.PreDownloadPackageAsync(packageVersion, timeout);
|
||||
return _playModeServices.PreDownloadContentAsync(packageVersion, timeout);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清理包裹未使用的缓存文件
|
||||
/// </summary>
|
||||
|
@ -630,91 +630,139 @@ namespace YooAsset
|
|||
|
||||
#region 资源下载
|
||||
/// <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>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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();
|
||||
return _playModeServices.CreatePatchDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return _playModeServices.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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();
|
||||
return _playModeServices.CreatePatchDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return _playModeServices.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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();
|
||||
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>
|
||||
/// <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>
|
||||
/// <param name="assetInfos">资源信息列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</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();
|
||||
return _playModeServices.CreatePatchDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
return _playModeServices.CreateResourceDownloaderByPaths(assetInfos, downloadingMaxNumber, failedTryAgain, timeout);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源解压
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.CreatePatchUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return _playModeServices.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.CreatePatchUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return _playModeServices.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeServices.CreatePatchUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
return _playModeServices.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue);
|
||||
}
|
||||
#endregion
|
||||
|
|
@ -6,12 +6,12 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 激活的清单
|
||||
/// </summary>
|
||||
PatchManifest ActiveManifest { set; get; }
|
||||
PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为内置资源文件
|
||||
/// </summary>
|
||||
bool IsBuildinPatchBundle(PatchBundle patchBundle);
|
||||
bool IsBuildinPackageBundle(PackageBundle packageBundle);
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求最新的资源版本
|
||||
|
@ -19,22 +19,22 @@ namespace YooAsset
|
|||
UpdatePackageVersionOperation UpdatePackageVersionAsync(bool appendTimeTicks, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求并更新补丁清单
|
||||
/// 向网络端请求并更新清单
|
||||
/// </summary>
|
||||
UpdatePackageManifestOperation UpdatePackageManifestAsync(string packageVersion, int timeout);
|
||||
|
||||
/// <summary>
|
||||
/// 预下载指定版本的包裹资源
|
||||
/// 预下载指定版本的包裹内容
|
||||
/// </summary>
|
||||
PreDownloadPackageOperation PreDownloadPackageAsync(string packageVersion, int timeout);
|
||||
PreDownloadContentOperation PreDownloadContentAsync(string packageVersion, int timeout);
|
||||
|
||||
// 下载相关
|
||||
PatchDownloaderOperation CreatePatchDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchDownloaderOperation CreatePatchDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchDownloaderOperation CreatePatchDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout);
|
||||
|
||||
// 解压相关
|
||||
PatchUnpackerOperation CreatePatchUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
PatchUnpackerOperation CreatePatchUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout);
|
||||
}
|
||||
}
|
|
@ -8,23 +8,23 @@ namespace YooAsset
|
|||
/// <summary>
|
||||
/// 清单文件名称
|
||||
/// </summary>
|
||||
public string PatchManifestFileName = "PatchManifest";
|
||||
public string ManifestFileName = "PackageManifest";
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 清单文件头标记
|
||||
/// </summary>
|
||||
public const uint PatchManifestFileSign = 0x594F4F;
|
||||
public const uint ManifestFileSign = 0x594F4F;
|
||||
|
||||
/// <summary>
|
||||
/// 清单文件极限大小(100MB)
|
||||
/// </summary>
|
||||
public const int PatchManifestFileMaxSize = 104857600;
|
||||
public const int ManifestFileMaxSize = 104857600;
|
||||
|
||||
/// <summary>
|
||||
/// 清单文件格式版本
|
||||
/// </summary>
|
||||
public const string PatchManifestFileVersion = "1.4.6";
|
||||
public const string ManifestFileVersion = "1.4.6";
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string GetManifestBinaryFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.bytes";
|
||||
return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.bytes";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -53,7 +53,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string GetManifestJsonFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.json";
|
||||
return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.json";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -61,7 +61,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string GetPackageHashFileName(string packageName, string packageVersion)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}_{packageVersion}.hash";
|
||||
return $"{Setting.ManifestFileName}_{packageName}_{packageVersion}.hash";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -69,7 +69,7 @@ namespace YooAsset
|
|||
/// </summary>
|
||||
public static string GetPackageVersionFileName(string packageName)
|
||||
{
|
||||
return $"{Setting.PatchManifestFileName}_{packageName}.version";
|
||||
return $"{Setting.ManifestFileName}_{packageName}.version";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,7 @@ namespace YooAsset
|
|||
{
|
||||
private static bool _isInitialize = false;
|
||||
private static GameObject _driver = null;
|
||||
private static readonly List<AssetsPackage> _packages = new List<AssetsPackage>();
|
||||
private static readonly List<ResourcePackage> _packages = new List<ResourcePackage>();
|
||||
|
||||
/// <summary>
|
||||
/// 初始化资源系统
|
||||
|
@ -88,7 +88,7 @@ namespace YooAsset
|
|||
/// 创建资源包
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static AssetsPackage CreateAssetsPackage(string packageName)
|
||||
public static ResourcePackage CreatePackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
@ -96,23 +96,23 @@ namespace YooAsset
|
|||
if (string.IsNullOrEmpty(packageName))
|
||||
throw new Exception("Package name is null or empty !");
|
||||
|
||||
if (HasAssetsPackage(packageName))
|
||||
if (HasPackage(packageName))
|
||||
throw new Exception($"Package {packageName} already existed !");
|
||||
|
||||
AssetsPackage assetsPackage = new AssetsPackage(packageName);
|
||||
_packages.Add(assetsPackage);
|
||||
return assetsPackage;
|
||||
ResourcePackage package = new ResourcePackage(packageName);
|
||||
_packages.Add(package);
|
||||
return package;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包
|
||||
/// </summary>
|
||||
/// <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)
|
||||
YooLogger.Warning($"Not found assets package : {packageName}");
|
||||
YooLogger.Error($"Not found assets package : {packageName}");
|
||||
return package;
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ namespace YooAsset
|
|||
/// 尝试获取资源包
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static AssetsPackage TryGetAssetsPackage(string packageName)
|
||||
public static ResourcePackage TryGetPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
@ -140,7 +140,7 @@ namespace YooAsset
|
|||
/// 检测资源包是否存在
|
||||
/// </summary>
|
||||
/// <param name="packageName">资源包名称</param>
|
||||
public static bool HasAssetsPackage(string packageName)
|
||||
public static bool HasPackage(string packageName)
|
||||
{
|
||||
if (_isInitialize == false)
|
||||
throw new Exception($"{nameof(YooAssets)} not initialize !");
|
||||
|
|
|
@ -8,14 +8,14 @@ namespace YooAsset
|
|||
{
|
||||
public static partial class YooAssets
|
||||
{
|
||||
private static AssetsPackage _defaultPackage;
|
||||
private static ResourcePackage _defaultPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 设置默认的资源包
|
||||
/// </summary>
|
||||
public static void SetDefaultAssetsPackage(AssetsPackage assetsPackage)
|
||||
public static void SetDefaultPackage(ResourcePackage package)
|
||||
{
|
||||
_defaultPackage = assetsPackage;
|
||||
_defaultPackage = package;
|
||||
}
|
||||
|
||||
#region 资源信息
|
||||
|
@ -286,47 +286,83 @@ namespace YooAsset
|
|||
|
||||
#region 资源下载
|
||||
/// <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>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</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();
|
||||
return _defaultPackage.CreatePatchDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateResourceDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新资源标签指定的资源包文件
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</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();
|
||||
return _defaultPackage.CreatePatchDownloader(tags, downloadingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateResourceDownloader(tags, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁下载器,用于下载更新当前资源版本所有的资源包文件
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static PatchDownloaderOperation CreatePatchDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
public static ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchDownloader(downloadingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateBundleDownloader(location, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="assetInfos">资源信息列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</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();
|
||||
return _defaultPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain);
|
||||
|
@ -335,38 +371,38 @@ namespace YooAsset
|
|||
|
||||
#region 资源解压
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</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();
|
||||
return _defaultPackage.CreatePatchUnpacker(tag, unpackingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateResourceUnpacker(tag, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</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();
|
||||
return _defaultPackage.CreatePatchUnpacker(tags, unpackingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateResourceUnpacker(tags, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建补丁解压器
|
||||
/// 创建内置资源解压器
|
||||
/// </summary>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static PatchUnpackerOperation CreatePatchUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
public static ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreatePatchUnpacker(unpackingMaxNumber, failedTryAgain);
|
||||
return _defaultPackage.CreateResourceUnpacker(unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
@ -375,7 +411,7 @@ namespace YooAsset
|
|||
private static void DebugCheckDefaultPackageValid()
|
||||
{
|
||||
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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue