mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-26 10:40:14 +00:00
refactor : 重构代码
This commit is contained in:
@@ -19,7 +19,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildBundleType = (int)EBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
buildParameters.PackageName = packageName;
|
||||
buildParameters.PackageVersion = "Simulate";
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 资源包加密服务类
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
public IBundleEncryptionServices EncryptionServices;
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单加密服务类
|
||||
@@ -146,7 +146,7 @@ namespace YooAsset.Editor
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineIsNullOrEmpty, "Build pipeline is null or empty !");
|
||||
throw new Exception(message);
|
||||
}
|
||||
if (BuildBundleType == (int)EBuildBundleType.Unknown)
|
||||
if (BuildBundleType == (int)EBundleType.Unknown)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildBundleTypeIsUnknown, $"Build bundle type is unknown {BuildBundleType} !");
|
||||
throw new Exception(message);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace YooAsset.Editor
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
CatalogFileHelper.CreateFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建新补丁清单
|
||||
PackageManifest manifest = new PackageManifest();
|
||||
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||
manifest.FileVersion = PackageManifestDefine.FileVersion;
|
||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
@@ -71,7 +71,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToJson(filePath, manifest);
|
||||
PackageManifestTools.SerializeToJson(filePath, manifest);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestProcessServices);
|
||||
PackageManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestProcessServices);
|
||||
packageHash = HashUtility.FileCRC32(packagePath);
|
||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||
}
|
||||
@@ -106,7 +106,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
|
||||
manifestContext.Manifest = PackageManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace YooAsset.Editor
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
EncryptFileInfo fileInfo = new EncryptFileInfo();
|
||||
EncryptBundleInfo fileInfo = new EncryptBundleInfo();
|
||||
fileInfo.BundleName = bundleInfo.BundleName;
|
||||
fileInfo.FileLoadPath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
var encryptResult = encryptionServices.Encrypt(fileInfo);
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace YooAsset.Editor
|
||||
{
|
||||
string bundleName = bundleInfo.BundleName;
|
||||
string fileHash = bundleInfo.PackageFileHash;
|
||||
string fileExtension = ManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||
string fileName = ManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||
string fileExtension = PackageManifestTools.GetRemoteBundleFileExtension(bundleName);
|
||||
string fileName = PackageManifestTools.GetRemoteBundleFileName(outputNameStyle, bundleName, fileExtension, fileHash);
|
||||
bundleInfo.PackageDestFilePath = $"{packageOutputDirectory}/{fileName}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class EncryptionNone : IEncryptionServices
|
||||
public class EncryptionNone : IBundleEncryptionServices
|
||||
{
|
||||
public EncryptResult Encrypt(EncryptFileInfo fileInfo)
|
||||
public EncryptResult Encrypt(EncryptBundleInfo fileInfo)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
@@ -46,13 +46,13 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 创建资源包加密服务类实例
|
||||
/// </summary>
|
||||
protected IEncryptionServices CreateEncryptionServicesInstance()
|
||||
protected IBundleEncryptionServices CreateEncryptionServicesInstance()
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, PipelineName);
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IBundleEncryptionServices));
|
||||
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||
if (classType != null)
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
return (IBundleEncryptionServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
@@ -184,7 +184,7 @@ namespace YooAsset.Editor
|
||||
protected PopupField<Type> CreateEncryptionServicesField(VisualElement container)
|
||||
{
|
||||
// 资源包加密服务类
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IBundleEncryptionServices));
|
||||
if (classTypes.Count > 0)
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, PipelineName);
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildBundleType = (int)EBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildBundleType = (int)EBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
buildParameters.BuildBundleType = (int)EBundleType.RawBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
|
||||
@@ -109,7 +109,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildBundleType = (int)EBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
|
||||
@@ -277,7 +277,7 @@ namespace YooAsset.Editor
|
||||
if (dependTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{dependTableData.BundleInfo.FileName}";
|
||||
|
||||
@@ -348,7 +348,7 @@ namespace YooAsset.Editor
|
||||
if (bundleTableData.BundleInfo.Encrypted)
|
||||
return;
|
||||
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
|
||||
if (_buildReport.Summary.BuildBundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
|
||||
string filePath = $"{rootDirectory}/{bundleTableData.BundleInfo.FileName}";
|
||||
|
||||
@@ -3,9 +3,9 @@ using System.Collections.Generic;
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入文件的信息
|
||||
/// 导入的资源包信息
|
||||
/// </summary>
|
||||
public struct ImportFileInfo
|
||||
public struct ImportBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 本地文件路径
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class CatalogDefine
|
||||
internal class CatalogFileDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件极限大小(100MB)
|
||||
@@ -5,14 +5,14 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal static class CatalogTools
|
||||
internal static class CatalogFileHelper
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
/// <summary>
|
||||
/// 生成包裹的内置资源目录文件
|
||||
/// 说明:根据指定目录下的文件生成清单文件。
|
||||
/// </summary>
|
||||
public static bool CreateCatalogFile(IManifestRestoreServices services, string packageName, string packageDirectory)
|
||||
public static bool CreateFile(IManifestRestoreServices services, string packageName, string packageDirectory)
|
||||
{
|
||||
// 获取资源清单版本
|
||||
string packageVersion;
|
||||
@@ -40,7 +40,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
|
||||
packageManifest = ManifestTools.DeserializeFromBinary(binaryData, services);
|
||||
packageManifest = PackageManifestTools.DeserializeFromBinary(binaryData, services);
|
||||
}
|
||||
|
||||
// 获取文件名映射关系
|
||||
@@ -54,7 +54,7 @@ namespace YooAsset
|
||||
|
||||
// 创建内置清单实例
|
||||
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
||||
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
buildinFileCatalog.FileVersion = CatalogFileDefine.FileVersion;
|
||||
buildinFileCatalog.PackageName = packageName;
|
||||
buildinFileCatalog.PackageVersion = packageVersion;
|
||||
|
||||
@@ -122,11 +122,11 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 生成空的包裹内置资源目录文件
|
||||
/// </summary>
|
||||
public static bool CreateEmptyCatalogFile(string packageName, string packageVersion, string outputPath)
|
||||
public static bool CreateEmptyFile(string packageName, string packageVersion, string outputPath)
|
||||
{
|
||||
// 创建内置清单实例
|
||||
var buildinFileCatalog = new DefaultBuildinFileCatalog();
|
||||
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
|
||||
buildinFileCatalog.FileVersion = CatalogFileDefine.FileVersion;
|
||||
buildinFileCatalog.PackageName = packageName;
|
||||
buildinFileCatalog.PackageVersion = packageVersion;
|
||||
|
||||
@@ -173,13 +173,13 @@ namespace YooAsset
|
||||
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||
{
|
||||
// 创建缓存器
|
||||
BufferWriter buffer = new BufferWriter(CatalogDefine.FileMaxSize);
|
||||
BufferWriter buffer = new BufferWriter(CatalogFileDefine.FileMaxSize);
|
||||
|
||||
// 写入文件标记
|
||||
buffer.WriteUInt32(CatalogDefine.FileSign);
|
||||
buffer.WriteUInt32(CatalogFileDefine.FileSign);
|
||||
|
||||
// 写入文件版本
|
||||
buffer.WriteUTF8(CatalogDefine.FileVersion);
|
||||
buffer.WriteUTF8(CatalogFileDefine.FileVersion);
|
||||
|
||||
// 写入文件头信息
|
||||
buffer.WriteUTF8(catalog.PackageName);
|
||||
@@ -213,13 +213,13 @@ namespace YooAsset
|
||||
|
||||
// 读取文件标记
|
||||
uint fileSign = buffer.ReadUInt32();
|
||||
if (fileSign != CatalogDefine.FileSign)
|
||||
if (fileSign != CatalogFileDefine.FileSign)
|
||||
throw new Exception("Invalid catalog file !");
|
||||
|
||||
// 读取文件版本
|
||||
string fileVersion = buffer.ReadUTF8();
|
||||
if (fileVersion != CatalogDefine.FileVersion)
|
||||
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogDefine.FileVersion}");
|
||||
if (fileVersion != CatalogFileDefine.FileVersion)
|
||||
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogFileDefine.FileVersion}");
|
||||
|
||||
DefaultBuildinFileCatalog catalog = new DefaultBuildinFileCatalog();
|
||||
{
|
||||
@@ -107,12 +107,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
public IBundleDecryptionServices BundleDecryptionServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
public IManifestRestoreServices ManifestRestoreServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件接口的实例类
|
||||
@@ -139,29 +139,30 @@ namespace YooAsset
|
||||
var operation = new DBFSLoadPackageManifestOperation(this, options.PackageVersion);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
return _unpackFileSystem.ClearCacheFilesAsync(manifest, options);
|
||||
return _unpackFileSystem.ClearCacheFilesAsync(options);
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
// 注意:业务层的解压器会依赖该方法
|
||||
options.ImportFilePath = GetBuildinFileLoadPath(bundle);
|
||||
return _unpackFileSystem.DownloadFileAsync(bundle, options);
|
||||
options.ImportFilePath = GetBuildinFileLoadPath(options.Bundle);
|
||||
return _unpackFileSystem.DownloadFileAsync(options);
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (IsUnpackBundleFile(bundle))
|
||||
{
|
||||
return _unpackFileSystem.LoadBundleFile(bundle);
|
||||
return _unpackFileSystem.LoadBundleAsync(options);
|
||||
}
|
||||
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
if (bundle.BundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DBFSLoadAssetBundleOperation(this, bundle);
|
||||
return operation;
|
||||
}
|
||||
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
else if (bundle.BundleType == (int)EBundleType.RawBundle)
|
||||
{
|
||||
var operation = new DBFSLoadRawBundleOperation(this, bundle);
|
||||
return operation;
|
||||
@@ -224,13 +225,13 @@ namespace YooAsset
|
||||
{
|
||||
UnpackFileSystemRoot = (string)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IDecryptionServices)value;
|
||||
BundleDecryptionServices = (IBundleDecryptionServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES)
|
||||
{
|
||||
ManifestServices = (IManifestRestoreServices)value;
|
||||
ManifestRestoreServices = (IManifestRestoreServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES)
|
||||
{
|
||||
@@ -264,7 +265,7 @@ namespace YooAsset
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_LEVEL, FileVerifyLevel);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY, FileVerifyMaxConcurrency);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES, BundleDecryptionServices);
|
||||
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, CopyLocalFileServices);
|
||||
_unpackFileSystem.OnCreate(packageName, UnpackFileSystemRoot);
|
||||
}
|
||||
@@ -409,7 +410,7 @@ namespace YooAsset
|
||||
if (bundle.Encrypted)
|
||||
return true;
|
||||
|
||||
if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
if (bundle.BundleType == (int)EBundleType.RawBundle)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
@@ -479,31 +480,31 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载加密的资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||
public DecryptSyncResult LoadEncryptedBundleSync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundle(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleSync(bundleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密的资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||
public DecryptAsyncResult LoadEncryptedBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetBuildinFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundleAsync(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleAsync(bundleInfo);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -44,11 +44,11 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
if (_fileSystem.DecryptionServices == null)
|
||||
if (_fileSystem.BundleDecryptionServices == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The {nameof(IDecryptionServices)} is null !";
|
||||
Error = $"The {nameof(IBundleDecryptionServices)} is null !";
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
@@ -58,7 +58,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleSync(_bundle);
|
||||
_assetBundle = decryptResult.Result;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleAsync(_bundle);
|
||||
_createRequest = decryptResult.CreateRequest;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace YooAsset
|
||||
{
|
||||
try
|
||||
{
|
||||
Catalog = CatalogTools.DeserializeFromBinary(_fileData);
|
||||
Catalog = CatalogFileHelper.DeserializeFromBinary(_fileData);
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _fileData);
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestRestoreServices, _fileData);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
@@ -129,12 +129,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IDecryptionServices DecryptionServices { private set; get; }
|
||||
public IBundleDecryptionServices BundleDecryptionServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
public IManifestRestoreServices ManifestRestoreServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:拷贝内置文件接口的实例类
|
||||
@@ -161,7 +161,7 @@ namespace YooAsset
|
||||
var operation = new DCFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
if (options.ClearMode == EFileClearMode.ClearAllBundleFiles.ToString())
|
||||
{
|
||||
@@ -170,17 +170,17 @@ namespace YooAsset
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearUnusedBundleFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
|
||||
var operation = new ClearUnusedCacheBundleFilesOperation(this, options.Manifest);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByLocations.ToString())
|
||||
{
|
||||
var operation = new ClearCacheBundleFilesByLocationsOperaiton(this, manifest, options.ClearParam);
|
||||
var operation = new ClearCacheBundleFilesByLocationsOperaiton(this, options.Manifest, options.ClearParam);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
|
||||
{
|
||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam);
|
||||
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, options.Manifest, options.ClearParam);
|
||||
return operation;
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearAllManifestFiles.ToString())
|
||||
@@ -190,7 +190,7 @@ namespace YooAsset
|
||||
}
|
||||
else if (options.ClearMode == EFileClearMode.ClearUnusedManifestFiles.ToString())
|
||||
{
|
||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, manifest);
|
||||
var operation = new ClearUnusedCacheManifestFilesOperation(this, options.Manifest);
|
||||
return operation;
|
||||
}
|
||||
else
|
||||
@@ -200,9 +200,10 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
// 获取下载地址
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (string.IsNullOrEmpty(options.ImportFilePath))
|
||||
{
|
||||
// 注意:如果是解压文件系统类,这里会返回本地内置文件的下载路径
|
||||
@@ -217,17 +218,18 @@ namespace YooAsset
|
||||
options.SetURL(mainURL, mainURL);
|
||||
}
|
||||
|
||||
var downloader = new DownloadPackageBundleOperation(this, bundle, options);
|
||||
var downloader = new DownloadPackageBundleOperation(this, options);
|
||||
return downloader;
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (bundle.BundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DCFSLoadAssetBundleOperation(this, bundle);
|
||||
return operation;
|
||||
}
|
||||
else if (bundle.BundleType == (int)EBuildBundleType.RawBundle)
|
||||
else if (bundle.BundleType == (int)EBundleType.RawBundle)
|
||||
{
|
||||
var operation = new DCFSLoadRawBundleOperation(this, bundle);
|
||||
return operation;
|
||||
@@ -315,13 +317,13 @@ namespace YooAsset
|
||||
{
|
||||
ResumeDownloadResponseCodes = (List<long>)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IDecryptionServices)value;
|
||||
BundleDecryptionServices = (IBundleDecryptionServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES)
|
||||
{
|
||||
ManifestServices = (IManifestRestoreServices)value;
|
||||
ManifestRestoreServices = (IManifestRestoreServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES)
|
||||
{
|
||||
@@ -403,20 +405,20 @@ namespace YooAsset
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
if (BundleDecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !");
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.ReadFileData(fileInfo);
|
||||
return BundleDecryptionServices.ReadFileData(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -431,20 +433,20 @@ namespace YooAsset
|
||||
|
||||
if (bundle.Encrypted)
|
||||
{
|
||||
if (DecryptionServices == null)
|
||||
if (BundleDecryptionServices == null)
|
||||
{
|
||||
YooLogger.Error($"The {nameof(IDecryptionServices)} is null !");
|
||||
YooLogger.Error($"The {nameof(IBundleDecryptionServices)} is null !");
|
||||
return null;
|
||||
}
|
||||
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.ReadFileText(fileInfo);
|
||||
return BundleDecryptionServices.ReadFileText(bundleInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -649,46 +651,46 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundle(PackageBundle bundle)
|
||||
public DecryptSyncResult LoadEncryptedBundleSync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundle(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleSync(bundleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleAsync(PackageBundle bundle)
|
||||
public DecryptAsyncResult LoadEncryptedBundleAsync(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundleAsync(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleAsync(bundleInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载加密资源文件
|
||||
/// </summary>
|
||||
public DecryptResult LoadEncryptedAssetBundleFallback(PackageBundle bundle)
|
||||
public DecryptSyncResult LoadEncryptedBundleFallback(PackageBundle bundle)
|
||||
{
|
||||
string filePath = GetCacheBundleFileLoadPath(bundle);
|
||||
var fileInfo = new DecryptFileInfo()
|
||||
var bundleInfo = new DecryptBundleInfo()
|
||||
{
|
||||
BundleName = bundle.BundleName,
|
||||
FileLoadCRC = bundle.UnityCRC,
|
||||
FileLoadPath = filePath,
|
||||
};
|
||||
return DecryptionServices.LoadAssetBundleFallback(fileInfo);
|
||||
return BundleDecryptionServices.LoadAssetBundleFallback(bundleInfo);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace YooAsset
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
@@ -127,11 +127,11 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
if (_fileSystem.DecryptionServices == null)
|
||||
if (_fileSystem.BundleDecryptionServices == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The {nameof(IDecryptionServices)} is null !";
|
||||
Error = $"The {nameof(IBundleDecryptionServices)} is null !";
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
@@ -141,7 +141,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundle(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleSync(_bundle);
|
||||
_assetBundle = decryptResult.Result;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundleAsync(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleAsync(_bundle);
|
||||
_createRequest = decryptResult.CreateRequest;
|
||||
_managedStream = decryptResult.ManagedStream;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
var decryptResult = _fileSystem.LoadEncryptedAssetBundleFallback(_bundle);
|
||||
var decryptResult = _fileSystem.LoadEncryptedBundleFallback(_bundle);
|
||||
_assetBundle = decryptResult.Result;
|
||||
if (_assetBundle != null)
|
||||
{
|
||||
@@ -348,8 +348,8 @@ namespace YooAsset
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DownloadPackageBundleOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||
internal DownloadPackageBundleOperation(DefaultCacheFileSystem fileSystem, DownloadFileOptions options) : base(options.Bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_options = options;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
@@ -75,7 +75,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _fileData);
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestRestoreServices, _fileData);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
@@ -93,21 +93,22 @@ namespace YooAsset
|
||||
var operation = new DEFSLoadPackageManifestOperation(this, options.PackageVersion);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
var operation = new FSClearCacheFilesCompleteOperation();
|
||||
return operation;
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
string mainURL = bundle.BundleName;
|
||||
string mainURL = options.Bundle.BundleName;
|
||||
options.SetURL(mainURL, mainURL);
|
||||
var downloader = new DownloadVirtualBundleOperation(this, bundle, options);
|
||||
var downloader = new DownloadVirtualBundleOperation(this, options);
|
||||
return downloader;
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.VirtualBundle)
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (bundle.BundleType == (int)EBundleType.VirtualBundle)
|
||||
{
|
||||
var operation = new DEFSLoadBundleOperation(this, bundle);
|
||||
return operation;
|
||||
|
||||
@@ -64,8 +64,8 @@ namespace YooAsset
|
||||
{
|
||||
if (_downloadFileOp == null)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
_downloadFileOp = _fileSystem.DownloadFileAsync(options);
|
||||
_downloadFileOp.StartOperation();
|
||||
AddChildOperation(_downloadFileOp);
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal DownloadVirtualBundleOperation(DefaultEditorFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
|
||||
internal DownloadVirtualBundleOperation(DefaultEditorFileSystem fileSystem, DownloadFileOptions options) : base(options.Bundle)
|
||||
{
|
||||
_fileSystem = fileSystem;
|
||||
_options = options;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_fileData, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
||||
@@ -61,12 +61,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IWebDecryptionServices DecryptionServices { private set; get; }
|
||||
public IWebBundleDecryptionServices BundleDecryptionServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
public IManifestRestoreServices ManifestRestoreServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -88,18 +88,19 @@ namespace YooAsset
|
||||
var operation = new DWRFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
var operation = new FSClearCacheFilesCompleteOperation();
|
||||
return operation;
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (bundle.BundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DWRFSLoadAssetBundleOperation(this, bundle);
|
||||
return operation;
|
||||
@@ -130,13 +131,13 @@ namespace YooAsset
|
||||
{
|
||||
RemoteServices = (IRemoteServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IWebDecryptionServices)value;
|
||||
BundleDecryptionServices = (IWebBundleDecryptionServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES)
|
||||
{
|
||||
ManifestServices = (IManifestRestoreServices)value;
|
||||
ManifestRestoreServices = (IManifestRestoreServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -36,18 +36,18 @@ namespace YooAsset
|
||||
{
|
||||
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
|
||||
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
options.SetURL(mainURL, fallbackURL);
|
||||
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(options, _fileSystem.BundleDecryptionServices, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(options, _fileSystem.DisableUnityWebCache, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace YooAsset
|
||||
{
|
||||
string packageHash = _requestWebPackageHashOp.PackageHash;
|
||||
string packageName = _fileSystem.PackageName;
|
||||
var manifestServices = _fileSystem.ManifestServices;
|
||||
var manifestServices = _fileSystem.ManifestRestoreServices;
|
||||
var remoteServices = _fileSystem.RemoteServices;
|
||||
var downloadBackend = _fileSystem.DownloadBackend;
|
||||
_loadWebPackageManifestOp = new LoadWebPackageManifestOperation(manifestServices, remoteServices, downloadBackend, packageName, _packageVersion, packageHash, _timeout);
|
||||
|
||||
@@ -70,12 +70,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 自定义参数:解密服务接口的实例类
|
||||
/// </summary>
|
||||
public IWebDecryptionServices DecryptionServices { private set; get; }
|
||||
public IWebBundleDecryptionServices BundleDecryptionServices { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 自定义参数:资源清单服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestServices { private set; get; }
|
||||
public IManifestRestoreServices ManifestRestoreServices { private set; get; }
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -97,18 +97,19 @@ namespace YooAsset
|
||||
var operation = new DWSFSLoadPackageManifestOperation(this, options.PackageVersion, options.Timeout);
|
||||
return operation;
|
||||
}
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options)
|
||||
public virtual FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
var operation = new FSClearCacheFilesCompleteOperation();
|
||||
return operation;
|
||||
}
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
|
||||
public virtual FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
|
||||
public virtual FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options)
|
||||
{
|
||||
if (bundle.BundleType == (int)EBuildBundleType.AssetBundle)
|
||||
PackageBundle bundle = options.Bundle;
|
||||
if (bundle.BundleType == (int)EBundleType.AssetBundle)
|
||||
{
|
||||
var operation = new DWSFSLoadAssetBundleOperation(this, bundle);
|
||||
return operation;
|
||||
@@ -135,13 +136,13 @@ namespace YooAsset
|
||||
{
|
||||
DisableUnityWebCache = Convert.ToBoolean(value);
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES)
|
||||
{
|
||||
DecryptionServices = (IWebDecryptionServices)value;
|
||||
BundleDecryptionServices = (IWebBundleDecryptionServices)value;
|
||||
}
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
|
||||
else if (name == FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES)
|
||||
{
|
||||
ManifestServices = (IManifestRestoreServices)value;
|
||||
ManifestRestoreServices = (IManifestRestoreServices)value;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -36,18 +36,18 @@ namespace YooAsset
|
||||
{
|
||||
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
|
||||
string mainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
|
||||
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
|
||||
DownloadFileOptions options = new DownloadFileOptions(_bundle, int.MaxValue);
|
||||
options.SetURL(mainURL, mainURL);
|
||||
|
||||
if (_bundle.Encrypted)
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(options, _fileSystem.BundleDecryptionServices, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(options, _fileSystem.DisableUnityWebCache, _fileSystem.DownloadBackend);
|
||||
_loadWebAssetBundleOp.StartOperation();
|
||||
AddChildOperation(_loadWebAssetBundleOp);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace YooAsset
|
||||
{
|
||||
try
|
||||
{
|
||||
var catalog = CatalogTools.DeserializeFromBinary(_webDataRequestOp.Result);
|
||||
var catalog = CatalogFileHelper.DeserializeFromBinary(_webDataRequestOp.Result);
|
||||
if (catalog.PackageName != _fileSystem.PackageName)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_deserializer == null)
|
||||
{
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestServices, _webDataRequestOp.Result);
|
||||
_deserializer = new DeserializeManifestOperation(_fileSystem.ManifestRestoreServices, _webDataRequestOp.Result);
|
||||
_deserializer.StartOperation();
|
||||
AddChildOperation(_deserializer);
|
||||
}
|
||||
|
||||
@@ -83,11 +83,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="packageRoot">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IBundleDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultBuildinFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES, decryptionServices);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
@@ -97,12 +97,12 @@ namespace YooAsset
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="packageRoot">文件系统的根目录</param>
|
||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IBundleDecryptionServices decryptionServices = null, string packageRoot = null)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultCacheFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES, decryptionServices);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
@@ -111,11 +111,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(IWebDecryptionServices decryptionServices = null, bool disableUnityWebCache = false)
|
||||
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(IWebBundleDecryptionServices decryptionServices = null, bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebServerFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
@@ -126,12 +126,12 @@ namespace YooAsset
|
||||
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||
/// <param name="disableUnityWebCache">禁用Unity的网络缓存</param>
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, IWebDecryptionServices decryptionServices = null, bool disableUnityWebCache = false)
|
||||
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, IWebBundleDecryptionServices decryptionServices = null, bool disableUnityWebCache = false)
|
||||
{
|
||||
string fileSystemClass = typeof(DefaultWebRemoteFileSystem).FullName;
|
||||
var fileSystemParams = new FileSystemParameters(fileSystemClass, null);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.BUNDLE_DECRYPTION_SERVICES, decryptionServices);
|
||||
fileSystemParams.AddParameter(FileSystemParametersDefine.DISABLE_UNITY_WEB_CACHE, disableUnityWebCache);
|
||||
return fileSystemParams;
|
||||
}
|
||||
|
||||
@@ -7,102 +7,127 @@ namespace YooAsset
|
||||
/// 初始化的时候缓存文件校验级别 <see cref=EFileVerifyLevel>
|
||||
/// </summary>
|
||||
public const string FILE_VERIFY_LEVEL = "FILE_VERIFY_LEVEL";
|
||||
|
||||
/// <summary>
|
||||
/// 初始化的时候缓存文件校验最大并发数 <see cref=int>
|
||||
/// </summary>
|
||||
public const string FILE_VERIFY_MAX_CONCURRENCY = "FILE_VERIFY_MAX_CONCURRENCY";
|
||||
|
||||
/// <summary>
|
||||
/// 覆盖安装缓存清理模式 <see cref=EOverwriteInstallClearMode>
|
||||
/// </summary>
|
||||
public const string INSTALL_CLEAR_MODE = "INSTALL_CLEAR_MODE";
|
||||
|
||||
/// <summary>
|
||||
/// 远端资源地址查询服务类 <see cref=IRemoteServices>
|
||||
/// </summary>
|
||||
public const string REMOTE_SERVICES = "REMOTE_SERVICES";
|
||||
|
||||
/// <summary>
|
||||
/// 解密服务接口的实例类 <see cref=IDecryptionServices>
|
||||
/// 解密服务接口的实例类 <see cref=IBundleDecryptionServices>
|
||||
/// </summary>
|
||||
public const string DECRYPTION_SERVICES = "DECRYPTION_SERVICES";
|
||||
public const string BUNDLE_DECRYPTION_SERVICES = "BUNDLE_DECRYPTION_SERVICES";
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单服务类 <see cref=IManifestRestoreServices>
|
||||
/// </summary>
|
||||
public const string MANIFEST_SERVICES = "MANIFEST_SERVICES";
|
||||
public const string MANIFEST_RESTORE_SERVICES = "MANIFEST_RESTORE_SERVICES";
|
||||
|
||||
/// <summary>
|
||||
/// 数据文件追加文件格式 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
|
||||
|
||||
/// <summary>
|
||||
/// 禁用Catalog目录查询文件 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string DISABLE_CATALOG_FILE = "DISABLE_CATALOG_FILE";
|
||||
|
||||
/// <summary>
|
||||
/// 禁用Unity的网络缓存 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE";
|
||||
|
||||
/// <summary>
|
||||
/// 禁用边玩边下机制 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLOAD";
|
||||
|
||||
/// <summary>
|
||||
/// UnityWebRequest 创建委托 <see cref=UnityWebRequestCreator>
|
||||
/// </summary>
|
||||
public const string UNITY_WEB_REQUEST_CREATOR = "UNITY_WEB_REQUEST_CREATOR";
|
||||
|
||||
/// <summary>
|
||||
/// 下载后台接口 <see cref=IDownloadBackend>
|
||||
/// </summary>
|
||||
public const string DOWNLOAD_BACKEND = "DOWNLOAD_BACKEND";
|
||||
|
||||
/// <summary>
|
||||
/// 最大并发连接数 默认值:10(推荐范围 1-32) <see cref=int>
|
||||
/// </summary>
|
||||
public const string DOWNLOAD_MAX_CONCURRENCY = "DOWNLOAD_MAX_CONCURRENCY";
|
||||
|
||||
/// <summary>
|
||||
/// 每帧发起的最大请求数 默认值:5(推荐范围 1-10)<see cref=int>
|
||||
/// </summary>
|
||||
public const string DOWNLOAD_MAX_REQUEST_PER_FRAME = "DOWNLOAD_MAX_REQUEST_PER_FRAME";
|
||||
|
||||
/// <summary>
|
||||
/// 下载任务的看门狗机制监控时间 <see cref=int>
|
||||
/// </summary>
|
||||
public const string DOWNLOAD_WATCH_DOG_TIME = "DOWNLOAD_WATCH_DOG_TIME";
|
||||
|
||||
/// <summary>
|
||||
/// 启用断点续传的最小尺寸 <see cref=long>
|
||||
/// </summary>
|
||||
public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE";
|
||||
|
||||
/// <summary>
|
||||
/// 断点续传下载器关注的错误码 <see cref=List<long>>
|
||||
/// </summary>
|
||||
public const string RESUME_DOWNLOAD_RESPONSE_CODES = "RESUME_DOWNLOAD_RESPONSE_CODES";
|
||||
|
||||
/// <summary>
|
||||
/// 模拟WebGL平台模式 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string VIRTUAL_WEBGL_MODE = "VIRTUAL_WEBGL_MODE";
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载模式 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string VIRTUAL_DOWNLOAD_MODE = "VIRTUAL_DOWNLOAD_MODE";
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载的网速(单位:字节) <see cref=int>
|
||||
/// </summary>
|
||||
public const string VIRTUAL_DOWNLOAD_SPEED = "VIRTUAL_DOWNLOAD_SPEED";
|
||||
|
||||
/// <summary>
|
||||
/// 异步模拟加载最小帧数 <see cref=int>
|
||||
/// </summary>
|
||||
public const string ASYNC_SIMULATE_MIN_FRAME = "ASYNC_SIMULATE_MIN_FRAME";
|
||||
|
||||
/// <summary>
|
||||
/// 异步模拟加载最大帧数 <see cref=int>
|
||||
/// </summary>
|
||||
public const string ASYNC_SIMULATE_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME";
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置清单 <see cref=bool>
|
||||
/// </summary>
|
||||
public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST";
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置清单的目标目录 <see cref=string>
|
||||
/// </summary>
|
||||
public const string COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT = "COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT";
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝内置文件接口的实例类 <see cref=ICopyLocalFileServices>
|
||||
/// </summary>
|
||||
public const string COPY_LOCAL_FILE_SERVICES = "COPY_LOCAL_FILE_SERVICES";
|
||||
|
||||
/// <summary>
|
||||
/// 解压文件系统的根目录 <see cref=string>
|
||||
/// </summary>
|
||||
|
||||
@@ -37,17 +37,17 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
FSClearCacheFilesOperation ClearCacheFilesAsync(PackageManifest manifest, ClearCacheFilesOptions options);
|
||||
FSClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// 下载Bundle文件
|
||||
/// </summary>
|
||||
FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options);
|
||||
FSDownloadFileOperation DownloadFileAsync(DownloadFileOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// 加载Bundle文件
|
||||
/// </summary>
|
||||
FSLoadBundleOperation LoadBundleFile(PackageBundle bundle);
|
||||
FSLoadBundleOperation LoadBundleAsync(LoadBundleOptions options);
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,54 +1,6 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class DownloadFileOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 失败后重试次数
|
||||
/// </summary>
|
||||
public readonly int FailedTryAgain;
|
||||
|
||||
/// <summary>
|
||||
/// 主资源地址
|
||||
/// </summary>
|
||||
public string MainURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 备用资源地址
|
||||
/// </summary>
|
||||
public string FallbackURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝的本地文件路径
|
||||
/// </summary>
|
||||
public string ImportFilePath { set; get; }
|
||||
|
||||
public DownloadFileOptions(int failedTryAgain)
|
||||
{
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置下载地址
|
||||
/// </summary>
|
||||
public void SetURL(string mainURL, string fallbackURL)
|
||||
{
|
||||
MainURL = mainURL;
|
||||
FallbackURL = fallbackURL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(MainURL) || string.IsNullOrEmpty(FallbackURL))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class FSDownloadFileOperation : AsyncOperationBase
|
||||
{
|
||||
public PackageBundle Bundle { private set; get; }
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal struct DownloadFileOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包
|
||||
/// </summary>
|
||||
public readonly PackageBundle Bundle;
|
||||
|
||||
/// <summary>
|
||||
/// 失败后重试次数
|
||||
/// </summary>
|
||||
public readonly int FailedTryAgain;
|
||||
|
||||
/// <summary>
|
||||
/// 主资源地址
|
||||
/// </summary>
|
||||
public string MainURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 备用资源地址
|
||||
/// </summary>
|
||||
public string FallbackURL { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 拷贝的本地文件路径
|
||||
/// </summary>
|
||||
public string ImportFilePath { set; get; }
|
||||
|
||||
public DownloadFileOptions(PackageBundle bundle, int failedTryAgain)
|
||||
{
|
||||
Bundle = bundle;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
MainURL = null;
|
||||
FallbackURL = null;
|
||||
ImportFilePath = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置下载地址
|
||||
/// </summary>
|
||||
public void SetURL(string mainURL, string fallbackURL)
|
||||
{
|
||||
MainURL = mainURL;
|
||||
FallbackURL = fallbackURL;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否有效
|
||||
/// </summary>
|
||||
public bool IsValid()
|
||||
{
|
||||
if (string.IsNullOrEmpty(MainURL) || string.IsNullOrEmpty(FallbackURL))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9143514bc9d4f3e4aa9a50a7cfb08d21
|
||||
guid: ae6a979ad693ddf488c7a0f387c6ea76
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal struct LoadBundleOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包
|
||||
/// </summary>
|
||||
public readonly PackageBundle Bundle;
|
||||
|
||||
public LoadBundleOptions(PackageBundle bundle)
|
||||
{
|
||||
Bundle = bundle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 70420213c551a2b4b8cf014067699b07
|
||||
guid: 3d4cf0ce3cf4c794fa2d40665d5f3147
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -13,9 +13,8 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PackageBundle _bundle;
|
||||
private readonly DownloadFileOptions _options;
|
||||
private readonly IWebDecryptionServices _decryptionServices;
|
||||
private readonly IWebBundleDecryptionServices _decryptionServices;
|
||||
private readonly IDownloadBackend _downloadBackend;
|
||||
private IDownloadBytesRequest _unityWebDataRequestOp;
|
||||
|
||||
@@ -24,9 +23,8 @@ namespace YooAsset
|
||||
private int _failedTryAgain;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal LoadWebEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, IWebDecryptionServices decryptionServices, IDownloadBackend downloadBackend)
|
||||
internal LoadWebEncryptAssetBundleOperation(DownloadFileOptions options, IWebBundleDecryptionServices decryptionServices, IDownloadBackend downloadBackend)
|
||||
{
|
||||
_bundle = bundle;
|
||||
_options = options;
|
||||
_failedTryAgain = options.FailedTryAgain;
|
||||
_decryptionServices = decryptionServices;
|
||||
@@ -48,7 +46,7 @@ namespace YooAsset
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
Error = $"The {nameof(IWebDecryptionServices)} is null !";
|
||||
Error = $"The {nameof(IWebBundleDecryptionServices)} is null !";
|
||||
YooLogger.Error(Error);
|
||||
return;
|
||||
}
|
||||
@@ -124,11 +122,11 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
private AssetBundle LoadEncryptedAssetBundle(byte[] fileData)
|
||||
{
|
||||
var fileInfo = new WebDecryptFileInfo();
|
||||
fileInfo.BundleName = _bundle.BundleName;
|
||||
fileInfo.FileLoadCRC = _bundle.UnityCRC;
|
||||
var fileInfo = new WebDecryptBundleInfo();
|
||||
fileInfo.BundleName = _options.Bundle.BundleName;
|
||||
fileInfo.FileLoadCRC = _options.Bundle.UnityCRC;
|
||||
fileInfo.FileData = fileData;
|
||||
var decryptResult = _decryptionServices.LoadAssetBundle(fileInfo);
|
||||
var decryptResult = _decryptionServices.LoadAssetBundleSync(fileInfo);
|
||||
return decryptResult.Result;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PackageBundle _bundle;
|
||||
private readonly DownloadFileOptions _options;
|
||||
private readonly bool _disableUnityWebCache;
|
||||
private readonly IDownloadBackend _downloadBackend;
|
||||
@@ -25,9 +24,8 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal LoadWebNormalAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool disableUnityWebCache, IDownloadBackend downloadBackend)
|
||||
internal LoadWebNormalAssetBundleOperation(DownloadFileOptions options, bool disableUnityWebCache, IDownloadBackend downloadBackend)
|
||||
{
|
||||
_bundle = bundle;
|
||||
_options = options;
|
||||
_failedTryAgain = options.FailedTryAgain;
|
||||
_disableUnityWebCache = disableUnityWebCache;
|
||||
@@ -46,7 +44,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CreateRequest)
|
||||
{
|
||||
string url = GetRequestURL();
|
||||
var args = new DownloadAssetBundleRequestArgs(url, 0, 0, _disableUnityWebCache, _bundle.FileHash, _bundle.UnityCRC);
|
||||
var args = new DownloadAssetBundleRequestArgs(url, 0, 0, _disableUnityWebCache, _options.Bundle.FileHash, _options.Bundle.UnityCRC);
|
||||
_unityAssetBundleRequestOp = _downloadBackend.CreateAssetBundleRequest(args);
|
||||
_unityAssetBundleRequestOp.SendRequest();
|
||||
_steps = ESteps.CheckRequest;
|
||||
|
||||
@@ -80,7 +80,7 @@ internal class LoadWebPackageManifestOperation : AsyncOperationBase
|
||||
|
||||
if (_steps == ESteps.VerifyFileData)
|
||||
{
|
||||
if (ManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
if (PackageManifestTools.VerifyManifestData(_webDataRequestOp.Result, _packageHash))
|
||||
{
|
||||
_steps = ESteps.LoadManifest;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class EditorSimulateModeHelper
|
||||
public class EditorSimulateBuildInvoker
|
||||
{
|
||||
public static PackageInvokeBuildResult SimulateBuild(string packageName)
|
||||
public static PackageInvokeBuildResult Build(string packageName)
|
||||
{
|
||||
var buildParam = new PackageInvokeBuildParam(packageName);
|
||||
buildParam.BuildPipelineName = "EditorSimulateBuildPipeline";
|
||||
@@ -76,62 +76,48 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public GameObject InstantiateSync()
|
||||
{
|
||||
return InstantiateSyncInternal(false, Vector3.zero, Quaternion.identity, null, false);
|
||||
var options = new InstantiateOptions(true);
|
||||
return InstantiateSyncInternal(options);
|
||||
}
|
||||
public GameObject InstantiateSync(Transform parent)
|
||||
|
||||
/// <summary>
|
||||
/// 同步初始化游戏对象
|
||||
/// </summary>
|
||||
public GameObject InstantiateSync(InstantiateOptions options)
|
||||
{
|
||||
return InstantiateSyncInternal(false, Vector3.zero, Quaternion.identity, parent, false);
|
||||
}
|
||||
public GameObject InstantiateSync(Transform parent, bool worldPositionStays)
|
||||
{
|
||||
return InstantiateSyncInternal(false, Vector3.zero, Quaternion.identity, parent, worldPositionStays);
|
||||
}
|
||||
public GameObject InstantiateSync(Vector3 position, Quaternion rotation)
|
||||
{
|
||||
return InstantiateSyncInternal(true, position, rotation, null, false);
|
||||
}
|
||||
public GameObject InstantiateSync(Vector3 position, Quaternion rotation, Transform parent)
|
||||
{
|
||||
return InstantiateSyncInternal(true, position, rotation, parent, false);
|
||||
return InstantiateSyncInternal(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步初始化游戏对象
|
||||
/// </summary>
|
||||
public InstantiateOperation InstantiateAsync(bool actived = true)
|
||||
public InstantiateOperation InstantiateAsync()
|
||||
{
|
||||
return InstantiateAsyncInternal(false, Vector3.zero, Quaternion.identity, null, false, actived);
|
||||
}
|
||||
public InstantiateOperation InstantiateAsync(Transform parent, bool actived = true)
|
||||
{
|
||||
return InstantiateAsyncInternal(false, Vector3.zero, Quaternion.identity, parent, false, actived);
|
||||
}
|
||||
public InstantiateOperation InstantiateAsync(Transform parent, bool worldPositionStays, bool actived = true)
|
||||
{
|
||||
return InstantiateAsyncInternal(false, Vector3.zero, Quaternion.identity, parent, worldPositionStays, actived);
|
||||
}
|
||||
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, bool actived = true)
|
||||
{
|
||||
return InstantiateAsyncInternal(true, position, rotation, null, false, actived);
|
||||
}
|
||||
public InstantiateOperation InstantiateAsync(Vector3 position, Quaternion rotation, Transform parent, bool actived = true)
|
||||
{
|
||||
return InstantiateAsyncInternal(true, position, rotation, parent, false, actived);
|
||||
var options = new InstantiateOptions(true);
|
||||
return InstantiateAsyncInternal(options);
|
||||
}
|
||||
|
||||
private GameObject InstantiateSyncInternal(bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)
|
||||
/// <summary>
|
||||
/// 异步初始化游戏对象
|
||||
/// </summary>
|
||||
public InstantiateOperation InstantiateAsync(InstantiateOptions options)
|
||||
{
|
||||
return InstantiateAsyncInternal(options);
|
||||
}
|
||||
|
||||
private GameObject InstantiateSyncInternal(InstantiateOptions options)
|
||||
{
|
||||
if (IsValidWithWarning == false)
|
||||
return null;
|
||||
if (Provider.AssetObject == null)
|
||||
return null;
|
||||
|
||||
return InstantiateOperation.InstantiateInternal(Provider.AssetObject, setPositionAndRotation, position, rotation, parent, worldPositionStays);
|
||||
return InstantiateOperation.InstantiateInternal(Provider.AssetObject, options);
|
||||
}
|
||||
private InstantiateOperation InstantiateAsyncInternal(bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays, bool actived)
|
||||
private InstantiateOperation InstantiateAsyncInternal(InstantiateOptions options)
|
||||
{
|
||||
string packageName = GetAssetInfo().PackageName;
|
||||
InstantiateOperation operation = new InstantiateOperation(this, setPositionAndRotation, position, rotation, parent, worldPositionStays, actived);
|
||||
InstantiateOperation operation = new InstantiateOperation(this, options);
|
||||
OperationSystem.StartOperation(packageName, operation);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ namespace YooAsset
|
||||
/// 异步卸载场景对象
|
||||
/// 注意:场景卸载成功后,会自动释放该handle的引用计数!
|
||||
/// </summary>
|
||||
public UnloadSceneOperation UnloadAsync()
|
||||
public UnloadSceneOperation UnloadSceneAsync()
|
||||
{
|
||||
string packageName = GetAssetInfo().PackageName;
|
||||
|
||||
|
||||
@@ -14,12 +14,7 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
private readonly AssetHandle _handle;
|
||||
private readonly bool _setPositionAndRotation;
|
||||
private readonly Vector3 _position;
|
||||
private readonly Quaternion _rotation;
|
||||
private readonly Transform _parent;
|
||||
private readonly bool _worldPositionStays;
|
||||
private readonly bool _actived;
|
||||
private readonly InstantiateOptions _options;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
#if UNITY_2023_3_OR_NEWER
|
||||
@@ -32,16 +27,10 @@ namespace YooAsset
|
||||
public GameObject Result = null;
|
||||
|
||||
|
||||
internal InstantiateOperation(AssetHandle handle, bool setPositionAndRotation, Vector3 position, Quaternion rotation,
|
||||
Transform parent, bool worldPositionStays, bool actived)
|
||||
internal InstantiateOperation(AssetHandle handle, InstantiateOptions options)
|
||||
{
|
||||
_handle = handle;
|
||||
_setPositionAndRotation = setPositionAndRotation;
|
||||
_position = position;
|
||||
_rotation = rotation;
|
||||
_parent = parent;
|
||||
_worldPositionStays = worldPositionStays;
|
||||
_actived = actived;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
@@ -90,8 +79,8 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CloneSync)
|
||||
{
|
||||
// 实例化游戏对象
|
||||
Result = InstantiateInternal(_handle.AssetObject, _setPositionAndRotation, _position, _rotation, _parent, _worldPositionStays);
|
||||
if (_actived == false)
|
||||
Result = InstantiateInternal(_handle.AssetObject, _options);
|
||||
if (_options.Actived == false)
|
||||
Result.SetActive(false);
|
||||
|
||||
_steps = ESteps.Done;
|
||||
@@ -103,7 +92,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_instantiateAsync == null)
|
||||
{
|
||||
_instantiateAsync = InstantiateAsyncInternal(_handle.AssetObject, _setPositionAndRotation, _position, _rotation, _parent, _worldPositionStays);
|
||||
_instantiateAsync = InstantiateAsyncInternal(_handle.AssetObject, _options);
|
||||
}
|
||||
|
||||
if (IsWaitForAsyncComplete)
|
||||
@@ -117,7 +106,7 @@ namespace YooAsset
|
||||
Result = _instantiateAsync.Result[0] as GameObject;
|
||||
if (Result != null)
|
||||
{
|
||||
if (_actived == false)
|
||||
if (_options.Actived == false)
|
||||
Result.SetActive(false);
|
||||
|
||||
_steps = ESteps.Done;
|
||||
@@ -165,22 +154,22 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 同步实例化
|
||||
/// </summary>
|
||||
internal static GameObject InstantiateInternal(UnityEngine.Object assetObject, bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)
|
||||
internal static GameObject InstantiateInternal(UnityEngine.Object assetObject, InstantiateOptions options)
|
||||
{
|
||||
if (assetObject == null)
|
||||
return null;
|
||||
|
||||
if (setPositionAndRotation)
|
||||
if (options.SetPositionAndRotation)
|
||||
{
|
||||
if (parent != null)
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, position, rotation, parent);
|
||||
if (options.Parent != null)
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, options.Position, options.Rotation, options.Parent);
|
||||
else
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, position, rotation);
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, options.Position, options.Rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent != null)
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, parent, worldPositionStays);
|
||||
if (options.Parent != null)
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject, options.Parent, options.InWorldSpace);
|
||||
else
|
||||
return UnityEngine.Object.Instantiate(assetObject as GameObject);
|
||||
}
|
||||
@@ -192,19 +181,19 @@ namespace YooAsset
|
||||
/// 注意:Unity2022.3.20f1及以上版本生效
|
||||
/// https://docs.unity3d.com/2022.3/Documentation/ScriptReference/Object.InstantiateAsync.html
|
||||
/// </summary>
|
||||
internal static AsyncInstantiateOperation InstantiateAsyncInternal(UnityEngine.Object assetObject, bool setPositionAndRotation, Vector3 position, Quaternion rotation, Transform parent, bool worldPositionStays)
|
||||
internal static AsyncInstantiateOperation InstantiateAsyncInternal(UnityEngine.Object assetObject, InstantiateOptions options)
|
||||
{
|
||||
if (setPositionAndRotation)
|
||||
if (options.SetPositionAndRotation)
|
||||
{
|
||||
if (parent != null)
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, parent, position, rotation);
|
||||
if (options.Parent != null)
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, options.Parent, options.Position, options.Rotation);
|
||||
else
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, position, rotation);
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, options.Position, options.Rotation);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parent != null)
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, parent);
|
||||
if (options.Parent != null)
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject, options.Parent);
|
||||
else
|
||||
return UnityEngine.Object.InstantiateAsync(assetObject as GameObject);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public struct InstantiateOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否激活实例化对象
|
||||
/// </summary>
|
||||
public bool Actived { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 将指定给新对象的父对象
|
||||
/// </summary>
|
||||
public Transform Parent { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 分配父对象时, 定位新对象关系。
|
||||
/// true 在世界空间中定位新对象。
|
||||
/// false 相对于父对象来设置新对象。
|
||||
/// </summary>
|
||||
public bool InWorldSpace { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 新对象的位置
|
||||
/// </summary>
|
||||
public Vector3 Position { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 新对象的方向
|
||||
/// </summary>
|
||||
public Quaternion Rotation { private set; get; }
|
||||
|
||||
internal bool SetPositionAndRotation { private set; get; }
|
||||
|
||||
public InstantiateOptions(bool actived)
|
||||
{
|
||||
Actived = actived;
|
||||
Parent = null;
|
||||
InWorldSpace = false;
|
||||
|
||||
SetPositionAndRotation = false;
|
||||
Position = Vector3.zero;
|
||||
Rotation = Quaternion.identity;
|
||||
}
|
||||
public InstantiateOptions(bool actived, Transform parent, bool inWorldSpace)
|
||||
{
|
||||
Actived = actived;
|
||||
Parent = parent;
|
||||
InWorldSpace = inWorldSpace;
|
||||
|
||||
SetPositionAndRotation = false;
|
||||
Position = Vector3.zero;
|
||||
Rotation = Quaternion.identity;
|
||||
}
|
||||
public InstantiateOptions(bool actived, Transform parent, Vector3 position, Quaternion rotation)
|
||||
{
|
||||
Actived = actived;
|
||||
Parent = parent;
|
||||
InWorldSpace = false;
|
||||
|
||||
SetPositionAndRotation = true;
|
||||
Position = position;
|
||||
Rotation = rotation;
|
||||
}
|
||||
public InstantiateOptions(bool actived, Vector3 position, Quaternion rotation)
|
||||
{
|
||||
Actived = actived;
|
||||
Parent = null;
|
||||
InWorldSpace = false;
|
||||
|
||||
SetPositionAndRotation = true;
|
||||
Position = position;
|
||||
Rotation = rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4629f36c31a96214b9057827c6a283cf
|
||||
guid: 7432581e3bde71648adef94499c7a398
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class LoadBundleFileOperation : AsyncOperationBase
|
||||
internal class LoadBundleOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -51,7 +51,7 @@ namespace YooAsset
|
||||
public BundleResult Result { set; get; }
|
||||
|
||||
|
||||
internal LoadBundleFileOperation(ResourceManager resourceManager, BundleInfo bundleInfo)
|
||||
internal LoadBundleOperation(ResourceManager resourceManager, BundleInfo bundleInfo)
|
||||
{
|
||||
_resManager = resourceManager;
|
||||
LoadBundleInfo = bundleInfo;
|
||||
@@ -85,7 +85,7 @@ namespace YooAsset
|
||||
{
|
||||
// 统计计数增加
|
||||
_resManager.BundleLoadingCounter++;
|
||||
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
|
||||
_loadBundleOp = LoadBundleInfo.CreateBundleLoader();
|
||||
_loadBundleOp.StartOperation();
|
||||
AddChildOperation(_loadBundleOp);
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
@@ -14,19 +13,19 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
private readonly ResourceManager _resManager;
|
||||
private readonly int _loopCount;
|
||||
private readonly UnloadUnusedAssetsOptions _options;
|
||||
private int _loopCounter = 0;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, int loopCount)
|
||||
internal UnloadUnusedAssetsOperation(ResourceManager resourceManager, UnloadUnusedAssetsOptions options)
|
||||
{
|
||||
_resManager = resourceManager;
|
||||
_loopCount = loopCount;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
{
|
||||
_steps = ESteps.UnloadUnused;
|
||||
_loopCounter = _loopCount;
|
||||
_loopCounter = _options.LoopCount;
|
||||
}
|
||||
internal override void InternalUpdate()
|
||||
{
|
||||
@@ -57,7 +56,7 @@ namespace YooAsset
|
||||
}
|
||||
internal override string InternalGetDesc()
|
||||
{
|
||||
return $"LoopCount : {_loopCount}";
|
||||
return $"LoopCount : {_options.LoopCount}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -65,7 +64,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
private void LoopUnloadUnused()
|
||||
{
|
||||
var removeList = new List<LoadBundleFileOperation>(_resManager.LoaderDic.Count);
|
||||
var removeList = new List<LoadBundleOperation>(_resManager.LoaderDic.Count);
|
||||
|
||||
// 注意:优先销毁资源提供者
|
||||
foreach (var loader in _resManager.LoaderDic.Values)
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public struct UnloadUnusedAssetsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 循环迭代次数
|
||||
/// </summary>
|
||||
public int LoopCount { private set; get; }
|
||||
|
||||
public UnloadUnusedAssetsOptions(int loopCount)
|
||||
{
|
||||
LoopCount = loopCount;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2db868c2aaaee8e42a7f035117e747c4
|
||||
guid: 33a033398461486429728fc87b8b9840
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -80,8 +80,8 @@ namespace YooAsset
|
||||
|
||||
private ESteps _steps = ESteps.None;
|
||||
protected readonly ResourceManager _resManager;
|
||||
private readonly LoadBundleFileOperation _mainBundleLoader;
|
||||
private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>(10);
|
||||
private readonly LoadBundleOperation _mainBundleLoader;
|
||||
private readonly List<LoadBundleOperation> _bundleLoaders = new List<LoadBundleOperation>(10);
|
||||
private readonly HashSet<HandleBase> _handles = new HashSet<HandleBase>();
|
||||
|
||||
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace YooAsset
|
||||
internal class ResourceManager
|
||||
{
|
||||
internal readonly Dictionary<string, ProviderOperation> ProviderDic = new Dictionary<string, ProviderOperation>(5000);
|
||||
internal readonly Dictionary<string, LoadBundleFileOperation> LoaderDic = new Dictionary<string, LoadBundleFileOperation>(5000);
|
||||
internal readonly Dictionary<string, LoadBundleOperation> LoaderDic = new Dictionary<string, LoadBundleOperation>(5000);
|
||||
internal readonly List<SceneHandle> SceneHandles = new List<SceneHandle>(100);
|
||||
private FileSystemHost _fileSystemHost;
|
||||
private long _sceneCreateIndex = 0;
|
||||
private IBundleQuery _bundleQuery;
|
||||
private int _bundleLoadingMaxConcurrency;
|
||||
|
||||
|
||||
// 开发者配置选项
|
||||
public bool AutoUnloadBundleWhenUnused { private set; get; }
|
||||
public bool WebGLForceSyncLoadAsset { private set; get; }
|
||||
@@ -44,12 +44,12 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
public void Initialize(InitializePackageOptions options, IBundleQuery bundleServices)
|
||||
public void Initialize(InitializePackageOptions options, FileSystemHost host)
|
||||
{
|
||||
_fileSystemHost = host;
|
||||
_bundleLoadingMaxConcurrency = options.BundleLoadingMaxConcurrency;
|
||||
AutoUnloadBundleWhenUnused = options.AutoUnloadBundleWhenUnused;
|
||||
WebGLForceSyncLoadAsset = options.WebGLForceSyncLoadAsset;
|
||||
_bundleQuery = bundleServices;
|
||||
SceneManager.sceneUnloaded += OnSceneUnloaded;
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace YooAsset
|
||||
loopCount--;
|
||||
|
||||
// 卸载主资源包加载器
|
||||
string mainBundleName = _bundleQuery.GetMainBundleName(assetInfo.Asset.BundleID);
|
||||
string mainBundleName = _fileSystemHost.GetMainBundleName(assetInfo.Asset.BundleID);
|
||||
var mainLoader = TryGetBundleFileLoader(mainBundleName);
|
||||
if (mainLoader != null)
|
||||
{
|
||||
@@ -97,7 +97,7 @@ namespace YooAsset
|
||||
// 卸载依赖资源包加载器
|
||||
foreach (var dependID in assetInfo.Asset.DependBundleIDs)
|
||||
{
|
||||
string dependBundleName = _bundleQuery.GetMainBundleName(dependID);
|
||||
string dependBundleName = _fileSystemHost.GetMainBundleName(dependID);
|
||||
var dependLoader = TryGetBundleFileLoader(dependBundleName);
|
||||
if (dependLoader != null)
|
||||
{
|
||||
@@ -296,15 +296,15 @@ namespace YooAsset
|
||||
return provider.CreateHandle<RawFileHandle>();
|
||||
}
|
||||
|
||||
internal LoadBundleFileOperation CreateMainBundleFileLoader(AssetInfo assetInfo)
|
||||
internal LoadBundleOperation CreateMainBundleFileLoader(AssetInfo assetInfo)
|
||||
{
|
||||
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
|
||||
BundleInfo bundleInfo = _fileSystemHost.GetMainBundleInfo(assetInfo);
|
||||
return CreateBundleFileLoaderInternal(bundleInfo);
|
||||
}
|
||||
internal List<LoadBundleFileOperation> CreateDependBundleFileLoaders(AssetInfo assetInfo)
|
||||
internal List<LoadBundleOperation> CreateDependBundleFileLoaders(AssetInfo assetInfo)
|
||||
{
|
||||
List<BundleInfo> bundleInfos = _bundleQuery.GetDependBundleInfos(assetInfo);
|
||||
List<LoadBundleFileOperation> result = new List<LoadBundleFileOperation>(bundleInfos.Count);
|
||||
List<BundleInfo> bundleInfos = _fileSystemHost.GetDependBundleInfos(assetInfo);
|
||||
List<LoadBundleOperation> result = new List<LoadBundleOperation>(bundleInfos.Count);
|
||||
foreach (var bundleInfo in bundleInfos)
|
||||
{
|
||||
var bundleLoader = CreateBundleFileLoaderInternal(bundleInfo);
|
||||
@@ -321,7 +321,7 @@ namespace YooAsset
|
||||
}
|
||||
internal bool CheckBundleDestroyed(int bundleID)
|
||||
{
|
||||
string bundleName = _bundleQuery.GetMainBundleName(bundleID);
|
||||
string bundleName = _fileSystemHost.GetMainBundleName(bundleID);
|
||||
var bundleFileLoader = TryGetBundleFileLoader(bundleName);
|
||||
if (bundleFileLoader == null)
|
||||
return true;
|
||||
@@ -329,7 +329,7 @@ namespace YooAsset
|
||||
}
|
||||
internal bool CheckBundleReleasable(int bundleID)
|
||||
{
|
||||
string bundleName = _bundleQuery.GetMainBundleName(bundleID);
|
||||
string bundleName = _fileSystemHost.GetMainBundleName(bundleID);
|
||||
var bundleFileLoader = TryGetBundleFileLoader(bundleName);
|
||||
if (bundleFileLoader == null)
|
||||
return true;
|
||||
@@ -344,22 +344,22 @@ namespace YooAsset
|
||||
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
|
||||
}
|
||||
|
||||
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||
private LoadBundleOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
|
||||
{
|
||||
// 如果加载器已经存在
|
||||
string bundleName = bundleInfo.Bundle.BundleName;
|
||||
LoadBundleFileOperation loaderOperation = TryGetBundleFileLoader(bundleName);
|
||||
LoadBundleOperation loaderOperation = TryGetBundleFileLoader(bundleName);
|
||||
if (loaderOperation != null)
|
||||
return loaderOperation;
|
||||
|
||||
// 新增下载需求
|
||||
loaderOperation = new LoadBundleFileOperation(this, bundleInfo);
|
||||
loaderOperation = new LoadBundleOperation(this, bundleInfo);
|
||||
LoaderDic.Add(bundleName, loaderOperation);
|
||||
return loaderOperation;
|
||||
}
|
||||
private LoadBundleFileOperation TryGetBundleFileLoader(string bundleName)
|
||||
private LoadBundleOperation TryGetBundleFileLoader(string bundleName)
|
||||
{
|
||||
if (LoaderDic.TryGetValue(bundleName, out LoadBundleFileOperation value))
|
||||
if (LoaderDic.TryGetValue(bundleName, out LoadBundleOperation value))
|
||||
return value;
|
||||
else
|
||||
return null;
|
||||
|
||||
@@ -26,21 +26,22 @@ namespace YooAsset
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载资源包
|
||||
/// 创建加载器
|
||||
/// </summary>
|
||||
public FSLoadBundleOperation LoadBundleFile()
|
||||
public FSLoadBundleOperation CreateBundleLoader()
|
||||
{
|
||||
return _fileSystem.LoadBundleFile(Bundle);
|
||||
var options = new LoadBundleOptions(Bundle);
|
||||
return _fileSystem.LoadBundleAsync(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建下载器
|
||||
/// </summary>
|
||||
public FSDownloadFileOperation CreateDownloader(int failedTryAgain)
|
||||
public FSDownloadFileOperation CreateBundleDownloader(int failedTryAgain)
|
||||
{
|
||||
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain);
|
||||
DownloadFileOptions options = new DownloadFileOptions(Bundle, failedTryAgain);
|
||||
options.ImportFilePath = _importFilePath;
|
||||
return _fileSystem.DownloadFileAsync(Bundle, options);
|
||||
return _fileSystem.DownloadFileAsync(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public enum EBuildBundleType
|
||||
public enum EBundleType
|
||||
{
|
||||
/// <summary>
|
||||
/// 未知类型
|
||||
@@ -4,12 +4,18 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal class PlayModeImpl : IPlayMode, IBundleQuery
|
||||
internal class FileSystemHost
|
||||
{
|
||||
public readonly string PackageName;
|
||||
public readonly List<IFileSystem> FileSystems = new List<IFileSystem>(10);
|
||||
|
||||
public PlayModeImpl(string packageName)
|
||||
/// <summary>
|
||||
/// 当前激活的清单
|
||||
/// </summary>
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
|
||||
public FileSystemHost(string packageName)
|
||||
{
|
||||
PackageName = packageName;
|
||||
}
|
||||
@@ -47,16 +53,10 @@ namespace YooAsset
|
||||
return operation;
|
||||
}
|
||||
|
||||
#region IPlayMode接口
|
||||
/// <summary>
|
||||
/// 当前激活的清单
|
||||
/// </summary>
|
||||
public PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 销毁文件系统
|
||||
/// </summary>
|
||||
void IPlayMode.DestroyFileSystem()
|
||||
public void Destroy()
|
||||
{
|
||||
foreach (var fileSystem in FileSystems)
|
||||
{
|
||||
@@ -65,92 +65,7 @@ namespace YooAsset
|
||||
FileSystems.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求最新的资源版本
|
||||
/// </summary>
|
||||
RequestPackageVersionOperation IPlayMode.RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||
{
|
||||
var operation = new RequestPackageVersionImplOperation(this, options);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 向网络端请求并更新清单
|
||||
/// </summary>
|
||||
LoadPackageManifestOperation IPlayMode.LoadPackageManifestAsync(LoadPackageManifestOptions options)
|
||||
{
|
||||
var operation = new LoadPackageManifestOperation(this, options);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预下载指定版本的包裹内容
|
||||
/// </summary>
|
||||
PreDownloadContentOperation IPlayMode.PreDownloadContentAsync(PreDownloadContentOptions options)
|
||||
{
|
||||
var operation = new PreDownloadContentOperation(this, options);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
ClearCacheFilesOperation IPlayMode.ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
var operation = new ClearCacheFilesOperation(this, options);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 下载相关
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByAll(ActiveManifest);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByTags(ActiveManifest, tags);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> downloadList = GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 解压相关
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByAll(ActiveManifest);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> unpcakList = GetUnpackListByTags(ActiveManifest, tags);
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
// 导入相关
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> importerList = GetImporterListByFilePaths(ActiveManifest, filePaths);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
ResourceImporterOperation IPlayMode.CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> importerList = GetImporterListByFileInfos(ActiveManifest, fileInfos);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, importingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IBundleQuery接口
|
||||
#region 资源包相关
|
||||
private BundleInfo CreateBundleInfo(PackageBundle packageBundle)
|
||||
{
|
||||
if (packageBundle == null)
|
||||
@@ -165,7 +80,11 @@ namespace YooAsset
|
||||
|
||||
throw new YooFileSystemException($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
}
|
||||
BundleInfo IBundleQuery.GetMainBundleInfo(AssetInfo assetInfo)
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源包信息
|
||||
/// </summary>
|
||||
public BundleInfo GetMainBundleInfo(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo == null || assetInfo.IsInvalid)
|
||||
throw new YooInternalException();
|
||||
@@ -174,7 +93,21 @@ namespace YooAsset
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
|
||||
return CreateBundleInfo(packageBundle);
|
||||
}
|
||||
List<BundleInfo> IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源包名称
|
||||
/// </summary>
|
||||
public string GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取依赖的资源包信息集合
|
||||
/// </summary>
|
||||
public List<BundleInfo> GetDependBundleInfos(AssetInfo assetInfo)
|
||||
{
|
||||
if (assetInfo == null || assetInfo.IsInvalid)
|
||||
throw new YooInternalException();
|
||||
@@ -199,45 +132,50 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
string IBundleQuery.GetMainBundleName(int bundleID)
|
||||
{
|
||||
// 注意:如果清单里未找到资源包会抛出异常!
|
||||
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
|
||||
return packageBundle.BundleName;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取主文件系统
|
||||
/// 说明:文件系统列表里,最后一个属于主文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetMainFileSystem()
|
||||
#region 下载器相关
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(ResourceDownloaderOptions options)
|
||||
{
|
||||
int count = FileSystems.Count;
|
||||
if (count == 0)
|
||||
return null;
|
||||
return FileSystems[count - 1];
|
||||
List<BundleInfo> downloadList;
|
||||
if (options.Tags == null)
|
||||
downloadList = GetDownloadListByAll(ActiveManifest);
|
||||
else
|
||||
downloadList = GetDownloadListByTags(ActiveManifest, options.Tags);
|
||||
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(BundleDownloaderOptions options)
|
||||
{
|
||||
List<BundleInfo> downloadList;
|
||||
if (options.AssetInfos == null)
|
||||
downloadList = GetDownloadListByAll(ActiveManifest);
|
||||
else
|
||||
downloadList = GetDownloadListByAssetInfos(ActiveManifest, options.AssetInfos, options.DownloadBundleDependencies);
|
||||
|
||||
var operation = new ResourceDownloaderOperation(PackageName, downloadList, options.MaximumConcurrency, options.FailedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(ResourceUnpackerOptions options)
|
||||
{
|
||||
List<BundleInfo> unpcakList;
|
||||
if (options.Tags == null)
|
||||
unpcakList = GetUnpackListByAll(ActiveManifest);
|
||||
else
|
||||
unpcakList = GetUnpackListByTags(ActiveManifest, options.Tags);
|
||||
|
||||
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, options.MaximumConcurrency, options.FailedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
public ResourceImporterOperation CreateResourceImporter(BundleImporterOptions options)
|
||||
{
|
||||
List<BundleInfo> importerList = GetImporterListByBundleInfos(ActiveManifest, options.BundleInfos);
|
||||
var operation = new ResourceImporterOperation(PackageName, importerList, options.MaximumConcurrency, options.FailedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包所属文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetBelongFileSystem(PackageBundle packageBundle)
|
||||
{
|
||||
for (int i = 0; i < FileSystems.Count; i++)
|
||||
{
|
||||
IFileSystem fileSystem = FileSystems[i];
|
||||
if (fileSystem.Belong(packageBundle))
|
||||
{
|
||||
return fileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
return null;
|
||||
}
|
||||
|
||||
public List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||
internal List<BundleInfo> GetDownloadListByAll(PackageManifest manifest)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -257,7 +195,7 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||
internal List<BundleInfo> GetDownloadListByTags(PackageManifest manifest, string[] tags)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -290,7 +228,7 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetDownloadListByPaths(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDownload)
|
||||
internal List<BundleInfo> GetDownloadListByAssetInfos(PackageManifest manifest, AssetInfo[] assetInfos, bool recursiveDownload)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -365,7 +303,7 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||
internal List<BundleInfo> GetUnpackListByAll(PackageManifest manifest)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -385,7 +323,7 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
||||
internal List<BundleInfo> GetUnpackListByTags(PackageManifest manifest, string[] tags)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -408,22 +346,7 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<BundleInfo> GetImporterListByFilePaths(PackageManifest manifest, string[] filePaths)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
|
||||
ImportFileInfo[] fileInfos = new ImportFileInfo[filePaths.Length];
|
||||
for (int i = 0; i < filePaths.Length; i++)
|
||||
{
|
||||
ImportFileInfo fileInfo = new ImportFileInfo();
|
||||
fileInfo.FilePath = filePaths[i];
|
||||
fileInfos[i] = fileInfo;
|
||||
}
|
||||
|
||||
return GetImporterListByFileInfos(manifest, fileInfos);
|
||||
}
|
||||
public List<BundleInfo> GetImporterListByFileInfos(PackageManifest manifest, ImportFileInfo[] fileInfos)
|
||||
internal List<BundleInfo> GetImporterListByBundleInfos(PackageManifest manifest, ImportBundleInfo[] fileInfos)
|
||||
{
|
||||
if (manifest == null)
|
||||
return new List<BundleInfo>();
|
||||
@@ -477,5 +400,36 @@ namespace YooAsset
|
||||
}
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 获取主文件系统
|
||||
/// 说明:文件系统列表里,最后一个属于主文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetMainFileSystem()
|
||||
{
|
||||
int count = FileSystems.Count;
|
||||
if (count == 0)
|
||||
return null;
|
||||
return FileSystems[count - 1];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包所属文件系统
|
||||
/// </summary>
|
||||
public IFileSystem GetBelongFileSystem(PackageBundle packageBundle)
|
||||
{
|
||||
for (int i = 0; i < FileSystems.Count; i++)
|
||||
{
|
||||
IFileSystem fileSystem = FileSystems[i];
|
||||
if (fileSystem.Belong(packageBundle))
|
||||
{
|
||||
return fileSystem;
|
||||
}
|
||||
}
|
||||
|
||||
YooLogger.Error($"Can not found belong file system : {packageBundle.BundleName}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7f5776546411834d9ed949d54a6f241
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,23 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface IBundleQuery
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取主资源包信息
|
||||
/// </summary>
|
||||
BundleInfo GetMainBundleInfo(AssetInfo assetInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 获取依赖的资源包信息集合
|
||||
/// </summary>
|
||||
List<BundleInfo> GetDependBundleInfos(AssetInfo assetPath);
|
||||
|
||||
/// <summary>
|
||||
/// 获取主资源包名称
|
||||
/// </summary>
|
||||
string GetMainBundleName(int bundleID);
|
||||
}
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal interface IPlayMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前激活的清单
|
||||
/// </summary>
|
||||
PackageManifest ActiveManifest { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 销毁文件系统
|
||||
/// </summary>
|
||||
void DestroyFileSystem();
|
||||
|
||||
/// <summary>
|
||||
/// 请求最新的资源版本
|
||||
/// </summary>
|
||||
RequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// 请求并加载资源清单
|
||||
/// </summary>
|
||||
LoadPackageManifestOperation LoadPackageManifestAsync(LoadPackageManifestOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// 预下载指定版本的包裹内容
|
||||
/// </summary>
|
||||
PreDownloadContentOperation PreDownloadContentAsync(PreDownloadContentOptions options);
|
||||
|
||||
/// <summary>
|
||||
/// 清理缓存文件
|
||||
/// </summary>
|
||||
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
|
||||
|
||||
// 下载相关
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain);
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain);
|
||||
ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain);
|
||||
|
||||
// 解压相关
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain);
|
||||
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain);
|
||||
|
||||
// 导入相关
|
||||
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain);
|
||||
ResourceImporterOperation CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain);
|
||||
}
|
||||
}
|
||||
@@ -14,15 +14,15 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly FileSystemHost _host;
|
||||
private readonly ClearCacheFilesOptions _options;
|
||||
private List<IFileSystem> _cloneList;
|
||||
private FSClearCacheFilesOperation _clearCacheFilesOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal ClearCacheFilesOperation(PlayModeImpl impl, ClearCacheFilesOptions options)
|
||||
internal ClearCacheFilesOperation(FileSystemHost host, ClearCacheFilesOptions options)
|
||||
{
|
||||
_impl = impl;
|
||||
_host = host;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -36,7 +36,7 @@ namespace YooAsset
|
||||
|
||||
if (_steps == ESteps.Prepare)
|
||||
{
|
||||
var fileSytems = _impl.FileSystems;
|
||||
var fileSytems = _host.FileSystems;
|
||||
if (fileSytems == null || fileSytems.Count == 0)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -72,7 +72,7 @@ namespace YooAsset
|
||||
var fileSystem = _cloneList[0];
|
||||
_cloneList.RemoveAt(0);
|
||||
|
||||
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_impl.ActiveManifest, _options);
|
||||
_clearCacheFilesOp = fileSystem.ClearCacheFilesAsync(_options);
|
||||
_clearCacheFilesOp.StartOperation();
|
||||
AddChildOperation(_clearCacheFilesOp);
|
||||
_steps = ESteps.CheckClearResult;
|
||||
|
||||
@@ -13,20 +13,28 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public object ClearParam { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单
|
||||
/// </summary>
|
||||
internal PackageManifest Manifest { set; get; }
|
||||
|
||||
public ClearCacheFilesOptions(EFileClearMode clearMode)
|
||||
{
|
||||
ClearMode = clearMode.ToString();
|
||||
ClearParam = null;
|
||||
Manifest = null;
|
||||
}
|
||||
public ClearCacheFilesOptions(EFileClearMode clearMode, object clearParam)
|
||||
{
|
||||
ClearMode = clearMode.ToString();
|
||||
ClearParam = clearParam;
|
||||
Manifest = null;
|
||||
}
|
||||
public ClearCacheFilesOptions(string clearMode, object clearParam)
|
||||
{
|
||||
ClearMode = clearMode;
|
||||
ClearParam = clearParam;
|
||||
Manifest = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 下载器结束
|
||||
/// </summary>
|
||||
public struct DownloaderFinishData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool Succeed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的更新数据
|
||||
/// </summary>
|
||||
public struct DownloadUpdateData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度 (0-1f)
|
||||
/// </summary>
|
||||
public float Progress;
|
||||
|
||||
/// <summary>
|
||||
/// 下载文件总数
|
||||
/// </summary>
|
||||
public int TotalDownloadCount;
|
||||
|
||||
/// <summary>
|
||||
/// 当前完成的下载文件数量
|
||||
/// </summary>
|
||||
public int CurrentDownloadCount;
|
||||
|
||||
/// <summary>
|
||||
/// 下载数据总大小(单位:字节)
|
||||
/// </summary>
|
||||
public long TotalDownloadBytes;
|
||||
|
||||
/// <summary>
|
||||
/// 当前完成的下载数据大小(单位:字节)
|
||||
/// </summary>
|
||||
public long CurrentDownloadBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的错误数据
|
||||
/// </summary>
|
||||
public struct DownloadErrorData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 下载失败的文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的文件数据
|
||||
/// </summary>
|
||||
public struct DownloadFileData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0a798eb87a00a284189bb69a767d2c02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -3,107 +3,6 @@ using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
#region 下载器相关类型定义
|
||||
/// <summary>
|
||||
/// 下载器结束
|
||||
/// </summary>
|
||||
public struct DownloaderFinishData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool Succeed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的更新数据
|
||||
/// </summary>
|
||||
public struct DownloadUpdateData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 下载进度 (0-1f)
|
||||
/// </summary>
|
||||
public float Progress;
|
||||
|
||||
/// <summary>
|
||||
/// 下载文件总数
|
||||
/// </summary>
|
||||
public int TotalDownloadCount;
|
||||
|
||||
/// <summary>
|
||||
/// 当前完成的下载文件数量
|
||||
/// </summary>
|
||||
public int CurrentDownloadCount;
|
||||
|
||||
/// <summary>
|
||||
/// 下载数据总大小(单位:字节)
|
||||
/// </summary>
|
||||
public long TotalDownloadBytes;
|
||||
|
||||
/// <summary>
|
||||
/// 当前完成的下载数据大小(单位:字节)
|
||||
/// </summary>
|
||||
public long CurrentDownloadBytes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的错误数据
|
||||
/// </summary>
|
||||
public struct DownloadErrorData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 下载失败的文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载器相关的文件数据
|
||||
/// </summary>
|
||||
public struct DownloadFileData
|
||||
{
|
||||
/// <summary>
|
||||
/// 所属包裹名称
|
||||
/// </summary>
|
||||
public string PackageName;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件名称
|
||||
/// </summary>
|
||||
public string FileName;
|
||||
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public long FileSize;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public abstract class DownloaderOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
@@ -140,7 +39,7 @@ namespace YooAsset
|
||||
#endregion
|
||||
|
||||
private readonly string _packageName;
|
||||
private readonly int _downloadingMaxNumber;
|
||||
private readonly int _maximumConcurrency;
|
||||
private readonly int _failedTryAgain;
|
||||
private readonly List<BundleInfo> _bundleInfoList;
|
||||
private readonly List<FSDownloadFileOperation> _downloaders = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT);
|
||||
@@ -203,11 +102,11 @@ namespace YooAsset
|
||||
public DownloadFileBegin DownloadFileBeginCallback { set; get; }
|
||||
|
||||
|
||||
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
_packageName = packageName;
|
||||
_bundleInfoList = downloadList;
|
||||
_downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ;
|
||||
_maximumConcurrency = UnityEngine.Mathf.Clamp(maximumConcurrency, 1, MAX_LOADER_COUNT); ;
|
||||
_failedTryAgain = failedTryAgain;
|
||||
|
||||
// 统计下载信息
|
||||
@@ -321,11 +220,11 @@ namespace YooAsset
|
||||
if (_isPause)
|
||||
return;
|
||||
|
||||
if (_downloaders.Count < _downloadingMaxNumber)
|
||||
if (_downloaders.Count < _maximumConcurrency)
|
||||
{
|
||||
int index = _bundleInfoList.Count - 1;
|
||||
var bundleInfo = _bundleInfoList[index];
|
||||
var downloader = bundleInfo.CreateDownloader(_failedTryAgain);
|
||||
var downloader = bundleInfo.CreateBundleDownloader(_failedTryAgain);
|
||||
downloader.StartOperation();
|
||||
this.AddChildOperation(downloader);
|
||||
|
||||
@@ -502,25 +401,25 @@ namespace YooAsset
|
||||
|
||||
public sealed class ResourceDownloaderOperation : DownloaderOperation
|
||||
{
|
||||
internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int maximumConcurrency, int failedTryAgain)
|
||||
: base(packageName, downloadList, maximumConcurrency, failedTryAgain)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建空的下载器
|
||||
/// </summary>
|
||||
internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int downloadingMaxNumber, int failedTryAgain)
|
||||
internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
List<BundleInfo> downloadList = new List<BundleInfo>();
|
||||
var operation = new ResourceDownloaderOperation(packageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
var operation = new ResourceDownloaderOperation(packageName, downloadList, maximumConcurrency, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
public sealed class ResourceUnpackerOperation : DownloaderOperation
|
||||
{
|
||||
internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int maximumConcurrency, int failedTryAgain)
|
||||
: base(packageName, downloadList, maximumConcurrency, failedTryAgain)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -536,8 +435,8 @@ namespace YooAsset
|
||||
}
|
||||
public sealed class ResourceImporterOperation : DownloaderOperation
|
||||
{
|
||||
internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
|
||||
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
|
||||
internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int maximumConcurrency, int failedTryAgain)
|
||||
: base(packageName, downloadList, maximumConcurrency, failedTryAgain)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源下载选项
|
||||
/// </summary>
|
||||
public struct BundleDownloaderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 最大并发数量
|
||||
/// </summary>
|
||||
public int MaximumConcurrency { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败后的重试次数
|
||||
/// </summary>
|
||||
public int FailedTryAgain { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 下载资源对象所属资源包内所有资源对象依赖的资源包
|
||||
/// </summary>
|
||||
public bool DownloadBundleDependencies { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源信息列表
|
||||
/// 说明:如果列表为NULL,则下载所有资产
|
||||
/// </summary>
|
||||
public AssetInfo[] AssetInfos { private set; get; }
|
||||
|
||||
public BundleDownloaderOptions(AssetInfo assetInfo, bool downloadDependencies, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
AssetInfos = new AssetInfo[] { assetInfo };
|
||||
DownloadBundleDependencies = downloadDependencies;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
public BundleDownloaderOptions(AssetInfo[] assetInfos, bool downloadDependencies, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
AssetInfos = assetInfos;
|
||||
DownloadBundleDependencies = downloadDependencies;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源下载选项
|
||||
/// </summary>
|
||||
public struct ResourceDownloaderOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 最大并发数量
|
||||
/// </summary>
|
||||
public int MaximumConcurrency { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败后的重试次数
|
||||
/// </summary>
|
||||
public int FailedTryAgain { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源标签列表
|
||||
/// 说明:如果列表为NULL,则下载所有资产
|
||||
/// </summary>
|
||||
public string[] Tags { private set; get; }
|
||||
|
||||
public ResourceDownloaderOptions(int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = null;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
public ResourceDownloaderOptions(string tag, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = new string[] { tag };
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
public ResourceDownloaderOptions(string[] tags, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = tags;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源解压选项
|
||||
/// </summary>
|
||||
public struct ResourceUnpackerOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 最大并发数量
|
||||
/// </summary>
|
||||
public int MaximumConcurrency { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败后的重试次数
|
||||
/// </summary>
|
||||
public int FailedTryAgain { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源标签列表
|
||||
/// 说明:如果列表为NULL,则解压所有资产
|
||||
/// </summary>
|
||||
public string[] Tags { private set; get; }
|
||||
|
||||
public ResourceUnpackerOptions(int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = null;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
public ResourceUnpackerOptions(string tag, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = new string[] { tag };
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
public ResourceUnpackerOptions(string[] tags, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
Tags = tags;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 资源导入选项
|
||||
/// </summary>
|
||||
public struct BundleImporterOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 最大并发数量
|
||||
/// </summary>
|
||||
public int MaximumConcurrency { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 失败后的重试次数
|
||||
/// </summary>
|
||||
public int FailedTryAgain { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源包信息列表
|
||||
/// </summary>
|
||||
public ImportBundleInfo[] BundleInfos { private set; get; }
|
||||
|
||||
public BundleImporterOptions(ImportBundleInfo[] bundleInfos, int maximumConcurrency, int failedTryAgain)
|
||||
{
|
||||
BundleInfos = bundleInfos;
|
||||
MaximumConcurrency = maximumConcurrency;
|
||||
FailedTryAgain = failedTryAgain;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2567b73a071bdc14884214cb5e3b5cc0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,7 +17,7 @@ namespace YooAsset
|
||||
|
||||
private readonly ResourcePackage _package;
|
||||
private readonly InitializePackageOptions _options;
|
||||
private PlayModeImpl _playModeImpl;
|
||||
private FileSystemHost _fileSystemHost;
|
||||
private InitializeFileSystemOperation _initializeFileSystemOp;
|
||||
private EPlayMode _playMode;
|
||||
private ESteps _steps = ESteps.None;
|
||||
@@ -118,12 +118,11 @@ namespace YooAsset
|
||||
{
|
||||
string packageName = _package.PackageName;
|
||||
var resourceManager = new ResourceManager(packageName);
|
||||
var playModeImpl = new PlayModeImpl(packageName);
|
||||
resourceManager.Initialize(_options, playModeImpl);
|
||||
var fileSystemHost = new FileSystemHost(packageName);
|
||||
resourceManager.Initialize(_options, fileSystemHost);
|
||||
|
||||
_playModeImpl = playModeImpl;
|
||||
_package._bundleQuery = playModeImpl;
|
||||
_package._playModeImpl = playModeImpl;
|
||||
_fileSystemHost = fileSystemHost;
|
||||
_package._fileSystemHost = fileSystemHost;
|
||||
_package._resourceManager = resourceManager;
|
||||
_steps = ESteps.InitFileSystem;
|
||||
}
|
||||
@@ -135,27 +134,27 @@ namespace YooAsset
|
||||
if (_playMode == EPlayMode.EditorSimulateMode)
|
||||
{
|
||||
var initializeParameters = _options as EditorSimulateModeOptions;
|
||||
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.EditorFileSystemParameters);
|
||||
_initializeFileSystemOp = _fileSystemHost.InitializeAsync(initializeParameters.EditorFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.OfflinePlayMode)
|
||||
{
|
||||
var initializeParameters = _options as OfflinePlayModeOptions;
|
||||
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
||||
_initializeFileSystemOp = _fileSystemHost.InitializeAsync(initializeParameters.BuildinFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.HostPlayMode)
|
||||
{
|
||||
var initializeParameters = _options as HostPlayModeOptions;
|
||||
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||
_initializeFileSystemOp = _fileSystemHost.InitializeAsync(initializeParameters.BuildinFileSystemParameters, initializeParameters.CacheFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.WebPlayMode)
|
||||
{
|
||||
var initializeParameters = _options as WebPlayModeOptions;
|
||||
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
|
||||
_initializeFileSystemOp = _fileSystemHost.InitializeAsync(initializeParameters.WebServerFileSystemParameters, initializeParameters.WebRemoteFileSystemParameters);
|
||||
}
|
||||
else if (_playMode == EPlayMode.CustomPlayMode)
|
||||
{
|
||||
var initializeParameters = _options as CustomPlayModeOptions;
|
||||
_initializeFileSystemOp = _playModeImpl.InitializeAsync(initializeParameters.FileSystemParameterList);
|
||||
_initializeFileSystemOp = _fileSystemHost.InitializeAsync(initializeParameters.FileSystemParameterList);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace YooAsset
|
||||
|
||||
// 读取文件标记
|
||||
uint fileSign = _buffer.ReadUInt32();
|
||||
if (fileSign != ManifestDefine.FileSign)
|
||||
if (fileSign != PackageManifestDefine.FileSign)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Failed;
|
||||
@@ -85,8 +85,8 @@ namespace YooAsset
|
||||
// 读取文件版本
|
||||
string fileVersion = _buffer.ReadUTF8();
|
||||
Version fileVer = new Version(fileVersion);
|
||||
Version ver2025_8_28 = new Version(ManifestDefine.VERSION_2025_8_28);
|
||||
Version ver2025_9_30 = new Version(ManifestDefine.VERSION_2025_9_30);
|
||||
Version ver2025_8_28 = new Version(PackageManifestDefine.VERSION_2025_8_28);
|
||||
Version ver2025_9_30 = new Version(PackageManifestDefine.VERSION_2025_9_30);
|
||||
if (fileVer < ver2025_8_28)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
|
||||
@@ -14,15 +14,15 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly FileSystemHost _host;
|
||||
private readonly List<FileSystemParameters> _parametersList;
|
||||
private List<FileSystemParameters> _cloneList;
|
||||
private FSInitializeFileSystemOperation _initFileSystemOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal InitializeFileSystemOperation(PlayModeImpl impl, List<FileSystemParameters> parametersList)
|
||||
internal InitializeFileSystemOperation(FileSystemHost host, List<FileSystemParameters> parametersList)
|
||||
{
|
||||
_impl = impl;
|
||||
_host = host;
|
||||
_parametersList = parametersList;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -71,7 +71,7 @@ namespace YooAsset
|
||||
var fileSystemParams = _cloneList[0];
|
||||
_cloneList.RemoveAt(0);
|
||||
|
||||
IFileSystem fileSystemInstance = fileSystemParams.CreateFileSystem(_impl.PackageName);
|
||||
IFileSystem fileSystemInstance = fileSystemParams.CreateFileSystem(_host.PackageName);
|
||||
if (fileSystemInstance == null)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
@@ -80,7 +80,7 @@ namespace YooAsset
|
||||
return;
|
||||
}
|
||||
|
||||
_impl.FileSystems.Add(fileSystemInstance);
|
||||
_host.FileSystems.Add(fileSystemInstance);
|
||||
_initFileSystemOp = fileSystemInstance.InitializeFileSystemAsync();
|
||||
_initFileSystemOp.StartOperation();
|
||||
AddChildOperation(_initFileSystemOp);
|
||||
|
||||
@@ -12,14 +12,14 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly FileSystemHost _host;
|
||||
private readonly LoadPackageManifestOptions _options;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal LoadPackageManifestOperation(PlayModeImpl impl, LoadPackageManifestOptions options)
|
||||
internal LoadPackageManifestOperation(FileSystemHost host, LoadPackageManifestOptions options)
|
||||
{
|
||||
_impl = impl;
|
||||
_host = host;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -48,7 +48,7 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CheckActiveManifest)
|
||||
{
|
||||
// 检测当前激活的清单对象
|
||||
if (_impl.ActiveManifest != null && _impl.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||
if (_host.ActiveManifest != null && _host.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
@@ -63,7 +63,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
{
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
var mainFileSystem = _host.GetMainFileSystem();
|
||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(_options);
|
||||
_loadPackageManifestOp.StartOperation();
|
||||
AddChildOperation(_loadPackageManifestOp);
|
||||
@@ -76,7 +76,7 @@ namespace YooAsset
|
||||
if (_loadPackageManifestOp.Status == EOperationStatus.Succeed)
|
||||
{
|
||||
_steps = ESteps.Done;
|
||||
_impl.ActiveManifest = _loadPackageManifestOp.Manifest;
|
||||
_host.ActiveManifest = _loadPackageManifestOp.Manifest;
|
||||
Status = EOperationStatus.Succeed;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly FileSystemHost _host;
|
||||
private readonly PreDownloadContentOptions _options;
|
||||
private readonly int _timeout;
|
||||
private FSLoadPackageManifestOperation _loadPackageManifestOp;
|
||||
@@ -23,9 +23,9 @@ namespace YooAsset
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
|
||||
internal PreDownloadContentOperation(PlayModeImpl impl, PreDownloadContentOptions options)
|
||||
internal PreDownloadContentOperation(FileSystemHost host, PreDownloadContentOptions options)
|
||||
{
|
||||
_impl = impl;
|
||||
_host = host;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -53,11 +53,11 @@ namespace YooAsset
|
||||
if (_steps == ESteps.CheckActiveManifest)
|
||||
{
|
||||
// 检测当前激活的清单对象
|
||||
if (_impl.ActiveManifest != null)
|
||||
if (_host.ActiveManifest != null)
|
||||
{
|
||||
if (_impl.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||
if (_host.ActiveManifest.PackageVersion == _options.PackageVersion)
|
||||
{
|
||||
_manifest = _impl.ActiveManifest;
|
||||
_manifest = _host.ActiveManifest;
|
||||
_steps = ESteps.Done;
|
||||
Status = EOperationStatus.Succeed;
|
||||
return;
|
||||
@@ -70,7 +70,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_loadPackageManifestOp == null)
|
||||
{
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
var mainFileSystem = _host.GetMainFileSystem();
|
||||
var options = new LoadPackageManifestOptions(_options.PackageVersion, _options.Timeout);
|
||||
_loadPackageManifestOp = mainFileSystem.LoadPackageManifestAsync(options);
|
||||
_loadPackageManifestOp.StartOperation();
|
||||
@@ -106,11 +106,11 @@ namespace YooAsset
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = _host.GetDownloadListByAll(_manifest);
|
||||
var operation = new ResourceDownloaderOperation(_host.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -125,11 +125,11 @@ namespace YooAsset
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = _host.GetDownloadListByTags(_manifest, new string[] { tag });
|
||||
var operation = new ResourceDownloaderOperation(_host.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -144,11 +144,11 @@ namespace YooAsset
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = _host.GetDownloadListByTags(_manifest, tags);
|
||||
var operation = new ResourceDownloaderOperation(_host.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -163,15 +163,15 @@ namespace YooAsset
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
List<AssetInfo> assetInfos = new List<AssetInfo>();
|
||||
var assetInfo = _manifest.ConvertLocationToAssetInfo(location, null);
|
||||
assetInfos.Add(assetInfo);
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = _host.GetDownloadListByAssetInfos(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_host.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace YooAsset
|
||||
if (Status != EOperationStatus.Succeed)
|
||||
{
|
||||
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
return ResourceDownloaderOperation.CreateEmptyDownloader(_host.PackageName, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
|
||||
@@ -196,8 +196,8 @@ namespace YooAsset
|
||||
assetInfos.Add(assetInfo);
|
||||
}
|
||||
|
||||
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
List<BundleInfo> downloadList = _host.GetDownloadListByAssetInfos(_manifest, assetInfos.ToArray(), recursiveDownload);
|
||||
var operation = new ResourceDownloaderOperation(_host.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
|
||||
return operation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public abstract class RequestPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前最新的包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { protected set; get; }
|
||||
}
|
||||
internal sealed class RequestPackageVersionImplOperation : RequestPackageVersionOperation
|
||||
public sealed class RequestPackageVersionOperation : AsyncOperationBase
|
||||
{
|
||||
private enum ESteps
|
||||
{
|
||||
@@ -17,14 +10,20 @@ namespace YooAsset
|
||||
Done,
|
||||
}
|
||||
|
||||
private readonly PlayModeImpl _impl;
|
||||
private readonly FileSystemHost _host;
|
||||
private readonly RequestPackageVersionOptions _options;
|
||||
private FSRequestPackageVersionOperation _requestPackageVersionOp;
|
||||
private ESteps _steps = ESteps.None;
|
||||
|
||||
internal RequestPackageVersionImplOperation(PlayModeImpl impl, RequestPackageVersionOptions options)
|
||||
/// <summary>
|
||||
/// 当前最新的包裹版本
|
||||
/// </summary>
|
||||
public string PackageVersion { private set; get; }
|
||||
|
||||
|
||||
internal RequestPackageVersionOperation(FileSystemHost host, RequestPackageVersionOptions options)
|
||||
{
|
||||
_impl = impl;
|
||||
_host = host;
|
||||
_options = options;
|
||||
}
|
||||
internal override void InternalStart()
|
||||
@@ -40,7 +39,7 @@ namespace YooAsset
|
||||
{
|
||||
if (_requestPackageVersionOp == null)
|
||||
{
|
||||
var mainFileSystem = _impl.GetMainFileSystem();
|
||||
var mainFileSystem = _host.GetMainFileSystem();
|
||||
_requestPackageVersionOp = mainFileSystem.RequestPackageVersionAsync(_options);
|
||||
_requestPackageVersionOp.StartOperation();
|
||||
AddChildOperation(_requestPackageVersionOp);
|
||||
|
||||
@@ -122,8 +122,8 @@ namespace YooAsset
|
||||
{
|
||||
_mainfest = manifest;
|
||||
_bundleType = manifest.BuildBundleType;
|
||||
_fileExtension = ManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||
_fileName = ManifestTools.GetRemoteBundleFileName(manifest.OutputNameStyle, BundleName, _fileExtension, FileHash);
|
||||
_fileExtension = PackageManifestTools.GetRemoteBundleFileExtension(BundleName);
|
||||
_fileName = PackageManifestTools.GetRemoteBundleFileName(manifest.OutputNameStyle, BundleName, _fileExtension, FileHash);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public class ManifestDefine
|
||||
internal class PackageManifestDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件极限大小(100MB)
|
||||
@@ -6,7 +6,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
internal static class ManifestTools
|
||||
internal static class PackageManifestTools
|
||||
{
|
||||
/// <summary>
|
||||
/// 验证清单文件的二进制数据
|
||||
@@ -49,10 +49,10 @@ namespace YooAsset
|
||||
using (FileStream fs = new FileStream(savePath, FileMode.Create))
|
||||
{
|
||||
// 创建缓存器
|
||||
BufferWriter buffer = new BufferWriter(ManifestDefine.FileMaxSize);
|
||||
BufferWriter buffer = new BufferWriter(PackageManifestDefine.FileMaxSize);
|
||||
|
||||
// 写入文件标记
|
||||
buffer.WriteUInt32(ManifestDefine.FileSign);
|
||||
buffer.WriteUInt32(PackageManifestDefine.FileSign);
|
||||
|
||||
// 写入文件版本
|
||||
buffer.WriteUTF8(manifest.FileVersion);
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e9d6cb1ce5d510645866ad7c122abfab
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -10,8 +10,7 @@ namespace YooAsset
|
||||
{
|
||||
private InitializePackageOperation _initializeOp;
|
||||
internal ResourceManager _resourceManager;
|
||||
internal IBundleQuery _bundleQuery;
|
||||
internal IPlayMode _playModeImpl;
|
||||
internal FileSystemHost _fileSystemHost;
|
||||
internal EPlayMode _playMode;
|
||||
|
||||
/// <summary>
|
||||
@@ -39,9 +38,9 @@ namespace YooAsset
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_playModeImpl == null)
|
||||
if (_fileSystemHost == null)
|
||||
return false;
|
||||
return _playModeImpl.ActiveManifest != null;
|
||||
return _fileSystemHost.ActiveManifest != null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +65,6 @@ namespace YooAsset
|
||||
internal void InternalDestroy()
|
||||
{
|
||||
_initializeOp = null;
|
||||
_bundleQuery = null;
|
||||
|
||||
// 销毁资源管理器
|
||||
if (_resourceManager != null)
|
||||
@@ -75,11 +73,11 @@ namespace YooAsset
|
||||
_resourceManager = null;
|
||||
}
|
||||
|
||||
// 销毁文件系统
|
||||
if (_playModeImpl != null)
|
||||
// 销毁文件系统中枢
|
||||
if (_fileSystemHost != null)
|
||||
{
|
||||
_playModeImpl.DestroyFileSystem();
|
||||
_playModeImpl = null;
|
||||
_fileSystemHost.Destroy();
|
||||
_fileSystemHost = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,7 +133,7 @@ namespace YooAsset
|
||||
public RequestPackageVersionOperation RequestPackageVersionAsync(RequestPackageVersionOptions options)
|
||||
{
|
||||
DebugCheckInitialize(false);
|
||||
var operation = _playModeImpl.RequestPackageVersionAsync(options);
|
||||
var operation = new RequestPackageVersionOperation(_fileSystemHost, options);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -153,7 +151,7 @@ namespace YooAsset
|
||||
YooLogger.Warning($"Found loaded bundle before update manifest ! Recommended to call the {nameof(UnloadAllAssetsAsync)} method to release loaded bundle !");
|
||||
}
|
||||
|
||||
var operation = _playModeImpl.LoadPackageManifestAsync(options);
|
||||
var operation = new LoadPackageManifestOperation(_fileSystemHost, options);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -164,7 +162,7 @@ namespace YooAsset
|
||||
public PreDownloadContentOperation PreDownloadContentAsync(PreDownloadContentOptions options)
|
||||
{
|
||||
DebugCheckInitialize(false);
|
||||
var operation = _playModeImpl.PreDownloadContentAsync(options);
|
||||
var operation = new PreDownloadContentOperation(_fileSystemHost, options);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -175,7 +173,8 @@ namespace YooAsset
|
||||
public ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options)
|
||||
{
|
||||
DebugCheckInitialize(false);
|
||||
var operation = _playModeImpl.ClearCacheFilesAsync(options);
|
||||
options.Manifest = _fileSystemHost.ActiveManifest;
|
||||
var operation = new ClearCacheFilesOperation(_fileSystemHost, options);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -188,7 +187,7 @@ namespace YooAsset
|
||||
public string GetPackageVersion()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.PackageVersion;
|
||||
return _fileSystemHost.ActiveManifest.PackageVersion;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -197,7 +196,7 @@ namespace YooAsset
|
||||
public string GetPackageNote()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.PackageNote;
|
||||
return _fileSystemHost.ActiveManifest.PackageNote;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -206,7 +205,7 @@ namespace YooAsset
|
||||
public PackageDetails GetPackageDetails()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetPackageDetails();
|
||||
return _fileSystemHost.ActiveManifest.GetPackageDetails();
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -216,7 +215,7 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public UnloadAllAssetsOperation UnloadAllAssetsAsync()
|
||||
{
|
||||
var options = new UnloadAllAssetsOptions();
|
||||
var options = new UnloadAllAssetsOptions(true, true);
|
||||
return UnloadAllAssetsAsync(options);
|
||||
}
|
||||
|
||||
@@ -235,12 +234,22 @@ namespace YooAsset
|
||||
/// <summary>
|
||||
/// 回收不再使用的资源
|
||||
/// 说明:卸载引用计数为零的资源
|
||||
/// 说明:默认循环10次
|
||||
/// </summary>
|
||||
/// <param name="loopCount">循环迭代次数</param>
|
||||
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync(int loopCount = 10)
|
||||
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync()
|
||||
{
|
||||
var options = new UnloadUnusedAssetsOptions(10);
|
||||
return UnloadUnusedAssetsAsync(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回收不再使用的资源
|
||||
/// 说明:卸载引用计数为零的资源
|
||||
/// </summary>
|
||||
public UnloadUnusedAssetsOperation UnloadUnusedAssetsAsync(UnloadUnusedAssetsOptions options)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var operation = new UnloadUnusedAssetsOperation(_resourceManager, loopCount);
|
||||
var operation = new UnloadUnusedAssetsOperation(_resourceManager, options);
|
||||
OperationSystem.StartOperation(PackageName, operation);
|
||||
return operation;
|
||||
}
|
||||
@@ -295,7 +304,7 @@ namespace YooAsset
|
||||
public AssetInfo[] GetAllAssetInfos()
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetAllAssetInfos();
|
||||
return _fileSystemHost.ActiveManifest.GetAllAssetInfos();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -306,7 +315,7 @@ namespace YooAsset
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string[] tags = new string[] { tag };
|
||||
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
return _fileSystemHost.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -316,7 +325,7 @@ namespace YooAsset
|
||||
public AssetInfo[] GetAssetInfos(string[] tags)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
return _fileSystemHost.ActiveManifest.GetAssetInfosByTags(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -368,7 +377,7 @@ namespace YooAsset
|
||||
public bool CheckLocationValid(string location)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
string assetPath = _playModeImpl.ActiveManifest.TryMappingToAssetPath(location);
|
||||
string assetPath = _fileSystemHost.ActiveManifest.TryMappingToAssetPath(location);
|
||||
return string.IsNullOrEmpty(assetPath) == false;
|
||||
}
|
||||
|
||||
@@ -380,11 +389,11 @@ namespace YooAsset
|
||||
return false;
|
||||
}
|
||||
|
||||
BundleInfo bundleInfo = _bundleQuery.GetMainBundleInfo(assetInfo);
|
||||
BundleInfo bundleInfo = _fileSystemHost.GetMainBundleInfo(assetInfo);
|
||||
if (bundleInfo.IsNeedDownloadFromRemote())
|
||||
return true;
|
||||
|
||||
List<BundleInfo> depends = _bundleQuery.GetDependBundleInfos(assetInfo);
|
||||
List<BundleInfo> depends = _fileSystemHost.GetDependBundleInfos(assetInfo);
|
||||
foreach (var depend in depends)
|
||||
{
|
||||
if (depend.IsNeedDownloadFromRemote())
|
||||
@@ -849,192 +858,55 @@ namespace YooAsset
|
||||
#endregion
|
||||
|
||||
#region 资源下载
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
public ResourceDownloaderOperation CreateResourceDownloader(ResourceDownloaderOptions options)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
|
||||
return _fileSystemHost.CreateResourceDownloader(options);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// 创建资源下载器,用于下载指定的资源信息列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(BundleDownloaderOptions options)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
var assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
|
||||
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="locations">资源的定位地址列表</param>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
|
||||
foreach (var location in locations)
|
||||
{
|
||||
var assetInfo = ConvertLocationToAssetInfo(location, null);
|
||||
assetInfos.Add(assetInfo);
|
||||
}
|
||||
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
|
||||
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源列表依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfos">资源信息列表</param>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain);
|
||||
return _fileSystemHost.CreateResourceDownloader(options);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源解压
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压指定的资源标签关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
public ResourceUnpackerOperation CreateResourceUnpacker(ResourceUnpackerOptions options)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
|
||||
return _fileSystemHost.CreateResourceUnpacker(options);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源导入
|
||||
/// <summary>
|
||||
/// 创建资源导入器
|
||||
/// 注意:资源文件名称必须和资源服务器部署的文件名称一致!
|
||||
/// </summary>
|
||||
/// <param name="filePaths">资源路径列表</param>
|
||||
/// <param name="importerMaxNumber">同时导入的最大文件数</param>
|
||||
/// <param name="failedTryAgain">导入失败的重试次数</param>
|
||||
public ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
|
||||
public ResourceImporterOperation CreateResourceImporter(BundleImporterOptions options)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceImporterByFilePaths(filePaths, importerMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源导入器
|
||||
/// 注意:资源信息里需要指定BundleName或BundleGUID!
|
||||
/// </summary>
|
||||
/// <param name="fileInfos">资源信息列表</param>
|
||||
/// <param name="importerMaxNumber">同时导入的最大文件数</param>
|
||||
/// <param name="failedTryAgain">导入失败的重试次数</param>
|
||||
public ResourceImporterOperation CreateResourceImporter(ImportFileInfo[] fileInfos, int importerMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckInitialize();
|
||||
return _playModeImpl.CreateResourceImporterByFileInfos(fileInfos, importerMaxNumber, failedTryAgain);
|
||||
return _fileSystemHost.CreateResourceImporter(options);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 内部方法
|
||||
private AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||
internal AssetInfo ConvertLocationToAssetInfo(string location, System.Type assetType)
|
||||
{
|
||||
return _playModeImpl.ActiveManifest.ConvertLocationToAssetInfo(location, assetType);
|
||||
return _fileSystemHost.ActiveManifest.ConvertLocationToAssetInfo(location, assetType);
|
||||
}
|
||||
private AssetInfo ConvertAssetGUIDToAssetInfo(string assetGUID, System.Type assetType)
|
||||
internal AssetInfo ConvertAssetGUIDToAssetInfo(string assetGUID, System.Type assetType)
|
||||
{
|
||||
return _playModeImpl.ActiveManifest.ConvertAssetGUIDToAssetInfo(assetGUID, assetType);
|
||||
return _fileSystemHost.ActiveManifest.ConvertAssetGUIDToAssetInfo(assetGUID, assetType);
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -1060,7 +932,7 @@ namespace YooAsset
|
||||
|
||||
if (checkActiveManifest)
|
||||
{
|
||||
if (_playModeImpl.ActiveManifest == null)
|
||||
if (_fileSystemHost.ActiveManifest == null)
|
||||
throw new YooPackageException(PackageName, "Can not found active package manifest !");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using UnityEngine;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public struct DecryptFileInfo
|
||||
public struct DecryptBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
@@ -20,13 +20,8 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public uint FileLoadCRC;
|
||||
}
|
||||
public struct DecryptResult
|
||||
public struct DecryptAsyncResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包对象
|
||||
/// </summary>
|
||||
public AssetBundle Result;
|
||||
|
||||
/// <summary>
|
||||
/// 异步请求句柄
|
||||
/// </summary>
|
||||
@@ -38,18 +33,30 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public Stream ManagedStream;
|
||||
}
|
||||
public struct DecryptSyncResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包对象
|
||||
/// </summary>
|
||||
public AssetBundle Result;
|
||||
|
||||
public interface IDecryptionServices
|
||||
/// <summary>
|
||||
/// 托管流对象
|
||||
/// 注意:流对象在资源包对象释放的时候会自动释放
|
||||
/// </summary>
|
||||
public Stream ManagedStream;
|
||||
}
|
||||
public interface IBundleDecryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 同步方式获取解密的资源包
|
||||
/// </summary>
|
||||
DecryptResult LoadAssetBundle(DecryptFileInfo fileInfo);
|
||||
DecryptSyncResult LoadAssetBundleSync(DecryptBundleInfo bundleInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 异步方式获取解密的资源包
|
||||
/// </summary>
|
||||
DecryptResult LoadAssetBundleAsync(DecryptFileInfo fileInfo);
|
||||
DecryptAsyncResult LoadAssetBundleAsync(DecryptBundleInfo bundleInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 后备方式获取解密的资源包
|
||||
@@ -57,16 +64,45 @@ namespace YooAsset
|
||||
/// 说明:建议通过LoadFromMemory()方法加载资源包作为保底机制。
|
||||
/// issues : https://github.com/tuyoogame/YooAsset/issues/562
|
||||
/// </summary>
|
||||
DecryptResult LoadAssetBundleFallback(DecryptFileInfo fileInfo);
|
||||
DecryptSyncResult LoadAssetBundleFallback(DecryptBundleInfo bundleInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的字节数据
|
||||
/// </summary>
|
||||
byte[] ReadFileData(DecryptFileInfo fileInfo);
|
||||
byte[] ReadFileData(DecryptBundleInfo bundleInfo);
|
||||
|
||||
/// <summary>
|
||||
/// 获取解密的文本数据
|
||||
/// </summary>
|
||||
string ReadFileText(DecryptFileInfo fileInfo);
|
||||
string ReadFileText(DecryptBundleInfo bundleInfo);
|
||||
}
|
||||
|
||||
public struct WebDecryptBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
/// </summary>
|
||||
public string BundleName;
|
||||
|
||||
/// <summary>
|
||||
/// Unity引擎用于内容校验的CRC
|
||||
/// </summary>
|
||||
public uint FileLoadCRC;
|
||||
|
||||
/// <summary>
|
||||
/// 文件字节数据
|
||||
/// </summary>
|
||||
public byte[] FileData;
|
||||
}
|
||||
public struct WebDecryptSyncResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包对象
|
||||
/// </summary>
|
||||
public AssetBundle Result;
|
||||
}
|
||||
public interface IWebBundleDecryptionServices
|
||||
{
|
||||
WebDecryptSyncResult LoadAssetBundleSync(WebDecryptBundleInfo bundleInfo);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public struct EncryptFileInfo
|
||||
public struct EncryptBundleInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
@@ -25,9 +25,8 @@ namespace YooAsset
|
||||
/// </summary>
|
||||
public byte[] EncryptedData;
|
||||
}
|
||||
|
||||
public interface IEncryptionServices
|
||||
public interface IBundleEncryptionServices
|
||||
{
|
||||
EncryptResult Encrypt(EncryptFileInfo fileInfo);
|
||||
EncryptResult Encrypt(EncryptBundleInfo bundleInfo);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -15,7 +15,6 @@ namespace YooAsset
|
||||
{
|
||||
_isInitialize = false;
|
||||
_packages.Clear();
|
||||
_defaultPackage = null;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,619 +0,0 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace YooAsset
|
||||
{
|
||||
public static partial class YooAssets
|
||||
{
|
||||
private static ResourcePackage _defaultPackage;
|
||||
|
||||
/// <summary>
|
||||
/// 设置默认的资源包
|
||||
/// </summary>
|
||||
public static void SetDefaultPackage(ResourcePackage package)
|
||||
{
|
||||
_defaultPackage = package;
|
||||
}
|
||||
|
||||
#region 资源信息
|
||||
/// <summary>
|
||||
/// 是否需要从远端更新下载
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static bool IsNeedDownloadFromRemote(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.IsNeedDownloadFromRemote(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否需要从远端更新下载
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static bool IsNeedDownloadFromRemote(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.IsNeedDownloadFromRemote(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
public static AssetInfo[] GetAssetInfos(string tag)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfos(tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息列表
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
public static AssetInfo[] GetAssetInfos(string[] tags)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfos(tags);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetInfo GetAssetInfo(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfo(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetInfo GetAssetInfo(string location, System.Type type)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfo(location, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
/// <param name="assetGUID">资源GUID</param>
|
||||
public static AssetInfo GetAssetInfoByGUID(string assetGUID)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfoByGUID(assetGUID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源信息
|
||||
/// </summary>
|
||||
/// <param name="assetGUID">资源GUID</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetInfo GetAssetInfoByGUID(string assetGUID, System.Type type)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.GetAssetInfoByGUID(assetGUID, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查资源定位地址是否有效
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static bool CheckLocationValid(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CheckLocationValid(location);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 原生文件
|
||||
/// <summary>
|
||||
/// 同步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static RawFileHandle LoadRawFileSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static RawFileHandle LoadRawFileSync(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileSync(location);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static RawFileHandle LoadRawFileAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载原生文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static RawFileHandle LoadRawFileAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadRawFileAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 场景加载
|
||||
/// <summary>
|
||||
/// 同步加载场景
|
||||
/// </summary>
|
||||
/// <param name="location">场景的定位地址</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="physicsMode">场景物理模式</param>
|
||||
public static SceneHandle LoadSceneSync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneSync(location, sceneMode, physicsMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载场景
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">场景的资源信息</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="physicsMode">场景物理模式</param>
|
||||
public static SceneHandle LoadSceneSync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneSync(assetInfo, sceneMode, physicsMode);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载场景
|
||||
/// </summary>
|
||||
/// <param name="location">场景的定位地址</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="physicsMode">场景物理模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneHandle LoadSceneAsync(string location, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(location, sceneMode, physicsMode, suspendLoad, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载场景
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">场景的资源信息</param>
|
||||
/// <param name="sceneMode">场景加载模式</param>
|
||||
/// <param name="physicsMode">场景物理模式</param>
|
||||
/// <param name="suspendLoad">场景加载到90%自动挂起</param>
|
||||
/// <param name="priority">优先级</param>
|
||||
public static SceneHandle LoadSceneAsync(AssetInfo assetInfo, LoadSceneMode sceneMode = LoadSceneMode.Single, LocalPhysicsMode physicsMode = LocalPhysicsMode.None, bool suspendLoad = false, uint priority = 100)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSceneAsync(assetInfo, sceneMode, physicsMode, suspendLoad, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源加载
|
||||
/// <summary>
|
||||
/// 同步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AssetHandle LoadAssetSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetSync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetHandle LoadAssetSync(string location, System.Type type)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync(location, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetSync(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetSync(location);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AssetHandle LoadAssetAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">资源类型</param>
|
||||
public static AssetHandle LoadAssetAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AssetHandle LoadAssetAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAssetAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源加载
|
||||
/// <summary>
|
||||
/// 同步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static SubAssetsHandle LoadSubAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载子资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsSync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static SubAssetsHandle LoadSubAssetsSync(string location, System.Type type)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync(location, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsSync(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsSync(location);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载子资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static SubAssetsHandle LoadSubAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadSubAssetsAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源加载
|
||||
/// <summary>
|
||||
/// 同步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AllAssetsHandle LoadAllAssetsSync(AssetInfo assetInfo)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsSync(assetInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsSync<TObject>(string location) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsSync<TObject>(location);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static AllAssetsHandle LoadAllAssetsSync(string location, System.Type type)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsSync(location, type);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsSync(string location)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsSync(location);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="assetInfo">资源信息</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(AssetInfo assetInfo, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(assetInfo, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <typeparam name="TObject">资源类型</typeparam>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync<TObject>(string location, uint priority = 0) where TObject : UnityEngine.Object
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync<TObject>(location, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
/// <param name="type">子对象类型</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, System.Type type, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(location, type, priority);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步加载资源包内所有资源对象
|
||||
/// </summary>
|
||||
/// <param name="location">资源的定位地址</param>
|
||||
public static AllAssetsHandle LoadAllAssetsAsync(string location, uint priority = 0)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.LoadAllAssetsAsync(location, priority);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#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 ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceDownloader(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceDownloader(tags, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="location">资源定位地址</param>
|
||||
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
|
||||
/// <param name="failedTryAgain">下载失败的重试次数</param>
|
||||
public static ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
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 ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateBundleDownloader(assetInfos, downloadingMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源解压
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压当前资源版本所有的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceUnpacker(unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压指定的资源标签关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tag">资源标签</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceUnpacker(tag, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建内置资源解压器,用于解压指定的资源标签列表关联的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="tags">资源标签列表</param>
|
||||
/// <param name="unpackingMaxNumber">同时解压的最大文件数</param>
|
||||
/// <param name="failedTryAgain">解压失败的重试次数</param>
|
||||
public static ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceUnpacker(tags, unpackingMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 资源导入
|
||||
/// <summary>
|
||||
/// 创建资源导入器
|
||||
/// 注意:资源文件名称必须和资源服务器部署的文件名称一致!
|
||||
/// </summary>
|
||||
/// <param name="filePaths">资源路径列表</param>
|
||||
/// <param name="importerMaxNumber">同时导入的最大文件数</param>
|
||||
/// <param name="failedTryAgain">导入失败的重试次数</param>
|
||||
public static ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
|
||||
{
|
||||
DebugCheckDefaultPackageValid();
|
||||
return _defaultPackage.CreateResourceImporter(filePaths, importerMaxNumber, failedTryAgain);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 调试方法
|
||||
[Conditional("DEBUG")]
|
||||
private static void DebugCheckDefaultPackageValid()
|
||||
{
|
||||
if (_defaultPackage == null)
|
||||
throw new YooInitializeException($"Default package is null. Please use {nameof(YooAssets.SetDefaultPackage)} !");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ public class T2_TestBuldinFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
var manifestServices = new TestRestoreManifest();
|
||||
initParams.BuildinFileSystemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters(fileDecryption, packageRoot);
|
||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
||||
initParams.BuildinFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES, manifestServices);
|
||||
var initializeOp = package.InitializePackageAsync(initParams);
|
||||
yield return initializeOp;
|
||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||
|
||||
@@ -52,7 +52,7 @@ public class T3_TestCacheFileSystem : IPrebuildSetup, IPostBuildCleanup
|
||||
var remoteServices = new TestRemoteServices(hostServerIP);
|
||||
initParams.BuildinFileSystemParameters = null;
|
||||
initParams.CacheFileSystemParameters = FileSystemParameters.CreateDefaultCacheFileSystemParameters(remoteServices, fileDecryption);
|
||||
initParams.CacheFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_SERVICES, manifestServices);
|
||||
initParams.CacheFileSystemParameters.AddParameter(FileSystemParametersDefine.MANIFEST_RESTORE_SERVICES, manifestServices);
|
||||
var initializeOp = package.InitializePackageAsync(initParams);
|
||||
yield return initializeOp;
|
||||
if (initializeOp.Status != EOperationStatus.Succeed)
|
||||
|
||||
Reference in New Issue
Block a user