Compare commits

..

32 Commits

Author SHA1 Message Date
何冠峰
baf76a454b Update CHANGELOG.md 2025-07-23 18:49:13 +08:00
何冠峰
385d343262 Update package.json 2025-07-23 18:49:02 +08:00
何冠峰
1f5ad24d44 test : 完善测试用例代码 2025-07-23 18:46:54 +08:00
何冠峰
fefc0043cf fix : 修正小游戏脚本编译错误 2025-07-23 18:46:12 +08:00
何冠峰
f49143d4f7 Update CHANGELOG.md 2025-07-23 17:12:19 +08:00
何冠峰
fd760b12a3 Update package.json 2025-07-23 17:12:05 +08:00
何冠峰
14cf8e9ca3 update space shooter 2025-07-23 17:11:49 +08:00
何冠峰
3595219a71 style : 移除冗余空格 2025-07-23 16:48:37 +08:00
何冠峰
a4c7d4b8f5 test : 修改资源清单加密解密测试用例 2025-07-23 15:41:57 +08:00
何冠峰
43c5c7fb53 feat : 增加构建前置处理扩展示例
内置清单构建
2025-07-23 15:41:00 +08:00
何冠峰
48d2b36d4e feat : 改进资源清单加密和解密接口 2025-07-23 15:38:29 +08:00
何冠峰
2fd87f4d4b test : 新增测试用例 2025-07-23 14:08:26 +08:00
何冠峰
0fd75b835a style : 修正参数命名 2025-07-23 14:07:12 +08:00
何冠峰
4489ca570b style : 修改日志 2025-07-23 14:06:32 +08:00
何冠峰
268792b576 fix #592
优化不必要的GC
2025-07-23 11:07:29 +08:00
何冠峰
33907ea967 fix #591
新增DISABLE_ONDEMAND_DOWNLOAD文件配置参数
2025-07-22 18:59:47 +08:00
何冠峰
5d7afff3e4 update mini game
增加单元测试用例
2025-07-22 17:40:39 +08:00
何冠峰
fa15f83d85 Update UnityWebCacheRequestOperation.cs 2025-07-22 17:36:39 +08:00
何冠峰
1801974c8a Update DownloadCenterOperation.cs 2025-07-22 10:11:22 +08:00
何冠峰
bfd476d59c Update DownloadCenterOperation.cs 2025-07-21 18:22:51 +08:00
何冠峰
7dd08e9634 update test sample 2025-07-21 18:05:08 +08:00
何冠峰
b2776b933a update mini game sample 2025-07-21 15:52:51 +08:00
何冠峰
9f09b6c526 update file system 2025-07-21 15:52:07 +08:00
何冠峰
01f6103b48 Update AssemblyInfo.cs 2025-07-21 15:48:52 +08:00
何冠峰
053b4a00d7 update test sample 2025-07-17 22:24:27 +08:00
何冠峰
db159428c6 update test sample
增加cache file system单元测试
2025-07-17 21:26:13 +08:00
何冠峰
ac7ee16017 update mini game 2025-07-17 21:23:34 +08:00
何冠峰
c2fb7c3cbb update package invoke
correct name
2025-07-17 21:09:35 +08:00
何冠峰
e70b0d37cd update extension sample 2025-07-17 21:00:46 +08:00
何冠峰
53db012fc8 update download system 2025-07-17 21:00:12 +08:00
何冠峰
b3622167da update download system
remove timeout
2025-07-17 20:59:15 +08:00
何冠峰
dd6fab46f9 update extension sample 2025-07-16 10:48:40 +08:00
219 changed files with 4671 additions and 2093 deletions

View File

@@ -2,6 +2,60 @@
All notable changes to this package will be documented in this file. All notable changes to this package will be documented in this file.
## [2.3.14] - 2025-07-23
**重要****所有下载相关的超时参数timeout已更新判定逻辑**
超时不再以‘指定时间内未接收到任何数据’为判定条件,而是以‘指定时间内未完成整个下载任务’为判定条件。
### Improvements
- 重构了核心代码的下载逻辑,解决了同步加载触发的下载任务没有完成的问题。
- 扩展工程里新增了PreprocessBuildCatalog类用于处理在构建应用程序前自动生成内置资源目录文件。
- (#592) 优化了资源清单逻辑里不必要产生的GC逻辑。
### Fixed
- (#590) 修复了TryUnloadUnusedAsset方法在依赖嵌套层数过深导致没有卸载的问题。
### Added
- 新增了支持Google Play的文件系统扩展示例。
- 新增了支持DefaultCacheFileSystem的单元测试用例。
- 新增了文件系统配置参数DISABLE_ONDEMAND_DOWNLOAD
```csharp
public class FileSystemParametersDefine
{
// 禁用边玩边下机制
public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLO";
}
```
### Changed
- IManifestServices接口拆分为了IManifestProcessServices和IManifestRestoreServices
```csharp
public interface IManifestProcessServices
{
/// <summary>
/// 处理资源清单(压缩或加密)
/// </summary>
byte[] ProcessManifest(byte[] fileData);
}
public interface IManifestRestoreServices
{
/// <summary>
/// 还原资源清单(解压或解密)
/// </summary>
byte[] RestoreManifest(byte[] fileData);
}
```
## [2.3.12] - 2025-07-01 ## [2.3.12] - 2025-07-01
### Improvements ### Improvements

View File

@@ -79,15 +79,27 @@ namespace YooAsset.Editor
EditorPrefs.SetString(key, encyptionClassName); EditorPrefs.SetString(key, encyptionClassName);
} }
// ManifestServicesClassName // ManifestProcessServicesClassName
public static string GetPackageManifestServicesClassName(string packageName, string buildPipeline) public static string GetPackageManifestProcessServicesClassName(string packageName, string buildPipeline)
{ {
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName"; string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
return EditorPrefs.GetString(key, $"{typeof(ManifestNone).FullName}"); return EditorPrefs.GetString(key, $"{typeof(ManifestProcessNone).FullName}");
} }
public static void SetPackageManifestServicesClassName(string packageName, string buildPipeline, string encyptionClassName) public static void SetPackageManifestProcessServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
{ {
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName"; string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
EditorPrefs.SetString(key, encyptionClassName);
}
// ManifestRestoreServicesClassName
public static string GetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline)
{
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
return EditorPrefs.GetString(key, $"{typeof(ManifestRestoreNone).FullName}");
}
public static void SetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
{
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
EditorPrefs.SetString(key, encyptionClassName); EditorPrefs.SetString(key, encyptionClassName);
} }

View File

@@ -99,10 +99,14 @@ namespace YooAsset.Editor
public IEncryptionServices EncryptionServices; public IEncryptionServices EncryptionServices;
/// <summary> /// <summary>
/// 资源清单服务类 /// 资源清单加密服务类
/// </summary> /// </summary>
public IManifestServices ManifestServices; public IManifestProcessServices ManifestProcessServices;
/// <summary>
/// 资源清单解密服务类
/// </summary>
public IManifestRestoreServices ManifestRestoreServices;
private string _pipelineOutputDirectory = string.Empty; private string _pipelineOutputDirectory = string.Empty;
private string _packageOutputDirectory = string.Empty; private string _packageOutputDirectory = string.Empty;

View File

@@ -14,8 +14,8 @@ namespace YooAsset.Editor
{ {
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory(); string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
string buildPackageName = buildParametersContext.Parameters.PackageName; string buildPackageName = buildParametersContext.Parameters.PackageName;
var manifestServices = buildParametersContext.Parameters.ManifestServices; var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(manifestServices, buildPackageName, buildinRootDirectory); CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
// 刷新目录 // 刷新目录
AssetDatabase.Refresh(); AssetDatabase.Refresh();

View File

@@ -72,7 +72,7 @@ namespace YooAsset.Editor
{ {
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
packagePath = $"{packageOutputDirectory}/{fileName}"; packagePath = $"{packageOutputDirectory}/{fileName}";
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestServices); ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestProcessServices);
packageHash = HashUtility.FileCRC32(packagePath); packageHash = HashUtility.FileCRC32(packagePath);
BuildLogger.Log($"Create package manifest file: {packagePath}"); BuildLogger.Log($"Create package manifest file: {packagePath}");
} }
@@ -97,7 +97,7 @@ namespace YooAsset.Editor
{ {
ManifestContext manifestContext = new ManifestContext(); ManifestContext manifestContext = new ManifestContext();
byte[] bytesData = FileUtility.ReadAllBytes(packagePath); byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestServices); manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
context.SetContextObject(manifestContext); context.SetContextObject(manifestContext);
} }
} }

View File

@@ -44,7 +44,9 @@ namespace YooAsset.Editor
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone; buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle; buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName; buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
buildReport.Summary.ManifestServicesClassName = buildParameters.ManifestServices == null ? "null" : buildParameters.ManifestServices.GetType().FullName; buildReport.Summary.ManifestProcessServicesClassName = buildParameters.ManifestProcessServices == null ? "null" : buildParameters.ManifestProcessServices.GetType().FullName;
buildReport.Summary.ManifestRestoreServicesClassName = buildParameters.ManifestRestoreServices == null ? "null" : buildParameters.ManifestRestoreServices.GetType().FullName;
if (buildParameters is BuiltinBuildParameters) if (buildParameters is BuiltinBuildParameters)
{ {
var builtinBuildParameters = buildParameters as BuiltinBuildParameters; var builtinBuildParameters = buildParameters as BuiltinBuildParameters;

View File

@@ -1,13 +1,17 @@
 
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
public class ManifestNone : IManifestServices public class ManifestProcessNone : IManifestProcessServices
{ {
public byte[] ProcessManifest(byte[] fileData) byte[] IManifestProcessServices.ProcessManifest(byte[] fileData)
{ {
return fileData; return fileData;
} }
public byte[] RestoreManifest(byte[] fileData) }
public class ManifestRestoreNone : IManifestRestoreServices
{
byte[] IManifestRestoreServices.RestoreManifest(byte[] fileData)
{ {
return fileData; return fileData;
} }

View File

@@ -44,7 +44,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 创建资源加密服务类实例 /// 创建资源加密服务类实例
/// </summary> /// </summary>
protected IEncryptionServices CreateEncryptionServicesInstance() protected IEncryptionServices CreateEncryptionServicesInstance()
{ {
@@ -58,15 +58,29 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 创建资源清单服务类实例 /// 创建资源清单加密服务类实例
/// </summary> /// </summary>
protected IManifestServices CreateManifestServicesInstance() protected IManifestProcessServices CreateManifestProcessServicesInstance()
{ {
var className = AssetBundleBuilderSetting.GetPackageManifestServicesClassName(PackageName, PipelineName); var className = AssetBundleBuilderSetting.GetPackageManifestProcessServicesClassName(PackageName, PipelineName);
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestServices)); var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestProcessServices));
var classType = classTypes.Find(x => x.FullName.Equals(className)); var classType = classTypes.Find(x => x.FullName.Equals(className));
if (classType != null) if (classType != null)
return (IManifestServices)Activator.CreateInstance(classType); return (IManifestProcessServices)Activator.CreateInstance(classType);
else
return null;
}
/// <summary>
/// 创建资源清单解密服务类实例
/// </summary>
protected IManifestRestoreServices CreateManifestRestoreServicesInstance()
{
var className = AssetBundleBuilderSetting.GetPackageManifestRestoreServicesClassName(PackageName, PipelineName);
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestRestoreServices));
var classType = classTypes.Find(x => x.FullName.Equals(className));
if (classType != null)
return (IManifestRestoreServices)Activator.CreateInstance(classType);
else else
return null; return null;
} }
@@ -169,7 +183,7 @@ namespace YooAsset.Editor
} }
protected PopupField<Type> CreateEncryptionServicesField(VisualElement container) protected PopupField<Type> CreateEncryptionServicesField(VisualElement container)
{ {
// 加密服务类 // 资源包加密服务类
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
if (classTypes.Count > 0) if (classTypes.Count > 0)
{ {
@@ -198,22 +212,22 @@ namespace YooAsset.Editor
return popupField; return popupField;
} }
} }
protected PopupField<Type> CreateManifestServicesField(VisualElement container) protected PopupField<Type> CreateManifestProcessServicesField(VisualElement container)
{ {
// 清单服务类 // 资源清单加密服务类
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestServices)); var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestProcessServices));
if (classTypes.Count > 0) if (classTypes.Count > 0)
{ {
var className = AssetBundleBuilderSetting.GetPackageManifestServicesClassName(PackageName, PipelineName); var className = AssetBundleBuilderSetting.GetPackageManifestProcessServicesClassName(PackageName, PipelineName);
int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className)); int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className));
if (defaultIndex < 0) if (defaultIndex < 0)
defaultIndex = 0; defaultIndex = 0;
var popupField = new PopupField<Type>(classTypes, defaultIndex); var popupField = new PopupField<Type>(classTypes, defaultIndex);
popupField.label = "Manifest Services"; popupField.label = "Manifest Process Services";
popupField.style.width = StyleWidth; popupField.style.width = StyleWidth;
popupField.RegisterValueChangedCallback(evt => popupField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSetting.SetPackageManifestServicesClassName(PackageName, PipelineName, popupField.value.FullName); AssetBundleBuilderSetting.SetPackageManifestProcessServicesClassName(PackageName, PipelineName, popupField.value.FullName);
}); });
container.Add(popupField); container.Add(popupField);
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth); UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
@@ -222,7 +236,38 @@ namespace YooAsset.Editor
else else
{ {
var popupField = new PopupField<Type>(); var popupField = new PopupField<Type>();
popupField.label = "Manifest Services"; popupField.label = "Manifest Process Services";
popupField.style.width = StyleWidth;
container.Add(popupField);
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
return popupField;
}
}
protected PopupField<Type> CreateManifestRestoreServicesField(VisualElement container)
{
// 资源清单加密服务类
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestRestoreServices));
if (classTypes.Count > 0)
{
var className = AssetBundleBuilderSetting.GetPackageManifestRestoreServicesClassName(PackageName, PipelineName);
int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className));
if (defaultIndex < 0)
defaultIndex = 0;
var popupField = new PopupField<Type>(classTypes, defaultIndex);
popupField.label = "Manifest Restore Services";
popupField.style.width = StyleWidth;
popupField.RegisterValueChangedCallback(evt =>
{
AssetBundleBuilderSetting.SetPackageManifestRestoreServicesClassName(PackageName, PipelineName, popupField.value.FullName);
});
container.Add(popupField);
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
return popupField;
}
else
{
var popupField = new PopupField<Type>();
popupField.label = "Manifest Restore Services";
popupField.style.width = StyleWidth; popupField.style.width = StyleWidth;
container.Add(popupField); container.Add(popupField);
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth); UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);

View File

@@ -17,7 +17,8 @@ namespace YooAsset.Editor
protected TextField _buildOutputField; protected TextField _buildOutputField;
protected TextField _buildVersionField; protected TextField _buildVersionField;
protected PopupField<Type> _encryptionServicesField; protected PopupField<Type> _encryptionServicesField;
protected PopupField<Type> _manifestServicesField; protected PopupField<Type> _manifestProcessServicesField;
protected PopupField<Type> _manifestRestoreServicesField;
protected EnumField _compressionField; protected EnumField _compressionField;
protected EnumField _outputNameStyleField; protected EnumField _outputNameStyleField;
protected EnumField _copyBuildinFileOptionField; protected EnumField _copyBuildinFileOptionField;
@@ -47,7 +48,8 @@ namespace YooAsset.Editor
// 服务类 // 服务类
var popupContainer = Root.Q("PopupContainer"); var popupContainer = Root.Q("PopupContainer");
_encryptionServicesField = CreateEncryptionServicesField(popupContainer); _encryptionServicesField = CreateEncryptionServicesField(popupContainer);
_manifestServicesField = CreateManifestServicesField(popupContainer); _manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
// 压缩方式选项 // 压缩方式选项
_compressionField = Root.Q<EnumField>("Compression"); _compressionField = Root.Q<EnumField>("Compression");
@@ -120,7 +122,8 @@ namespace YooAsset.Editor
buildParameters.ClearBuildCacheFiles = clearBuildCache; buildParameters.ClearBuildCacheFiles = clearBuildCache;
buildParameters.UseAssetDependencyDB = useAssetDependencyDB; buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.ManifestServices = CreateManifestServicesInstance(); buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline(); BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
var buildResult = pipeline.Run(buildParameters, true); var buildResult = pipeline.Run(buildParameters, true);

View File

@@ -17,7 +17,8 @@ namespace YooAsset.Editor
protected TextField _buildOutputField; protected TextField _buildOutputField;
protected TextField _buildVersionField; protected TextField _buildVersionField;
protected PopupField<Type> _encryptionServicesField; protected PopupField<Type> _encryptionServicesField;
protected PopupField<Type> _manifestServicesField; protected PopupField<Type> _manifestProcessServicesField;
protected PopupField<Type> _manifestRestoreServicesField;
protected EnumField _outputNameStyleField; protected EnumField _outputNameStyleField;
protected EnumField _copyBuildinFileOptionField; protected EnumField _copyBuildinFileOptionField;
protected TextField _copyBuildinFileTagsField; protected TextField _copyBuildinFileTagsField;
@@ -46,7 +47,8 @@ namespace YooAsset.Editor
// 加密方法 // 加密方法
var popupContainer = Root.Q("PopupContainer"); var popupContainer = Root.Q("PopupContainer");
_encryptionServicesField = CreateEncryptionServicesField(popupContainer); _encryptionServicesField = CreateEncryptionServicesField(popupContainer);
_manifestServicesField = CreateManifestServicesField(popupContainer); _manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
// 输出文件名称样式 // 输出文件名称样式
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle"); _outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
@@ -112,7 +114,8 @@ namespace YooAsset.Editor
buildParameters.ClearBuildCacheFiles = clearBuildCache; buildParameters.ClearBuildCacheFiles = clearBuildCache;
buildParameters.UseAssetDependencyDB = useAssetDependencyDB; buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.ManifestServices = CreateManifestServicesInstance(); buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
RawFileBuildPipeline pipeline = new RawFileBuildPipeline(); RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
var buildResult = pipeline.Run(buildParameters, true); var buildResult = pipeline.Run(buildParameters, true);

View File

@@ -17,7 +17,8 @@ namespace YooAsset.Editor
protected TextField _buildOutputField; protected TextField _buildOutputField;
protected TextField _buildVersionField; protected TextField _buildVersionField;
protected PopupField<Type> _encryptionServicesField; protected PopupField<Type> _encryptionServicesField;
protected PopupField<Type> _manifestServicesField; protected PopupField<Type> _manifestProcessServicesField;
protected PopupField<Type> _manifestRestoreServicesField;
protected EnumField _compressionField; protected EnumField _compressionField;
protected EnumField _outputNameStyleField; protected EnumField _outputNameStyleField;
protected EnumField _copyBuildinFileOptionField; protected EnumField _copyBuildinFileOptionField;
@@ -47,7 +48,8 @@ namespace YooAsset.Editor
// 加密方法 // 加密方法
var popupContainer = Root.Q("PopupContainer"); var popupContainer = Root.Q("PopupContainer");
_encryptionServicesField = CreateEncryptionServicesField(popupContainer); _encryptionServicesField = CreateEncryptionServicesField(popupContainer);
_manifestServicesField = CreateManifestServicesField(popupContainer); _manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
// 压缩方式选项 // 压缩方式选项
_compressionField = Root.Q<EnumField>("Compression"); _compressionField = Root.Q<EnumField>("Compression");
@@ -122,7 +124,8 @@ namespace YooAsset.Editor
buildParameters.UseAssetDependencyDB = useAssetDependencyDB; buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName; buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
buildParameters.EncryptionServices = CreateEncryptionServicesInstance(); buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
buildParameters.ManifestServices = CreateManifestServicesInstance(); buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline(); ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
var buildResult = pipeline.Run(buildParameters, true); var buildResult = pipeline.Run(buildParameters, true);

View File

@@ -72,7 +72,8 @@ namespace YooAsset.Editor
public bool EnableSharePackRule; public bool EnableSharePackRule;
public bool SingleReferencedPackAlone; public bool SingleReferencedPackAlone;
public string EncryptionServicesClassName; public string EncryptionServicesClassName;
public string ManifestServicesClassName; public string ManifestProcessServicesClassName;
public string ManifestRestoreServicesClassName;
public EFileNameStyle FileNameStyle; public EFileNameStyle FileNameStyle;
// 引擎参数 // 引擎参数

View File

@@ -67,7 +67,8 @@ namespace YooAsset.Editor
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}"); BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}"); BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
BindListViewItem("Encryption Services", buildReport.Summary.EncryptionServicesClassName); BindListViewItem("Encryption Services", buildReport.Summary.EncryptionServicesClassName);
BindListViewItem("Manifest Services", buildReport.Summary.ManifestServicesClassName); BindListViewItem("Manifest Process Services", buildReport.Summary.ManifestProcessServicesClassName);
BindListViewItem("Manifest Restore Services", buildReport.Summary.ManifestRestoreServicesClassName);
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"); BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}"); BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"); BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");

View File

@@ -2,6 +2,7 @@
// 内部友元 // 内部友元
[assembly: InternalsVisibleTo("YooAsset.Editor")] [assembly: InternalsVisibleTo("YooAsset.Editor")]
[assembly: InternalsVisibleTo("YooAsset.Test")]
[assembly: InternalsVisibleTo("YooAsset.Test.Editor")] [assembly: InternalsVisibleTo("YooAsset.Test.Editor")]
// 外部友元 // 外部友元

View File

@@ -94,4 +94,25 @@ namespace YooAsset
/// </summary> /// </summary>
public long FileSize; public long FileSize;
} }
/// <summary>
/// 导入文件的信息
/// </summary>
public struct ImportFileInfo
{
/// <summary>
/// 本地文件路径
/// </summary>
public string FilePath;
/// <summary>
/// 资源包名称
/// </summary>
public string BundleName;
/// <summary>
/// 资源包GUID
/// </summary>
public string BundleGUID;
}
} }

View File

@@ -24,7 +24,7 @@ namespace YooAsset
/// </summary> /// </summary>
public AssetBundle Result { private set; get; } public AssetBundle Result { private set; get; }
internal UnityAssetBundleRequestOperation(PackageBundle packageBundle, bool disableUnityWebCache, string url, int timeout = 60) : base(url, timeout) internal UnityAssetBundleRequestOperation(PackageBundle packageBundle, bool disableUnityWebCache, string url) : base(url)
{ {
_packageBundle = packageBundle; _packageBundle = packageBundle;
_disableUnityWebCache = disableUnityWebCache; _disableUnityWebCache = disableUnityWebCache;
@@ -40,7 +40,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest) if (_steps == ESteps.CreateRequest)
{ {
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -51,10 +50,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress; Progress = _requestOperation.progress;
if (_requestOperation.isDone == false) if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return; return;
}
if (CheckRequestResult()) if (CheckRequestResult())
{ {

View File

@@ -0,0 +1,89 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Networking;
using UnityEngine;
namespace YooAsset
{
internal class UnityWebCacheRequestOperation : UnityWebRequestOperation
{
protected enum ESteps
{
None,
CreateRequest,
Download,
Done,
}
private UnityWebRequestAsyncOperation _requestOperation;
private readonly Dictionary<string, string> _headers = new Dictionary<string, string>();
private ESteps _steps = ESteps.None;
internal UnityWebCacheRequestOperation(string url) : base(url)
{
}
internal override void InternalStart()
{
_steps = ESteps.CreateRequest;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CreateRequest)
{
CreateWebRequest();
_steps = ESteps.Download;
}
if (_steps == ESteps.Download)
{
DownloadProgress = _webRequest.downloadProgress;
DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress;
if (_requestOperation.isDone == false)
return;
if (CheckRequestResult())
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
}
// 注意:最终释放请求器
DisposeRequest();
}
}
/// <summary>
/// 设置请求头信息
/// </summary>
public void SetRequestHeader(string name, string value)
{
_headers.Add(name, value);
}
private void CreateWebRequest()
{
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.disposeDownloadHandlerOnDispose = true;
// 设置消息头
foreach (var keyValuePair in _headers)
{
string name = keyValuePair.Key;
string value = keyValuePair.Value;
_webRequest.SetRequestHeader(name, value);
}
_requestOperation = _webRequest.SendWebRequest();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 375d88bcf5b9a6146adaf98ceb5369f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -14,17 +14,24 @@ namespace YooAsset
} }
private UnityWebRequestAsyncOperation _requestOperation; private UnityWebRequestAsyncOperation _requestOperation;
private bool _checkTimeout = true;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
/// <summary> /// <summary>
/// 请求结果 /// 请求结果
/// </summary> /// </summary>
public byte[] Result { private set; get; } public byte[] Result { private set; get; }
internal UnityWebDataRequestOperation(string url, int timeout = 60) : base(url, timeout) internal UnityWebDataRequestOperation(string url, int timeout) : base(url)
{ {
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -37,7 +44,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest) if (_steps == ESteps.CreateRequest)
{ {
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -48,11 +54,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress; Progress = _requestOperation.progress;
if (_requestOperation.isDone == false) if (_requestOperation.isDone == false)
{
if (_checkTimeout)
CheckRequestTimeout();
return; return;
}
if (CheckRequestResult()) if (CheckRequestResult())
{ {
@@ -81,18 +83,11 @@ namespace YooAsset
} }
} }
/// <summary>
/// 不检测超时
/// </summary>
public void DontCheckTimeout()
{
_checkTimeout = false;
}
private void CreateWebRequest() private void CreateWebRequest()
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerBuffer handler = new DownloadHandlerBuffer(); DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest(); _requestOperation = _webRequest.SendWebRequest();

View File

@@ -17,10 +17,18 @@ namespace YooAsset
private readonly string _fileSavePath; private readonly string _fileSavePath;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout = 60) : base(url, timeout)
internal UnityWebFileRequestOperation(string url, string fileSavePath, int timeout) : base(url)
{ {
_fileSavePath = fileSavePath; _fileSavePath = fileSavePath;
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -33,7 +41,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest) if (_steps == ESteps.CreateRequest)
{ {
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -44,10 +51,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress; Progress = _requestOperation.progress;
if (_requestOperation.isDone == false) if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return; return;
}
if (CheckRequestResult()) if (CheckRequestResult())
{ {
@@ -67,9 +71,10 @@ namespace YooAsset
private void CreateWebRequest() private void CreateWebRequest()
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_fileSavePath); DownloadHandlerFile handler = new DownloadHandlerFile(_fileSavePath);
handler.removeFileOnAbort = true; handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest(); _requestOperation = _webRequest.SendWebRequest();

View File

@@ -8,11 +8,6 @@ namespace YooAsset
{ {
protected UnityWebRequest _webRequest; protected UnityWebRequest _webRequest;
protected readonly string _requestURL; protected readonly string _requestURL;
// 超时相关
private readonly float _timeout;
private ulong _latestDownloadBytes;
private float _latestDownloadRealtime;
private bool _isAbort = false; private bool _isAbort = false;
/// <summary> /// <summary>
@@ -38,10 +33,9 @@ namespace YooAsset
get { return _requestURL; } get { return _requestURL; }
} }
internal UnityWebRequestOperation(string url, int timeout) internal UnityWebRequestOperation(string url)
{ {
_requestURL = url; _requestURL = url;
_timeout = timeout;
} }
internal override void InternalAbort() internal override void InternalAbort()
{ {
@@ -71,42 +65,6 @@ namespace YooAsset
} }
} }
/// <summary>
/// 重置超时计时
/// </summary>
protected void ResetTimeout()
{
_latestDownloadBytes = 0;
_latestDownloadRealtime = Time.realtimeSinceStartup;
}
/// <summary>
/// 检测超时
/// </summary>
protected void CheckRequestTimeout()
{
if (_webRequest.isDone)
return;
// 注意:在连续时间段内无新增下载数据及判定为超时
if (_isAbort == false)
{
if (_latestDownloadBytes != _webRequest.downloadedBytes)
{
_latestDownloadBytes = _webRequest.downloadedBytes;
_latestDownloadRealtime = Time.realtimeSinceStartup;
}
float offset = Time.realtimeSinceStartup - _latestDownloadRealtime;
if (offset > _timeout)
{
YooLogger.Warning($"Web request timeout : {_requestURL}");
_webRequest.Abort();
_isAbort = true;
}
}
}
/// <summary> /// <summary>
/// 检测请求结果 /// 检测请求结果
/// </summary> /// </summary>

View File

@@ -16,14 +16,22 @@ namespace YooAsset
private UnityWebRequestAsyncOperation _requestOperation; private UnityWebRequestAsyncOperation _requestOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
/// <summary>
/// 响应的超时时间单位在经过Timeout的秒数后尝试中止。
/// 注意当Timeout设置为0时不会应用超时。
/// 注意设置的超时值可能应用于Android上的每个URL重定向这可能会导致响应时间增加。
/// </summary>
private readonly int _timeout;
/// <summary> /// <summary>
/// 请求结果 /// 请求结果
/// </summary> /// </summary>
public string Result { private set; get; } public string Result { private set; get; }
internal UnityWebTextRequestOperation(string url, int timeout = 60) : base(url, timeout) internal UnityWebTextRequestOperation(string url, int timeout) : base(url)
{ {
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -36,7 +44,6 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest) if (_steps == ESteps.CreateRequest)
{ {
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -47,10 +54,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = _requestOperation.progress; Progress = _requestOperation.progress;
if (_requestOperation.isDone == false) if (_requestOperation.isDone == false)
{
CheckRequestTimeout();
return; return;
}
if (CheckRequestResult()) if (CheckRequestResult())
{ {
@@ -81,8 +85,9 @@ namespace YooAsset
private void CreateWebRequest() private void CreateWebRequest()
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerBuffer handler = new DownloadHandlerBuffer(); DownloadHandlerBuffer handler = new DownloadHandlerBuffer();
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.timeout = _timeout;
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
_requestOperation = _webRequest.SendWebRequest(); _requestOperation = _webRequest.SendWebRequest();

View File

@@ -7,6 +7,114 @@ namespace YooAsset
{ {
internal static class CatalogTools internal static class CatalogTools
{ {
#if UNITY_EDITOR
/// <summary>
/// 生成包裹的内置资源目录文件
/// 说明:根据指定目录下的文件生成清单文件。
/// </summary>
public static bool CreateCatalogFile(IManifestRestoreServices services, string packageName, string packageDirectory)
{
// 获取资源清单版本
string packageVersion;
{
string versionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
string versionFilePath = $"{packageDirectory}/{versionFileName}";
if (File.Exists(versionFilePath) == false)
{
Debug.LogError($"Can not found package version file : {versionFilePath}");
return false;
}
packageVersion = FileUtility.ReadAllText(versionFilePath);
}
// 加载资源清单文件
PackageManifest packageManifest;
{
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
string manifestFilePath = $"{packageDirectory}/{manifestFileName}";
if (File.Exists(manifestFilePath) == false)
{
Debug.LogError($"Can not found package manifest file : {manifestFilePath}");
return false;
}
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
packageManifest = ManifestTools.DeserializeFromBinary(binaryData, services);
}
// 获取文件名映射关系
Dictionary<string, string> fileMapping = new Dictionary<string, string>();
{
foreach (var packageBundle in packageManifest.BundleList)
{
fileMapping.Add(packageBundle.FileName, packageBundle.BundleGUID);
}
}
// 创建内置清单实例
var buildinFileCatalog = new DefaultBuildinFileCatalog();
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
buildinFileCatalog.PackageName = packageName;
buildinFileCatalog.PackageVersion = packageVersion;
// 创建白名单查询集合
HashSet<string> whiteFileList = new HashSet<string>
{
"link.xml",
"buildlogtep.json",
$"{packageName}.version",
$"{packageName}_{packageVersion}.bytes",
$"{packageName}_{packageVersion}.hash",
$"{packageName}_{packageVersion}.json",
$"{packageName}_{packageVersion}.report",
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
};
// 记录所有内置资源文件
DirectoryInfo rootDirectory = new DirectoryInfo(packageDirectory);
FileInfo[] fileInfos = rootDirectory.GetFiles();
foreach (var fileInfo in fileInfos)
{
if (fileInfo.Extension == ".meta")
continue;
if (whiteFileList.Contains(fileInfo.Name))
continue;
string fileName = fileInfo.Name;
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
{
var wrapper = new DefaultBuildinFileCatalog.FileWrapper();
wrapper.BundleGUID = bundleGUID;
wrapper.FileName = fileName;
buildinFileCatalog.Wrappers.Add(wrapper);
}
else
{
Debug.LogWarning($"Failed mapping file : {fileName}");
}
}
// 创建输出文件
string jsonFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
if (File.Exists(jsonFilePath))
File.Delete(jsonFilePath);
SerializeToJson(jsonFilePath, buildinFileCatalog);
// 创建输出文件
string binaryFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
if (File.Exists(binaryFilePath))
File.Delete(binaryFilePath);
SerializeToBinary(binaryFilePath, buildinFileCatalog);
UnityEditor.AssetDatabase.Refresh();
Debug.Log($"Succeed to save catalog file : {binaryFilePath}");
return true;
}
#endif
/// <summary> /// <summary>
/// 序列化JSON文件 /// 序列化JSON文件
/// </summary> /// </summary>

View File

@@ -92,7 +92,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 自定义参数:资源清单服务类 /// 自定义参数:资源清单服务类
/// </summary> /// </summary>
public IManifestServices ManifestServices { private set; get; } public IManifestRestoreServices ManifestServices { private set; get; }
/// <summary> /// <summary>
/// 自定义参数:拷贝内置文件服务类 /// 自定义参数:拷贝内置文件服务类
@@ -186,7 +186,7 @@ namespace YooAsset
} }
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES) else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
{ {
ManifestServices = (IManifestServices)value; ManifestServices = (IManifestRestoreServices)value;
} }
else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES) else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES)
{ {

View File

@@ -1,155 +0,0 @@
#if UNITY_EDITOR
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace YooAsset
{
public class DefaultBuildinFileSystemBuild : UnityEditor.Build.IPreprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
/// <summary>
/// 在构建应用程序前自动生成内置资源目录文件。
/// 原理搜索StreamingAssets目录下的所有资源文件将这些文件信息写入文件然后在运行时做查询用途。
/// </summary>
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
{
YooLogger.Log("Begin to create catalog file !");
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
if (rootDirectory.Exists == false)
{
Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
return;
}
// 搜索所有Package目录
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
foreach (var subDirectory in subDirectories)
{
string packageName = subDirectory.Name;
string pacakgeDirectory = subDirectory.FullName;
try
{
bool result = CreateBuildinCatalogFile(null, packageName, pacakgeDirectory);
if (result == false)
{
Debug.LogError($"Create package {packageName} catalog file failed ! See the detail error in console !");
}
}
catch (System.Exception ex)
{
Debug.LogError($"Create package {packageName} catalog file failed ! {ex.Message}");
}
}
}
/// <summary>
/// 生成包裹的内置资源目录文件
/// </summary>
public static bool CreateBuildinCatalogFile(IManifestServices services, string packageName, string packageDirectory)
{
// 获取资源清单版本
string packageVersion;
{
string versionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
string versionFilePath = $"{packageDirectory}/{versionFileName}";
if (File.Exists(versionFilePath) == false)
{
Debug.LogError($"Can not found package version file : {versionFilePath}");
return false;
}
packageVersion = FileUtility.ReadAllText(versionFilePath);
}
// 加载资源清单文件
PackageManifest packageManifest;
{
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
string manifestFilePath = $"{packageDirectory}/{manifestFileName}";
if (File.Exists(manifestFilePath) == false)
{
Debug.LogError($"Can not found package manifest file : {manifestFilePath}");
return false;
}
var binaryData = FileUtility.ReadAllBytes(manifestFilePath);
packageManifest = ManifestTools.DeserializeFromBinary(binaryData, services);
}
// 获取文件名映射关系
Dictionary<string, string> fileMapping = new Dictionary<string, string>();
{
foreach (var packageBundle in packageManifest.BundleList)
{
fileMapping.Add(packageBundle.FileName, packageBundle.BundleGUID);
}
}
// 创建内置清单实例
var buildinFileCatalog = new DefaultBuildinFileCatalog();
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
buildinFileCatalog.PackageName = packageName;
buildinFileCatalog.PackageVersion = packageVersion;
// 创建白名单查询集合
HashSet<string> whiteFileList = new HashSet<string>
{
"link.xml",
"buildlogtep.json",
$"{packageName}.version",
$"{packageName}_{packageVersion}.bytes",
$"{packageName}_{packageVersion}.hash",
$"{packageName}_{packageVersion}.json",
$"{packageName}_{packageVersion}.report",
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
};
// 记录所有内置资源文件
DirectoryInfo rootDirectory = new DirectoryInfo(packageDirectory);
FileInfo[] fileInfos = rootDirectory.GetFiles();
foreach (var fileInfo in fileInfos)
{
if (fileInfo.Extension == ".meta")
continue;
if (whiteFileList.Contains(fileInfo.Name))
continue;
string fileName = fileInfo.Name;
if (fileMapping.TryGetValue(fileName, out string bundleGUID))
{
var wrapper = new DefaultBuildinFileCatalog.FileWrapper();
wrapper.BundleGUID = bundleGUID;
wrapper.FileName = fileName;
buildinFileCatalog.Wrappers.Add(wrapper);
}
else
{
Debug.LogWarning($"Failed mapping file : {fileName}");
}
}
// 创建输出文件
string jsonFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
if (File.Exists(jsonFilePath))
File.Delete(jsonFilePath);
CatalogTools.SerializeToJson(jsonFilePath, buildinFileCatalog);
// 创建输出文件
string binaryFilePath = $"{packageDirectory}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
if (File.Exists(binaryFilePath))
File.Delete(binaryFilePath);
CatalogTools.SerializeToBinary(binaryFilePath, buildinFileCatalog);
UnityEditor.AssetDatabase.Refresh();
Debug.Log($"Succeed to save buildin file catalog : {binaryFilePath}");
return true;
}
}
}
#endif

View File

@@ -17,7 +17,7 @@ namespace YooAsset
private readonly DefaultBuildinFileSystem _fileSystem; private readonly DefaultBuildinFileSystem _fileSystem;
private CopyBuildinPackageManifestOperation _copyBuildinPackageManifestOp; private CopyBuildinPackageManifestOperation _copyBuildinPackageManifestOp;
private FSInitializeFileSystemOperation _initUnpackFIleSystemOp; private FSInitializeFileSystemOperation _initUnpackFIleSystemOp;
private LoadBuildinCatalogFileOperation _loadCatalogFileOp; private LoadBuildinCatalogFileOperation _loadBuildinCatalogFileOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DBFSInitializeOperation(DefaultBuildinFileSystem fileSystem) internal DBFSInitializeOperation(DefaultBuildinFileSystem fileSystem)
@@ -103,34 +103,18 @@ namespace YooAsset
if (_steps == ESteps.LoadCatalogFile) if (_steps == ESteps.LoadCatalogFile)
{ {
if (_loadCatalogFileOp == null) if (_loadBuildinCatalogFileOp == null)
{ {
#if UNITY_EDITOR _loadBuildinCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
/* _loadBuildinCatalogFileOp.StartOperation();
// 兼容性初始化 AddChildOperation(_loadBuildinCatalogFileOp);
// 说明:内置文件系统在编辑器下运行时需要动态生成
string packageRoot = _fileSystem.FileRoot;
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.ManifestServices, _fileSystem.PackageName, packageRoot);
if (result == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Create package catalog file failed ! See the detail error in console !";
return;
}
*/
#endif
_loadCatalogFileOp = new LoadBuildinCatalogFileOperation(_fileSystem);
_loadCatalogFileOp.StartOperation();
AddChildOperation(_loadCatalogFileOp);
} }
_loadCatalogFileOp.UpdateOperation(); _loadBuildinCatalogFileOp.UpdateOperation();
if (_loadCatalogFileOp.IsDone == false) if (_loadBuildinCatalogFileOp.IsDone == false)
return; return;
if (_loadCatalogFileOp.Status == EOperationStatus.Succeed) if (_loadBuildinCatalogFileOp.Status == EOperationStatus.Succeed)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
@@ -139,7 +123,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _loadCatalogFileOp.Error; Error = _loadBuildinCatalogFileOp.Error;
} }
} }
} }

View File

@@ -104,27 +104,28 @@ namespace YooAsset
} }
} }
if (_assetBundle != null) if (_assetBundle == null)
{ {
_steps = ESteps.Done; if (_bundle.Encrypted)
Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream); {
Status = EOperationStatus.Succeed; _steps = ESteps.Done;
return; Status = EOperationStatus.Failed;
} Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}";
YooLogger.Error(Error);
if (_bundle.Encrypted) }
{ else
_steps = ESteps.Done; {
Status = EOperationStatus.Failed; _steps = ESteps.Done;
Error = $"Failed to load encrypted buildin asset bundle file : {_bundle.BundleName}"; Status = EOperationStatus.Failed;
YooLogger.Error(Error); Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}";
YooLogger.Error(Error);
}
} }
else else
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Result = new AssetBundleResult(_fileSystem, _bundle, _assetBundle, _managedStream);
Error = $"Failed to load buildin asset bundle file : {_bundle.BundleName}"; Status = EOperationStatus.Succeed;
YooLogger.Error(Error);
} }
} }
} }
@@ -176,13 +177,15 @@ namespace YooAsset
if (_steps == ESteps.LoadBuildinRawBundle) if (_steps == ESteps.LoadBuildinRawBundle)
{ {
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
#if UNITY_ANDROID #if UNITY_ANDROID
//TODO : 安卓平台内置文件属于APK压缩包内的文件。 //TODO : 安卓平台内置文件属于APK压缩包内的文件。
_steps = ESteps.Done; _steps = ESteps.Done;
Result = new RawBundleResult(_fileSystem, _bundle); Status = EOperationStatus.Failed;
Status = EOperationStatus.Succeed; Error = $"Can not load android buildin raw bundle file : {filePath}";
YooLogger.Error(Error);
#else #else
string filePath = _fileSystem.GetBuildinFileLoadPath(_bundle);
if (File.Exists(filePath)) if (File.Exists(filePath))
{ {
_steps = ESteps.Done; _steps = ESteps.Done;

View File

@@ -20,8 +20,8 @@ namespace YooAsset
private readonly DefaultBuildinFileSystem _fileSystem; private readonly DefaultBuildinFileSystem _fileSystem;
private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp; private RequestBuildinPackageVersionOperation _requestBuildinPackageVersionOp;
private UnityWebFileRequestOperation _hashFileRequestOp; private UnityWebFileRequestOperation _hashWebFileRequestOp;
private UnityWebFileRequestOperation _manifestFileRequestOp; private UnityWebFileRequestOperation _manifestWebFileRequestOp;
private string _buildinPackageVersion; private string _buildinPackageVersion;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -78,21 +78,21 @@ namespace YooAsset
if (_steps == ESteps.UnpackHashFile) if (_steps == ESteps.UnpackHashFile)
{ {
if (_hashFileRequestOp == null) if (_hashWebFileRequestOp == null)
{ {
string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion); string sourcePath = _fileSystem.GetBuildinPackageHashFilePath(_buildinPackageVersion);
string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion); string destPath = GetCopyPackageHashDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _hashWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
_hashFileRequestOp.StartOperation(); _hashWebFileRequestOp.StartOperation();
AddChildOperation(_hashFileRequestOp); AddChildOperation(_hashWebFileRequestOp);
} }
_hashFileRequestOp.UpdateOperation(); _hashWebFileRequestOp.UpdateOperation();
if (_hashFileRequestOp.IsDone == false) if (_hashWebFileRequestOp.IsDone == false)
return; return;
if (_hashFileRequestOp.Status == EOperationStatus.Succeed) if (_hashWebFileRequestOp.Status == EOperationStatus.Succeed)
{ {
_steps = ESteps.CheckManifestFile; _steps = ESteps.CheckManifestFile;
} }
@@ -100,7 +100,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _hashFileRequestOp.Error; Error = _hashWebFileRequestOp.Error;
} }
} }
@@ -119,21 +119,21 @@ namespace YooAsset
if (_steps == ESteps.UnpackManifestFile) if (_steps == ESteps.UnpackManifestFile)
{ {
if (_manifestFileRequestOp == null) if (_manifestWebFileRequestOp == null)
{ {
string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion); string sourcePath = _fileSystem.GetBuildinPackageManifestFilePath(_buildinPackageVersion);
string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion); string destPath = GetCopyPackageManifestDestPath(_buildinPackageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _manifestWebFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
_manifestFileRequestOp.StartOperation(); _manifestWebFileRequestOp.StartOperation();
AddChildOperation(_manifestFileRequestOp); AddChildOperation(_manifestWebFileRequestOp);
} }
_manifestFileRequestOp.UpdateOperation(); _manifestWebFileRequestOp.UpdateOperation();
if (_manifestFileRequestOp.IsDone == false) if (_manifestWebFileRequestOp.IsDone == false)
return; return;
if (_manifestFileRequestOp.Status == EOperationStatus.Succeed) if (_manifestWebFileRequestOp.Status == EOperationStatus.Succeed)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Succeed; Status = EOperationStatus.Succeed;
@@ -142,7 +142,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _manifestFileRequestOp.Error; Error = _manifestWebFileRequestOp.Error;
} }
} }
} }

View File

@@ -35,7 +35,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath(); string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url, 60);
_webDataRequestOp.StartOperation(); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp); AddChildOperation(_webDataRequestOp);
} }

View File

@@ -46,7 +46,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion); string filePath = _fileSystem.GetBuildinPackageManifestFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url, 60);
_webDataRequestOp.StartOperation(); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp); AddChildOperation(_webDataRequestOp);
} }

View File

@@ -41,7 +41,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion); string filePath = _fileSystem.GetBuildinPackageHashFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url); _webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
_webTextRequestOp.StartOperation(); _webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp); AddChildOperation(_webTextRequestOp);
} }

View File

@@ -39,7 +39,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetBuildinPackageVersionFilePath(); string filePath = _fileSystem.GetBuildinPackageVersionFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webTextRequestOp = new UnityWebTextRequestOperation(url); _webTextRequestOp = new UnityWebTextRequestOperation(url, 60);
_webTextRequestOp.StartOperation(); _webTextRequestOp.StartOperation();
AddChildOperation(_webTextRequestOp); AddChildOperation(_webTextRequestOp);
} }

View File

@@ -75,6 +75,11 @@ namespace YooAsset
/// </summary> /// </summary>
public bool AppendFileExtension { private set; get; } = false; public bool AppendFileExtension { private set; get; } = false;
/// <summary>
/// 自定义参数:禁用边玩边下机制
/// </summary>
public bool DisableOnDemandDownload { private set; get; } = false;
/// <summary> /// <summary>
/// 自定义参数:最大并发连接数 /// 自定义参数:最大并发连接数
/// </summary> /// </summary>
@@ -103,7 +108,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 自定义参数:资源清单服务类 /// 自定义参数:资源清单服务类
/// </summary> /// </summary>
public IManifestServices ManifestServices { private set; get; } public IManifestRestoreServices ManifestServices { private set; get; }
/// <summary> /// <summary>
/// 自定义参数:拷贝内置文件服务类 /// 自定义参数:拷贝内置文件服务类
@@ -222,6 +227,10 @@ namespace YooAsset
{ {
AppendFileExtension = Convert.ToBoolean(value); AppendFileExtension = Convert.ToBoolean(value);
} }
else if (name == FileSystemParametersDefine.DISABLE_ONDEMAND_DOWNLOAD)
{
DisableOnDemandDownload = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY) else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
{ {
DownloadMaxConcurrency = Convert.ToInt32(value); DownloadMaxConcurrency = Convert.ToInt32(value);
@@ -244,7 +253,7 @@ namespace YooAsset
} }
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES) else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
{ {
ManifestServices = (IManifestServices)value; ManifestServices = (IManifestRestoreServices)value;
} }
else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES) else if (name == FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES)
{ {

View File

@@ -111,7 +111,7 @@ namespace YooAsset
if (_verifyCacheFilesOp.Status == EOperationStatus.Succeed) if (_verifyCacheFilesOp.Status == EOperationStatus.Succeed)
{ {
_steps = ESteps.CreateDownloadCenter; _steps = ESteps.CreateDownloadCenter;
YooLogger.Log($"Package '{_fileSystem.PackageName}' cached files count : {_fileSystem.FileCount}"); YooLogger.Log($"Package '{_fileSystem.PackageName}' '{_fileSystem.GetType().Name}' cached files count : {_fileSystem.FileCount}");
} }
else else
{ {

View File

@@ -49,7 +49,17 @@ namespace YooAsset
} }
else else
{ {
_steps = ESteps.DownloadFile; if (_fileSystem.DisableOnDemandDownload)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The bundle not cached : {_bundle.BundleName}";
YooLogger.Warning(Error);
}
else
{
_steps = ESteps.DownloadFile;
}
} }
} }
@@ -57,7 +67,7 @@ namespace YooAsset
{ {
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
_downloadFileOp.StartOperation(); _downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp); AddChildOperation(_downloadFileOp);
@@ -304,7 +314,7 @@ namespace YooAsset
{ {
if (_downloadFileOp == null) if (_downloadFileOp == null)
{ {
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options); _downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
_downloadFileOp.StartOperation(); _downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp); AddChildOperation(_downloadFileOp);

View File

@@ -3,22 +3,11 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
/// <summary>
/// 下载器单元测试
/// 1. 下载失败重试机制
/// 2. 下载引用计数机制
/// 3. 最大下载并发机制
/// 4. 异步下载远端资源
/// 5. 同步下载远端资源
/// 6. 异步拷贝本地资源
/// 7. 同步拷贝本地资源
/// 9. 断点续传下载器
/// </summary>
internal class DownloadCenterOperation : AsyncOperationBase internal class DownloadCenterOperation : AsyncOperationBase
{ {
private readonly DefaultCacheFileSystem _fileSystem; private readonly DefaultCacheFileSystem _fileSystem;
protected readonly Dictionary<string, UnityDownloadFileOperation> _downloaders = new Dictionary<string, UnityDownloadFileOperation>(1000); protected readonly Dictionary<string, UnityDownloadFileOperation> _downloaders = new Dictionary<string, UnityDownloadFileOperation>(1000);
protected readonly List<string> _removeDownloadList = new List<string>(1000); protected readonly List<string> _removeList = new List<string>(1000);
public DownloadCenterOperation(DefaultCacheFileSystem fileSystem) public DownloadCenterOperation(DefaultCacheFileSystem fileSystem)
{ {
@@ -30,31 +19,34 @@ namespace YooAsset
internal override void InternalUpdate() internal override void InternalUpdate()
{ {
// 获取可移除的下载器集合 // 获取可移除的下载器集合
_removeDownloadList.Clear(); _removeList.Clear();
foreach (var valuePair in _downloaders) foreach (var valuePair in _downloaders)
{ {
var downloader = valuePair.Value; var downloader = valuePair.Value;
downloader.UpdateOperation(); downloader.UpdateOperation();
if (downloader.IsDone)
{
_removeList.Add(valuePair.Key);
continue;
}
// 注意:主动终止引用计数为零的下载任务 // 注意:主动终止引用计数为零的下载任务
if (downloader.RefCount <= 0) if (downloader.RefCount <= 0)
{ {
_removeDownloadList.Add(valuePair.Key); _removeList.Add(valuePair.Key);
downloader.AbortOperation(); downloader.AbortOperation();
continue; continue;
} }
if (downloader.IsDone)
{
_removeDownloadList.Add(valuePair.Key);
continue;
}
} }
// 移除下载器 // 移除下载器
foreach (var key in _removeDownloadList) foreach (var key in _removeList)
{ {
_downloaders.Remove(key); if (_downloaders.TryGetValue(key, out var downloader))
{
Childs.Remove(downloader);
_downloaders.Remove(key);
}
} }
// 最大并发数检测 // 最大并发数检测
@@ -85,7 +77,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建下载任务 /// 创建下载任务
/// </summary> /// </summary>
public UnityDownloadFileOperation DownloadFileAsync(PackageBundle bundle, string url, int timeout) public UnityDownloadFileOperation DownloadFileAsync(PackageBundle bundle, string url)
{ {
// 查询旧的下载器 // 查询旧的下载器
if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader)) if (_downloaders.TryGetValue(bundle.BundleGUID, out var oldDownloader))
@@ -99,7 +91,7 @@ namespace YooAsset
bool isRequestLocalFile = DownloadSystemHelper.IsRequestLocalFile(url); bool isRequestLocalFile = DownloadSystemHelper.IsRequestLocalFile(url);
if (isRequestLocalFile) if (isRequestLocalFile)
{ {
newDownloader = new UnityDownloadLocalFileOperation(_fileSystem, bundle, url, timeout); newDownloader = new UnityDownloadLocalFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }
@@ -107,13 +99,13 @@ namespace YooAsset
{ {
if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize) if (bundle.FileSize >= _fileSystem.ResumeDownloadMinimumSize)
{ {
newDownloader = new UnityDownloadResumeFileOperation(_fileSystem, bundle, url, timeout); newDownloader = new UnityDownloadResumeFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }
else else
{ {
newDownloader = new UnityDownloadNormalFileOperation(_fileSystem, bundle, url, timeout); newDownloader = new UnityDownloadNormalFileOperation(_fileSystem, bundle, url);
AddChildOperation(newDownloader); AddChildOperation(newDownloader);
_downloaders.Add(bundle.BundleGUID, newDownloader); _downloaders.Add(bundle.BundleGUID, newDownloader);
} }

View File

@@ -67,7 +67,7 @@ namespace YooAsset
} }
string url = GetRequestURL(); string url = GetRequestURL();
_unityDownloadFileOp = _fileSystem.DownloadCenter.DownloadFileAsync(Bundle, url, _options.Timeout); _unityDownloadFileOp = _fileSystem.DownloadCenter.DownloadFileAsync(Bundle, url);
_steps = ESteps.CheckRequest; _steps = ESteps.CheckRequest;
} }

View File

@@ -22,7 +22,7 @@ namespace YooAsset
/// </summary> /// </summary>
public int RefCount { private set; get; } public int RefCount { private set; get; }
internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout) : base(url, timeout) internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url) : base(url)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_bundle = bundle; _bundle = bundle;

View File

@@ -9,8 +9,8 @@ namespace YooAsset
private VerifyTempFileOperation _verifyOperation; private VerifyTempFileOperation _verifyOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal UnityDownloadLocalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60) internal UnityDownloadLocalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url, timeout) : base(fileSystem, bundle, url)
{ {
} }
internal override void InternalStart() internal override void InternalStart()
@@ -32,7 +32,6 @@ namespace YooAsset
if (File.Exists(_tempFilePath)) if (File.Exists(_tempFilePath))
File.Delete(_tempFilePath); File.Delete(_tempFilePath);
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -44,10 +43,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return; return;
}
// 检查网络错误 // 检查网络错误
if (CheckRequestResult()) if (CheckRequestResult())
@@ -161,9 +157,9 @@ namespace YooAsset
private void CreateWebRequest() private void CreateWebRequest()
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath); DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
handler.removeFileOnAbort = true; handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest(); _webRequest.SendWebRequest();

View File

@@ -9,8 +9,8 @@ namespace YooAsset
private VerifyTempFileOperation _verifyOperation; private VerifyTempFileOperation _verifyOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal UnityDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60) internal UnityDownloadNormalFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url, timeout) : base(fileSystem, bundle, url)
{ {
} }
internal override void InternalStart() internal override void InternalStart()
@@ -29,7 +29,6 @@ namespace YooAsset
if (File.Exists(_tempFilePath)) if (File.Exists(_tempFilePath))
File.Delete(_tempFilePath); File.Delete(_tempFilePath);
ResetTimeout();
CreateWebRequest(); CreateWebRequest();
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -41,10 +40,7 @@ namespace YooAsset
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return; return;
}
// 检查网络错误 // 检查网络错误
if (CheckRequestResult()) if (CheckRequestResult())
@@ -115,9 +111,9 @@ namespace YooAsset
private void CreateWebRequest() private void CreateWebRequest()
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath); DownloadHandlerFile handler = new DownloadHandlerFile(_tempFilePath);
handler.removeFileOnAbort = true; handler.removeFileOnAbort = true;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
_webRequest.SendWebRequest(); _webRequest.SendWebRequest();

View File

@@ -10,8 +10,8 @@ namespace YooAsset
private long _fileOriginLength = 0; private long _fileOriginLength = 0;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal UnityDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url, int timeout = 60) internal UnityDownloadResumeFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url)
: base(fileSystem, bundle, url, timeout) : base(fileSystem, bundle, url)
{ {
} }
internal override void InternalStart() internal override void InternalStart()
@@ -46,7 +46,6 @@ namespace YooAsset
} }
} }
ResetTimeout();
CreateWebRequest(fileBeginLength); CreateWebRequest(fileBeginLength);
_steps = ESteps.Download; _steps = ESteps.Download;
} }
@@ -58,10 +57,7 @@ namespace YooAsset
DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes; DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
{
CheckRequestTimeout();
return; return;
}
// 检查网络错误 // 检查网络错误
if (CheckRequestResult()) if (CheckRequestResult())
@@ -147,9 +143,9 @@ namespace YooAsset
} }
private void CreateWebRequest(long fileBeginLength) private void CreateWebRequest(long fileBeginLength)
{ {
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
var handler = new DownloadHandlerFile(_tempFilePath, true); var handler = new DownloadHandlerFile(_tempFilePath, true);
handler.removeFileOnAbort = false; handler.removeFileOnAbort = false;
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
_webRequest.downloadHandler = handler; _webRequest.downloadHandler = handler;
_webRequest.disposeDownloadHandlerOnDispose = true; _webRequest.disposeDownloadHandlerOnDispose = true;
if (fileBeginLength > 0) if (fileBeginLength > 0)

View File

@@ -56,7 +56,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 自定义参数:资源清单服务类 /// 自定义参数:资源清单服务类
/// </summary> /// </summary>
public IManifestServices ManifestServices { private set; get; } public IManifestRestoreServices ManifestServices { private set; get; }
#endregion #endregion
@@ -118,7 +118,7 @@ namespace YooAsset
} }
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES) else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
{ {
ManifestServices = (IManifestServices)value; ManifestServices = (IManifestRestoreServices)value;
} }
else else
{ {

View File

@@ -6,13 +6,13 @@ namespace YooAsset
private enum ESteps private enum ESteps
{ {
None, None,
DownloadAssetBundle, LoadWebAssetBundle,
Done, Done,
} }
private readonly DefaultWebRemoteFileSystem _fileSystem; private readonly DefaultWebRemoteFileSystem _fileSystem;
private readonly PackageBundle _bundle; private readonly PackageBundle _bundle;
private DownloadAssetBundleOperation _downloadAssetBundleOp; private LoadWebAssetBundleOperation _loadWebAssetBundleOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -23,51 +23,51 @@ namespace YooAsset
} }
internal override void InternalStart() internal override void InternalStart()
{ {
_steps = ESteps.DownloadAssetBundle; _steps = ESteps.LoadWebAssetBundle;
} }
internal override void InternalUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
if (_steps == ESteps.DownloadAssetBundle) if (_steps == ESteps.LoadWebAssetBundle)
{ {
if (_downloadAssetBundleOp == null) if (_loadWebAssetBundleOp == null)
{ {
string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName); string mainURL = _fileSystem.RemoteServices.GetRemoteMainURL(_bundle.FileName);
string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName); string fallbackURL = _fileSystem.RemoteServices.GetRemoteFallbackURL(_bundle.FileName);
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
options.SetURL(mainURL, fallbackURL); options.SetURL(mainURL, fallbackURL);
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadEncryptAssetBundleOperation(_bundle, options, true, _fileSystem.DecryptionServices); _loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices);
_downloadAssetBundleOp.StartOperation(); _loadWebAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_loadWebAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache); _loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache);
_downloadAssetBundleOp.StartOperation(); _loadWebAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_loadWebAssetBundleOp);
} }
} }
_downloadAssetBundleOp.UpdateOperation(); _loadWebAssetBundleOp.UpdateOperation();
DownloadProgress = _downloadAssetBundleOp.DownloadProgress; DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
DownloadedBytes = _downloadAssetBundleOp.DownloadedBytes; DownloadedBytes = _loadWebAssetBundleOp.DownloadedBytes;
Progress = _downloadAssetBundleOp.Progress; Progress = _loadWebAssetBundleOp.Progress;
if (_downloadAssetBundleOp.IsDone == false) if (_loadWebAssetBundleOp.IsDone == false)
return; return;
if (_downloadAssetBundleOp.Status == EOperationStatus.Succeed) if (_loadWebAssetBundleOp.Status == EOperationStatus.Succeed)
{ {
var assetBundle = _downloadAssetBundleOp.Result; var assetBundle = _loadWebAssetBundleOp.Result;
if (assetBundle == null) if (assetBundle == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DownloadAssetBundleOperation)} loaded asset bundle is null !"; Error = $"{nameof(DWRFSLoadAssetBundleOperation)} loaded asset bundle is null !";
} }
else else
{ {
@@ -80,7 +80,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _downloadAssetBundleOp.Error; Error = _loadWebAssetBundleOp.Error;
} }
} }
} }

View File

@@ -64,7 +64,7 @@ namespace YooAsset
if (_loadWebPackageManifestOp == null) if (_loadWebPackageManifestOp == null)
{ {
string packageHash = _requestWebPackageHashOp.PackageHash; string packageHash = _requestWebPackageHashOp.PackageHash;
_loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash); _loadWebPackageManifestOp = new LoadWebRemotePackageManifestOperation(_fileSystem, _packageVersion, packageHash, _timeout);
_loadWebPackageManifestOp.StartOperation(); _loadWebPackageManifestOp.StartOperation();
AddChildOperation(_loadWebPackageManifestOp); AddChildOperation(_loadWebPackageManifestOp);
} }

View File

@@ -15,6 +15,7 @@ namespace YooAsset
private readonly DefaultWebRemoteFileSystem _fileSystem; private readonly DefaultWebRemoteFileSystem _fileSystem;
private readonly string _packageVersion; private readonly string _packageVersion;
private readonly string _packageHash; private readonly string _packageHash;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp; private UnityWebDataRequestOperation _webDataRequestOp;
private DeserializeManifestOperation _deserializer; private DeserializeManifestOperation _deserializer;
private int _requestCount = 0; private int _requestCount = 0;
@@ -26,11 +27,12 @@ namespace YooAsset
public PackageManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash) internal LoadWebRemotePackageManifestOperation(DefaultWebRemoteFileSystem fileSystem, string packageVersion, string packageHash, int timeout)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_packageVersion = packageVersion; _packageVersion = packageVersion;
_packageHash = packageHash; _packageHash = packageHash;
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -48,7 +50,7 @@ namespace YooAsset
{ {
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion); string fileName = YooAssetSettingsData.GetManifestBinaryFileName(_fileSystem.PackageName, _packageVersion);
string url = GetWebRequestURL(fileName); string url = GetWebRequestURL(fileName);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation(); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp); AddChildOperation(_webDataRequestOp);
} }

View File

@@ -65,7 +65,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 自定义参数:资源清单服务类 /// 自定义参数:资源清单服务类
/// </summary> /// </summary>
public IManifestServices ManifestServices { private set; get; } public IManifestRestoreServices ManifestServices { private set; get; }
#endregion #endregion
@@ -123,7 +123,7 @@ namespace YooAsset
} }
else if (name == FileSystemParametersDefine.MANIFEST_SERVICES) else if (name == FileSystemParametersDefine.MANIFEST_SERVICES)
{ {
ManifestServices = (IManifestServices)value; ManifestServices = (IManifestRestoreServices)value;
} }
else else
{ {

View File

@@ -32,23 +32,7 @@ namespace YooAsset
{ {
if (_loadCatalogFileOp == null) if (_loadCatalogFileOp == null)
{ {
#if UNITY_EDITOR _loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem, 60);
/*
// 兼容性初始化
// 说明:内置文件系统在编辑器下运行时需要动态生成
string packageRoot = _fileSystem.FileRoot;
bool result = DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(_fileSystem.ManifestServices, _fileSystem.PackageName, packageRoot);
if (result == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Create package catalog file failed ! See the detail error in console !";
return;
}
*/
#endif
_loadCatalogFileOp = new LoadWebServerCatalogFileOperation(_fileSystem);
_loadCatalogFileOp.StartOperation(); _loadCatalogFileOp.StartOperation();
AddChildOperation(_loadCatalogFileOp); AddChildOperation(_loadCatalogFileOp);
} }

View File

@@ -6,13 +6,13 @@ namespace YooAsset
private enum ESteps private enum ESteps
{ {
None, None,
DownloadAssetBundle, LoadWebAssetBundle,
Done, Done,
} }
private readonly DefaultWebServerFileSystem _fileSystem; private readonly DefaultWebServerFileSystem _fileSystem;
private readonly PackageBundle _bundle; private readonly PackageBundle _bundle;
private DownloadAssetBundleOperation _downloadAssetBundleOp; private LoadWebAssetBundleOperation _loadWebAssetBundleOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -23,51 +23,51 @@ namespace YooAsset
} }
internal override void InternalStart() internal override void InternalStart()
{ {
_steps = ESteps.DownloadAssetBundle; _steps = ESteps.LoadWebAssetBundle;
} }
internal override void InternalUpdate() internal override void InternalUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
if (_steps == ESteps.DownloadAssetBundle) if (_steps == ESteps.LoadWebAssetBundle)
{ {
if (_downloadAssetBundleOp == null) if (_loadWebAssetBundleOp == null)
{ {
string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle); string fileLoadPath = _fileSystem.GetWebFileLoadPath(_bundle);
string mainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath); string mainURL = DownloadSystemHelper.ConvertToWWWPath(fileLoadPath);
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue, 60); DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
options.SetURL(mainURL, mainURL); options.SetURL(mainURL, mainURL);
if (_bundle.Encrypted) if (_bundle.Encrypted)
{ {
_downloadAssetBundleOp = new DownloadEncryptAssetBundleOperation(_bundle, options, true, _fileSystem.DecryptionServices); _loadWebAssetBundleOp = new LoadWebEncryptAssetBundleOperation(_bundle, options, _fileSystem.DecryptionServices);
_downloadAssetBundleOp.StartOperation(); _loadWebAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_loadWebAssetBundleOp);
} }
else else
{ {
_downloadAssetBundleOp = new DownloadNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache); _loadWebAssetBundleOp = new LoadWebNormalAssetBundleOperation(_bundle, options, _fileSystem.DisableUnityWebCache);
_downloadAssetBundleOp.StartOperation(); _loadWebAssetBundleOp.StartOperation();
AddChildOperation(_downloadAssetBundleOp); AddChildOperation(_loadWebAssetBundleOp);
} }
} }
_downloadAssetBundleOp.UpdateOperation(); _loadWebAssetBundleOp.UpdateOperation();
DownloadProgress = _downloadAssetBundleOp.DownloadProgress; DownloadProgress = _loadWebAssetBundleOp.DownloadProgress;
DownloadedBytes = _downloadAssetBundleOp.DownloadedBytes; DownloadedBytes = _loadWebAssetBundleOp.DownloadedBytes;
Progress = _downloadAssetBundleOp.Progress; Progress = _loadWebAssetBundleOp.Progress;
if (_downloadAssetBundleOp.IsDone == false) if (_loadWebAssetBundleOp.IsDone == false)
return; return;
if (_downloadAssetBundleOp.Status == EOperationStatus.Succeed) if (_loadWebAssetBundleOp.Status == EOperationStatus.Succeed)
{ {
var assetBundle = _downloadAssetBundleOp.Result; var assetBundle = _loadWebAssetBundleOp.Result;
if (assetBundle == null) if (assetBundle == null)
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = $"{nameof(DownloadAssetBundleOperation)} loaded asset bundle is null !"; Error = $"{nameof(DWSFSLoadAssetBundleOperation)} loaded asset bundle is null !";
} }
else else
{ {
@@ -80,7 +80,7 @@ namespace YooAsset
{ {
_steps = ESteps.Done; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = _downloadAssetBundleOp.Error; Error = _loadWebAssetBundleOp.Error;
} }
} }
} }

View File

@@ -64,7 +64,7 @@ namespace YooAsset
if (_loadWebPackageManifestOp == null) if (_loadWebPackageManifestOp == null)
{ {
string packageHash = _requestWebPackageHashOp.PackageHash; string packageHash = _requestWebPackageHashOp.PackageHash;
_loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash); _loadWebPackageManifestOp = new LoadWebServerPackageManifestOperation(_fileSystem, _packageVersion, packageHash, _timeout);
_loadWebPackageManifestOp.StartOperation(); _loadWebPackageManifestOp.StartOperation();
AddChildOperation(_loadWebPackageManifestOp); AddChildOperation(_loadWebPackageManifestOp);
} }

View File

@@ -1,7 +1,4 @@
using System; using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
@@ -16,12 +13,14 @@ namespace YooAsset
} }
private readonly DefaultWebServerFileSystem _fileSystem; private readonly DefaultWebServerFileSystem _fileSystem;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp; private UnityWebDataRequestOperation _webDataRequestOp;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem) internal LoadWebServerCatalogFileOperation(DefaultWebServerFileSystem fileSystem, int timeout)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -38,7 +37,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetCatalogBinaryFileLoadPath(); string filePath = _fileSystem.GetCatalogBinaryFileLoadPath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation(); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp); AddChildOperation(_webDataRequestOp);
} }

View File

@@ -15,6 +15,7 @@ namespace YooAsset
private readonly DefaultWebServerFileSystem _fileSystem; private readonly DefaultWebServerFileSystem _fileSystem;
private readonly string _packageVersion; private readonly string _packageVersion;
private readonly string _packageHash; private readonly string _packageHash;
private readonly int _timeout;
private UnityWebDataRequestOperation _webDataRequestOp; private UnityWebDataRequestOperation _webDataRequestOp;
private DeserializeManifestOperation _deserializer; private DeserializeManifestOperation _deserializer;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -25,11 +26,12 @@ namespace YooAsset
public PackageManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash) internal LoadWebServerPackageManifestOperation(DefaultWebServerFileSystem fileSystem, string packageVersion, string packageHash, int timeout)
{ {
_fileSystem = fileSystem; _fileSystem = fileSystem;
_packageVersion = packageVersion; _packageVersion = packageVersion;
_packageHash = packageHash; _packageHash = packageHash;
_timeout = timeout;
} }
internal override void InternalStart() internal override void InternalStart()
{ {
@@ -46,7 +48,7 @@ namespace YooAsset
{ {
string filePath = _fileSystem.GetWebPackageManifestFilePath(_packageVersion); string filePath = _fileSystem.GetWebPackageManifestFilePath(_packageVersion);
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_webDataRequestOp = new UnityWebDataRequestOperation(url); _webDataRequestOp = new UnityWebDataRequestOperation(url, _timeout);
_webDataRequestOp.StartOperation(); _webDataRequestOp.StartOperation();
AddChildOperation(_webDataRequestOp); AddChildOperation(_webDataRequestOp);
} }

View File

@@ -11,6 +11,7 @@ namespace YooAsset
public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION"; public const string APPEND_FILE_EXTENSION = "APPEND_FILE_EXTENSION";
public const string DISABLE_CATALOG_FILE = "DISABLE_CATALOG_FILE"; public const string DISABLE_CATALOG_FILE = "DISABLE_CATALOG_FILE";
public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE"; public const string DISABLE_UNITY_WEB_CACHE = "DISABLE_UNITY_WEB_CACHE";
public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLOAD";
public const string DOWNLOAD_MAX_CONCURRENCY = "DOWNLOAD_MAX_CONCURRENCY"; public const string DOWNLOAD_MAX_CONCURRENCY = "DOWNLOAD_MAX_CONCURRENCY";
public const string DOWNLOAD_MAX_REQUEST_PER_FRAME = "DOWNLOAD_MAX_REQUEST_PER_FRAME"; public const string DOWNLOAD_MAX_REQUEST_PER_FRAME = "DOWNLOAD_MAX_REQUEST_PER_FRAME";
public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE"; public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE";

View File

@@ -8,11 +8,6 @@ namespace YooAsset
/// </summary> /// </summary>
public readonly int FailedTryAgain; public readonly int FailedTryAgain;
/// <summary>
/// 超时时间
/// </summary>
public readonly int Timeout;
/// <summary> /// <summary>
/// 主资源地址 /// 主资源地址
/// </summary> /// </summary>
@@ -28,10 +23,9 @@ namespace YooAsset
/// </summary> /// </summary>
public string ImportFilePath { set; get; } public string ImportFilePath { set; get; }
public DownloadFileOptions(int failedTryAgain, int timeout) public DownloadFileOptions(int failedTryAgain)
{ {
FailedTryAgain = failedTryAgain; FailedTryAgain = failedTryAgain;
Timeout = timeout;
} }
/// <summary> /// <summary>

View File

@@ -2,7 +2,7 @@
namespace YooAsset namespace YooAsset
{ {
internal abstract class DownloadAssetBundleOperation : AsyncOperationBase internal abstract class LoadWebAssetBundleOperation : AsyncOperationBase
{ {
/// <summary> /// <summary>
/// AssetBundle对象 /// AssetBundle对象

View File

@@ -2,7 +2,7 @@
namespace YooAsset namespace YooAsset
{ {
internal class DownloadEncryptAssetBundleOperation : DownloadAssetBundleOperation internal class LoadWebEncryptAssetBundleOperation : LoadWebAssetBundleOperation
{ {
protected enum ESteps protected enum ESteps
{ {
@@ -13,22 +13,20 @@ namespace YooAsset
Done, Done,
} }
private UnityWebDataRequestOperation _unityWebDataRequestOp;
private readonly PackageBundle _bundle; private readonly PackageBundle _bundle;
private readonly DownloadFileOptions _options; private readonly DownloadFileOptions _options;
private readonly bool _checkTimeout;
private readonly IWebDecryptionServices _decryptionServices; private readonly IWebDecryptionServices _decryptionServices;
private UnityWebDataRequestOperation _unityWebDataRequestOp;
protected int _requestCount = 0; protected int _requestCount = 0;
protected float _tryAgainTimer; protected float _tryAgainTimer;
protected int _failedTryAgain; protected int _failedTryAgain;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool checkTimeout, IWebDecryptionServices decryptionServices) internal LoadWebEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, IWebDecryptionServices decryptionServices)
{ {
_bundle = bundle; _bundle = bundle;
_options = options; _options = options;
_checkTimeout = checkTimeout;
_decryptionServices = decryptionServices; _decryptionServices = decryptionServices;
} }
internal override void InternalStart() internal override void InternalStart()
@@ -53,10 +51,9 @@ namespace YooAsset
} }
string url = GetRequestURL(); string url = GetRequestURL();
_unityWebDataRequestOp = new UnityWebDataRequestOperation(url, _options.Timeout); _unityWebDataRequestOp = new UnityWebDataRequestOperation(url, 0);
_unityWebDataRequestOp.StartOperation(); _unityWebDataRequestOp.StartOperation();
if (_checkTimeout == false) AddChildOperation(_unityWebDataRequestOp);
_unityWebDataRequestOp.DontCheckTimeout();
_steps = ESteps.CheckRequest; _steps = ESteps.CheckRequest;
} }
@@ -119,12 +116,6 @@ namespace YooAsset
} }
} }
} }
internal override void InternalAbort()
{
_steps = ESteps.Done;
if (_unityWebDataRequestOp != null)
_unityWebDataRequestOp.AbortOperation();
}
/// <summary> /// <summary>
/// 加载加密资源文件 /// 加载加密资源文件

View File

@@ -2,7 +2,7 @@
namespace YooAsset namespace YooAsset
{ {
internal class DownloadNormalAssetBundleOperation : DownloadAssetBundleOperation internal class LoadWebNormalAssetBundleOperation : LoadWebAssetBundleOperation
{ {
protected enum ESteps protected enum ESteps
{ {
@@ -13,18 +13,18 @@ namespace YooAsset
Done, Done,
} }
private UnityAssetBundleRequestOperation _unityAssetBundleRequestOp;
private readonly PackageBundle _bundle; private readonly PackageBundle _bundle;
private readonly DownloadFileOptions _options; private readonly DownloadFileOptions _options;
private readonly bool _disableUnityWebCache; private readonly bool _disableUnityWebCache;
private UnityAssetBundleRequestOperation _unityAssetBundleRequestOp;
protected int _requestCount = 0; protected int _requestCount = 0;
protected float _tryAgainTimer; protected float _tryAgainTimer;
protected int _failedTryAgain; protected int _failedTryAgain;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
internal DownloadNormalAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool disableUnityWebCache) internal LoadWebNormalAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, bool disableUnityWebCache)
{ {
_bundle = bundle; _bundle = bundle;
_options = options; _options = options;
@@ -43,8 +43,9 @@ namespace YooAsset
if (_steps == ESteps.CreateRequest) if (_steps == ESteps.CreateRequest)
{ {
string url = GetRequestURL(); string url = GetRequestURL();
_unityAssetBundleRequestOp = new UnityAssetBundleRequestOperation(_bundle, _disableUnityWebCache, url, _options.Timeout); _unityAssetBundleRequestOp = new UnityAssetBundleRequestOperation(_bundle, _disableUnityWebCache, url);
_unityAssetBundleRequestOp.StartOperation(); _unityAssetBundleRequestOp.StartOperation();
AddChildOperation(_unityAssetBundleRequestOp);
_steps = ESteps.CheckRequest; _steps = ESteps.CheckRequest;
} }
@@ -96,12 +97,6 @@ namespace YooAsset
} }
} }
} }
internal override void InternalAbort()
{
_steps = ESteps.Done;
if (_unityAssetBundleRequestOp != null)
_unityAssetBundleRequestOp.AbortOperation();
}
/// <summary> /// <summary>
/// 获取网络请求地址 /// 获取网络请求地址

View File

@@ -3,7 +3,7 @@ using System.Reflection;
namespace YooAsset namespace YooAsset
{ {
public static class PakcageInvokeBuilder public static class PackageInvokeBuilder
{ {
/// <summary> /// <summary>
/// 调用Editro类来执行构建资源包任务 /// 调用Editro类来执行构建资源包任务
@@ -32,7 +32,7 @@ namespace YooAsset
#else #else
namespace YooAsset namespace YooAsset
{ {
public static class PakcageInvokeBuilder public static class PackageInvokeBuilder
{ {
public static PackageInvokeBuildResult InvokeBuilder(PackageInvokeBuildParam buildParam) public static PackageInvokeBuildResult InvokeBuilder(PackageInvokeBuildParam buildParam)
{ {

View File

@@ -62,6 +62,11 @@ namespace YooAsset
/// </summary> /// </summary>
public void TryUnloadUnusedAsset(AssetInfo assetInfo, int loopCount) public void TryUnloadUnusedAsset(AssetInfo assetInfo, int loopCount)
{ {
if (assetInfo == null)
{
YooLogger.Error($"{nameof(AssetInfo)} is null !");
return;
}
if (assetInfo.IsInvalid) if (assetInfo.IsInvalid)
{ {
YooLogger.Error($"Failed to unload asset ! {assetInfo.Error}"); YooLogger.Error($"Failed to unload asset ! {assetInfo.Error}");
@@ -73,31 +78,29 @@ namespace YooAsset
loopCount--; loopCount--;
// 卸载主资源包加载器 // 卸载主资源包加载器
string mainBundleName = _bundleQuery.GetMainBundleName(assetInfo); string mainBundleName = _bundleQuery.GetMainBundleName(assetInfo.Asset.BundleID);
var mainLoader = TryGetBundleFileLoader(mainBundleName); var mainLoader = TryGetBundleFileLoader(mainBundleName);
if (mainLoader != null) if (mainLoader != null)
{ {
mainLoader.TryDestroyProviders(); mainLoader.TryDestroyProviders();
if (mainLoader.CanDestroyLoader()) if (mainLoader.CanDestroyLoader())
{ {
string bundleName = mainLoader.LoadBundleInfo.Bundle.BundleName;
mainLoader.DestroyLoader(); mainLoader.DestroyLoader();
LoaderDic.Remove(bundleName); LoaderDic.Remove(mainBundleName);
} }
} }
// 卸载依赖资源包加载器 // 卸载依赖资源包加载器
string[] dependBundleNames = _bundleQuery.GetDependBundleNames(assetInfo); foreach (var dependID in assetInfo.Asset.DependBundleIDs)
foreach (var dependBundleName in dependBundleNames)
{ {
string dependBundleName = _bundleQuery.GetMainBundleName(dependID);
var dependLoader = TryGetBundleFileLoader(dependBundleName); var dependLoader = TryGetBundleFileLoader(dependBundleName);
if (dependLoader != null) if (dependLoader != null)
{ {
if (dependLoader.CanDestroyLoader()) if (dependLoader.CanDestroyLoader())
{ {
string bundleName = dependLoader.LoadBundleInfo.Bundle.BundleName;
dependLoader.DestroyLoader(); dependLoader.DestroyLoader();
LoaderDic.Remove(bundleName); LoaderDic.Remove(dependBundleName);
} }
} }
} }
@@ -296,8 +299,8 @@ namespace YooAsset
} }
internal List<LoadBundleFileOperation> CreateDependBundleFileLoaders(AssetInfo assetInfo) internal List<LoadBundleFileOperation> CreateDependBundleFileLoaders(AssetInfo assetInfo)
{ {
BundleInfo[] bundleInfos = _bundleQuery.GetDependBundleInfos(assetInfo); List<BundleInfo> bundleInfos = _bundleQuery.GetDependBundleInfos(assetInfo);
List<LoadBundleFileOperation> result = new List<LoadBundleFileOperation>(bundleInfos.Length); List<LoadBundleFileOperation> result = new List<LoadBundleFileOperation>(bundleInfos.Count);
foreach (var bundleInfo in bundleInfos) foreach (var bundleInfo in bundleInfos)
{ {
var bundleLoader = CreateBundleFileLoaderInternal(bundleInfo); var bundleLoader = CreateBundleFileLoaderInternal(bundleInfo);

View File

@@ -36,9 +36,9 @@ namespace YooAsset
/// <summary> /// <summary>
/// 创建下载器 /// 创建下载器
/// </summary> /// </summary>
public FSDownloadFileOperation CreateDownloader(int failedTryAgain, int timeout) public FSDownloadFileOperation CreateDownloader(int failedTryAgain)
{ {
DownloadFileOptions options = new DownloadFileOptions(failedTryAgain, timeout); DownloadFileOptions options = new DownloadFileOptions(failedTryAgain);
options.ImportFilePath = _importFilePath; options.ImportFilePath = _importFilePath;
return _fileSystem.DownloadFileAsync(Bundle, options); return _fileSystem.DownloadFileAsync(Bundle, options);
} }

View File

@@ -1,4 +1,6 @@
 using System.Collections;
using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
internal interface IBundleQuery internal interface IBundleQuery
@@ -11,21 +13,11 @@ namespace YooAsset
/// <summary> /// <summary>
/// 获取依赖的资源包信息集合 /// 获取依赖的资源包信息集合
/// </summary> /// </summary>
BundleInfo[] GetDependBundleInfos(AssetInfo assetPath); List<BundleInfo> GetDependBundleInfos(AssetInfo assetPath);
/// <summary> /// <summary>
/// 获取主资源包名称 /// 获取主资源包名称
/// </summary> /// </summary>
string GetMainBundleName(int bundleID); string GetMainBundleName(int bundleID);
/// <summary>
/// 获取主资源包名称
/// </summary>
string GetMainBundleName(AssetInfo assetInfo);
/// <summary>
/// 获取依赖的资源包名称集合
/// </summary>
string[] GetDependBundleNames(AssetInfo assetInfo);
} }
} }

View File

@@ -34,15 +34,16 @@ namespace YooAsset
ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options); ClearCacheFilesOperation ClearCacheFilesAsync(ClearCacheFilesOptions options);
// 下载相关 // 下载相关
ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain);
ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain);
ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout); ResourceDownloaderOperation CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain);
// 解压相关 // 解压相关
ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout); ResourceUnpackerOperation CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain);
ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout); ResourceUnpackerOperation CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain);
// 导入相关 // 导入相关
ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout); ResourceImporterOperation CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain);
ResourceImporterOperation CreateResourceImporterByFileInfos(ImportFileInfo[] fileInfos, int importingMaxNumber, int failedTryAgain);
} }
} }

View File

@@ -44,7 +44,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 序列化(二进制文件) /// 序列化(二进制文件)
/// </summary> /// </summary>
public static void SerializeToBinary(string savePath, PackageManifest manifest, IManifestServices services) public static void SerializeToBinary(string savePath, PackageManifest manifest, IManifestProcessServices services)
{ {
using (FileStream fs = new FileStream(savePath, FileMode.Create)) using (FileStream fs = new FileStream(savePath, FileMode.Create))
{ {
@@ -124,7 +124,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 反序列化(二进制文件) /// 反序列化(二进制文件)
/// </summary> /// </summary>
public static PackageManifest DeserializeFromBinary(byte[] binaryData, IManifestServices services) public static PackageManifest DeserializeFromBinary(byte[] binaryData, IManifestRestoreServices services)
{ {
// 创建缓存器 // 创建缓存器
BufferReader buffer; BufferReader buffer;

View File

@@ -40,7 +40,6 @@ namespace YooAsset
private readonly string _packageName; private readonly string _packageName;
private readonly int _downloadingMaxNumber; private readonly int _downloadingMaxNumber;
private readonly int _failedTryAgain; private readonly int _failedTryAgain;
private readonly int _timeout;
private readonly List<BundleInfo> _bundleInfoList; private readonly List<BundleInfo> _bundleInfoList;
private readonly List<FSDownloadFileOperation> _downloaders = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT); private readonly List<FSDownloadFileOperation> _downloaders = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT);
private readonly List<FSDownloadFileOperation> _removeList = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT); private readonly List<FSDownloadFileOperation> _removeList = new List<FSDownloadFileOperation>(MAX_LOADER_COUNT);
@@ -102,13 +101,12 @@ namespace YooAsset
public DownloadFileBegin DownloadFileBeginCallback { set; get; } public DownloadFileBegin DownloadFileBeginCallback { set; get; }
internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal DownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
{ {
_packageName = packageName; _packageName = packageName;
_bundleInfoList = downloadList; _bundleInfoList = downloadList;
_downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ; _downloadingMaxNumber = UnityEngine.Mathf.Clamp(downloadingMaxNumber, 1, MAX_LOADER_COUNT); ;
_failedTryAgain = failedTryAgain; _failedTryAgain = failedTryAgain;
_timeout = timeout;
// 设置包裹名称 (fix #210) // 设置包裹名称 (fix #210)
SetPackageName(packageName); SetPackageName(packageName);
@@ -203,7 +201,7 @@ namespace YooAsset
{ {
int index = _bundleInfoList.Count - 1; int index = _bundleInfoList.Count - 1;
var bundleInfo = _bundleInfoList[index]; var bundleInfo = _bundleInfoList[index];
var downloader = bundleInfo.CreateDownloader(_failedTryAgain, _timeout); var downloader = bundleInfo.CreateDownloader(_failedTryAgain);
downloader.StartOperation(); downloader.StartOperation();
this.AddChildOperation(downloader); this.AddChildOperation(downloader);
@@ -374,52 +372,52 @@ namespace YooAsset
public sealed class ResourceDownloaderOperation : DownloaderOperation public sealed class ResourceDownloaderOperation : DownloaderOperation
{ {
internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal ResourceDownloaderOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{ {
} }
/// <summary> /// <summary>
/// 创建空的下载器 /// 创建空的下载器
/// </summary> /// </summary>
internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int downloadingMaxNumber, int failedTryAgain, int timeout) internal static ResourceDownloaderOperation CreateEmptyDownloader(string packageName, int downloadingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceDownloaderOperation(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(packageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
} }
public sealed class ResourceUnpackerOperation : DownloaderOperation public sealed class ResourceUnpackerOperation : DownloaderOperation
{ {
internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal ResourceUnpackerOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{ {
} }
/// <summary> /// <summary>
/// 创建空的解压器 /// 创建空的解压器
/// </summary> /// </summary>
internal static ResourceUnpackerOperation CreateEmptyUnpacker(string packageName, int upackingMaxNumber, int failedTryAgain, int timeout) internal static ResourceUnpackerOperation CreateEmptyUnpacker(string packageName, int upackingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceUnpackerOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue); var operation = new ResourceUnpackerOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain);
return operation; return operation;
} }
} }
public sealed class ResourceImporterOperation : DownloaderOperation public sealed class ResourceImporterOperation : DownloaderOperation
{ {
internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain, int timeout) internal ResourceImporterOperation(string packageName, List<BundleInfo> downloadList, int downloadingMaxNumber, int failedTryAgain)
: base(packageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout) : base(packageName, downloadList, downloadingMaxNumber, failedTryAgain)
{ {
} }
/// <summary> /// <summary>
/// 创建空的导入器 /// 创建空的导入器
/// </summary> /// </summary>
internal static ResourceImporterOperation CreateEmptyImporter(string packageName, int upackingMaxNumber, int failedTryAgain, int timeout) internal static ResourceImporterOperation CreateEmptyImporter(string packageName, int upackingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = new List<BundleInfo>(); List<BundleInfo> downloadList = new List<BundleInfo>();
var operation = new ResourceImporterOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain, int.MaxValue); var operation = new ResourceImporterOperation(packageName, downloadList, upackingMaxNumber, failedTryAgain);
return operation; return operation;
} }
} }

View File

@@ -20,7 +20,7 @@ namespace YooAsset
Done, Done,
} }
private readonly IManifestServices _services; private readonly IManifestRestoreServices _services;
private byte[] _sourceData; private byte[] _sourceData;
private BufferReader _buffer; private BufferReader _buffer;
private int _packageAssetCount; private int _packageAssetCount;
@@ -33,7 +33,7 @@ namespace YooAsset
/// </summary> /// </summary>
public PackageManifest Manifest { private set; get; } public PackageManifest Manifest { private set; get; }
public DeserializeManifestOperation(IManifestServices services, byte[] binaryData) public DeserializeManifestOperation(IManifestRestoreServices services, byte[] binaryData)
{ {
_services = services; _services = services;
_sourceData = binaryData; _sourceData = binaryData;

View File

@@ -107,11 +107,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest); List<BundleInfo> downloadList = _impl.GetDownloadListByAll(_manifest);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
@@ -127,11 +127,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag }); List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, new string[] { tag });
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
@@ -147,11 +147,11 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags); List<BundleInfo> downloadList = _impl.GetDownloadListByTags(_manifest, tags);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
@@ -167,7 +167,7 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
} }
List<AssetInfo> assetInfos = new List<AssetInfo>(); List<AssetInfo> assetInfos = new List<AssetInfo>();
@@ -175,7 +175,7 @@ namespace YooAsset
assetInfos.Add(assetInfo); assetInfos.Add(assetInfo);
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload); List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
@@ -191,7 +191,7 @@ namespace YooAsset
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !"); YooLogger.Warning($"{nameof(PreDownloadContentOperation)} status is not succeed !");
return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain, timeout); return ResourceDownloaderOperation.CreateEmptyDownloader(_impl.PackageName, downloadingMaxNumber, failedTryAgain);
} }
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length); List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -202,7 +202,7 @@ namespace YooAsset
} }
List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload); List<BundleInfo> downloadList = _impl.GetDownloadListByPaths(_manifest, assetInfos.ToArray(), recursiveDownload);
var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(_impl.PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
} }

View File

@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using System.Diagnostics; using System.Diagnostics;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@@ -171,10 +170,10 @@ namespace YooAsset
} }
/// <summary> /// <summary>
/// 获取依赖列表 /// 获取资源对象的依赖列表(框架层查询结果)
/// 注意:传入的资源对象一定合法有效! /// 注意:传入的资源对象一定合法有效!
/// </summary> /// </summary>
public PackageBundle[] GetAllDependencies(PackageAsset packageAsset) public List<PackageBundle> GetAssetAllDependencies(PackageAsset packageAsset)
{ {
List<PackageBundle> result = new List<PackageBundle>(packageAsset.DependBundleIDs.Length); List<PackageBundle> result = new List<PackageBundle>(packageAsset.DependBundleIDs.Length);
foreach (var dependID in packageAsset.DependBundleIDs) foreach (var dependID in packageAsset.DependBundleIDs)
@@ -182,14 +181,14 @@ namespace YooAsset
var dependBundle = GetMainPackageBundle(dependID); var dependBundle = GetMainPackageBundle(dependID);
result.Add(dependBundle); result.Add(dependBundle);
} }
return result.ToArray(); return result;
} }
/// <summary> /// <summary>
/// 获取依赖列表 /// 获取资源包的依赖列表(引擎层查询结果)
/// 注意:传入的资源包对象一定合法有效! /// 注意:传入的资源包对象一定合法有效!
/// </summary> /// </summary>
public PackageBundle[] GetAllDependencies(PackageBundle packageBundle) public List<PackageBundle> GetBundleAllDependencies(PackageBundle packageBundle)
{ {
List<PackageBundle> result = new List<PackageBundle>(packageBundle.DependBundleIDs.Length); List<PackageBundle> result = new List<PackageBundle>(packageBundle.DependBundleIDs.Length);
foreach (var dependID in packageBundle.DependBundleIDs) foreach (var dependID in packageBundle.DependBundleIDs)
@@ -197,7 +196,7 @@ namespace YooAsset
var dependBundle = GetMainPackageBundle(dependID); var dependBundle = GetMainPackageBundle(dependID);
result.Add(dependBundle); result.Add(dependBundle);
} }
return result.ToArray(); return result;
} }
/// <summary> /// <summary>
@@ -211,17 +210,17 @@ namespace YooAsset
/// <summary> /// <summary>
/// 尝试获取包裹的资源包 /// 尝试获取包裹的资源包
/// </summary> /// </summary>
public bool TryGetPackageBundleByBundleName(string bundleName, out PackageBundle result) public bool TryGetPackageBundleByFileName(string fileName, out PackageBundle result)
{ {
return BundleDic1.TryGetValue(bundleName, out result); return BundleDic2.TryGetValue(fileName, out result);
} }
/// <summary> /// <summary>
/// 尝试获取包裹的资源包 /// 尝试获取包裹的资源包
/// </summary> /// </summary>
public bool TryGetPackageBundleByFileName(string fileName, out PackageBundle result) public bool TryGetPackageBundleByBundleName(string bundleName, out PackageBundle result)
{ {
return BundleDic2.TryGetValue(fileName, out result); return BundleDic1.TryGetValue(bundleName, out result);
} }
/// <summary> /// <summary>
@@ -245,13 +244,14 @@ namespace YooAsset
/// </summary> /// </summary>
public AssetInfo[] GetAllAssetInfos() public AssetInfo[] GetAllAssetInfos()
{ {
List<AssetInfo> result = new List<AssetInfo>(AssetList.Count); AssetInfo[] result = new AssetInfo[AssetList.Count];
foreach (var packageAsset in AssetList) for (int i = 0; i < AssetList.Count; i++)
{ {
var packageAsset = AssetList[i];
AssetInfo assetInfo = new AssetInfo(PackageName, packageAsset, null); AssetInfo assetInfo = new AssetInfo(PackageName, packageAsset, null);
result.Add(assetInfo); result[i] = assetInfo;
} }
return result.ToArray(); return result;
} }
/// <summary> /// <summary>
@@ -259,7 +259,7 @@ namespace YooAsset
/// </summary> /// </summary>
public AssetInfo[] GetAssetInfosByTags(string[] tags) public AssetInfo[] GetAssetInfosByTags(string[] tags)
{ {
List<AssetInfo> result = new List<AssetInfo>(100); List<AssetInfo> result = new List<AssetInfo>(AssetList.Count);
foreach (var packageAsset in AssetList) foreach (var packageAsset in AssetList)
{ {
if (packageAsset.HasTag(tags)) if (packageAsset.HasTag(tags))

View File

@@ -10,7 +10,7 @@ namespace YooAsset
buildParam.InvokeAssmeblyName = "YooAsset.Editor"; buildParam.InvokeAssmeblyName = "YooAsset.Editor";
buildParam.InvokeClassFullName = "YooAsset.Editor.AssetBundleSimulateBuilder"; buildParam.InvokeClassFullName = "YooAsset.Editor.AssetBundleSimulateBuilder";
buildParam.InvokeMethodName = "SimulateBuild"; buildParam.InvokeMethodName = "SimulateBuild";
return PakcageInvokeBuilder.InvokeBuilder(buildParam); return PackageInvokeBuilder.InvokeBuilder(buildParam);
} }
} }
} }

View File

@@ -104,44 +104,50 @@ namespace YooAsset
} }
// 下载相关 // 下载相关
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByAll(int downloadingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = GetDownloadListByAll(ActiveManifest); List<BundleInfo> downloadList = GetDownloadListByAll(ActiveManifest);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByTags(string[] tags, int downloadingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = GetDownloadListByTags(ActiveManifest, tags); List<BundleInfo> downloadList = GetDownloadListByTags(ActiveManifest, tags);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout) ResourceDownloaderOperation IPlayMode.CreateResourceDownloaderByPaths(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> downloadList = GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload); List<BundleInfo> downloadList = GetDownloadListByPaths(ActiveManifest, assetInfos, recursiveDownload);
var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain, timeout); var operation = new ResourceDownloaderOperation(PackageName, downloadList, downloadingMaxNumber, failedTryAgain);
return operation; return operation;
} }
// 解压相关 // 解压相关
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByAll(int upackingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> unpcakList = GetUnpackListByAll(ActiveManifest); List<BundleInfo> unpcakList = GetUnpackListByAll(ActiveManifest);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout); var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
return operation; return operation;
} }
ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain, int timeout) ResourceUnpackerOperation IPlayMode.CreateResourceUnpackerByTags(string[] tags, int upackingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> unpcakList = GetUnpackListByTags(ActiveManifest, tags); List<BundleInfo> unpcakList = GetUnpackListByTags(ActiveManifest, tags);
var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain, timeout); var operation = new ResourceUnpackerOperation(PackageName, unpcakList, upackingMaxNumber, failedTryAgain);
return operation; return operation;
} }
// 导入相关 // 导入相关
ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importerMaxNumber, int failedTryAgain, int timeout) ResourceImporterOperation IPlayMode.CreateResourceImporterByFilePaths(string[] filePaths, int importingMaxNumber, int failedTryAgain)
{ {
List<BundleInfo> importerList = GetImporterListByFilePaths(ActiveManifest, filePaths); List<BundleInfo> importerList = GetImporterListByFilePaths(ActiveManifest, filePaths);
var operation = new ResourceImporterOperation(PackageName, importerList, importerMaxNumber, failedTryAgain, timeout); 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; return operation;
} }
#endregion #endregion
@@ -170,30 +176,30 @@ namespace YooAsset
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset); var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
return CreateBundleInfo(packageBundle); return CreateBundleInfo(packageBundle);
} }
BundleInfo[] IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo) List<BundleInfo> IBundleQuery.GetDependBundleInfos(AssetInfo assetInfo)
{ {
if (assetInfo == null || assetInfo.IsInvalid) if (assetInfo == null || assetInfo.IsInvalid)
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
// 注意:如果清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
PackageBundle[] depends; List<PackageBundle> depends;
if (assetInfo.LoadMethod == AssetInfo.ELoadMethod.LoadAllAssets) if (assetInfo.LoadMethod == AssetInfo.ELoadMethod.LoadAllAssets)
{ {
var mainBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset); var mainBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
depends = ActiveManifest.GetAllDependencies(mainBundle); depends = ActiveManifest.GetBundleAllDependencies(mainBundle);
} }
else else
{ {
depends = ActiveManifest.GetAllDependencies(assetInfo.Asset); depends = ActiveManifest.GetAssetAllDependencies(assetInfo.Asset);
} }
List<BundleInfo> result = new List<BundleInfo>(depends.Length); List<BundleInfo> result = new List<BundleInfo>(depends.Count);
foreach (var packageBundle in depends) foreach (var packageBundle in depends)
{ {
BundleInfo bundleInfo = CreateBundleInfo(packageBundle); BundleInfo bundleInfo = CreateBundleInfo(packageBundle);
result.Add(bundleInfo); result.Add(bundleInfo);
} }
return result.ToArray(); return result;
} }
string IBundleQuery.GetMainBundleName(int bundleID) string IBundleQuery.GetMainBundleName(int bundleID)
{ {
@@ -201,29 +207,6 @@ namespace YooAsset
var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID); var packageBundle = ActiveManifest.GetMainPackageBundle(bundleID);
return packageBundle.BundleName; return packageBundle.BundleName;
} }
string IBundleQuery.GetMainBundleName(AssetInfo assetInfo)
{
if (assetInfo == null || assetInfo.IsInvalid)
throw new Exception("Should never get here !");
// 注意:如果清单里未找到资源包会抛出异常!
var packageBundle = ActiveManifest.GetMainPackageBundle(assetInfo.Asset);
return packageBundle.BundleName;
}
string[] IBundleQuery.GetDependBundleNames(AssetInfo assetInfo)
{
if (assetInfo == null || assetInfo.IsInvalid)
throw new Exception("Should never get here !");
// 注意:如果清单里未找到资源包会抛出异常!
var depends = ActiveManifest.GetAllDependencies(assetInfo.Asset);
List<string> result = new List<string>(depends.Length);
foreach (var packageBundle in depends)
{
result.Add(packageBundle.BundleName);
}
return result.ToArray();
}
#endregion #endregion
/// <summary> /// <summary>
@@ -330,7 +313,7 @@ namespace YooAsset
checkList.Add(mainBundle); checkList.Add(mainBundle);
// 注意:如果清单里未找到资源包会抛出异常! // 注意:如果清单里未找到资源包会抛出异常!
PackageBundle[] mainDependBundles = manifest.GetAllDependencies(assetInfo.Asset); List<PackageBundle> mainDependBundles = manifest.GetAssetAllDependencies(assetInfo.Asset);
foreach (var dependBundle in mainDependBundles) foreach (var dependBundle in mainDependBundles)
{ {
if (checkList.Contains(dependBundle) == false) if (checkList.Contains(dependBundle) == false)
@@ -346,7 +329,7 @@ namespace YooAsset
if (checkList.Contains(otherMainBundle) == false) if (checkList.Contains(otherMainBundle) == false)
checkList.Add(otherMainBundle); checkList.Add(otherMainBundle);
PackageBundle[] otherDependBundles = manifest.GetAllDependencies(otherMainAsset); List<PackageBundle> otherDependBundles = manifest.GetAssetAllDependencies(otherMainAsset);
foreach (var dependBundle in otherDependBundles) foreach (var dependBundle in otherDependBundles)
{ {
if (checkList.Contains(dependBundle) == false) if (checkList.Contains(dependBundle) == false)
@@ -419,11 +402,56 @@ namespace YooAsset
if (manifest == null) if (manifest == null)
return new List<BundleInfo>(); return new List<BundleInfo>();
List<BundleInfo> result = new List<BundleInfo>(); ImportFileInfo[] fileInfos = new ImportFileInfo[filePaths.Length];
foreach (var filePath in filePaths) for (int i = 0; i < filePaths.Length; i++)
{ {
string fileName = System.IO.Path.GetFileName(filePath); ImportFileInfo fileInfo = new ImportFileInfo();
if (manifest.TryGetPackageBundleByFileName(fileName, out PackageBundle packageBundle)) fileInfo.FilePath = filePaths[i];
fileInfos[i] = fileInfo;
}
return GetImporterListByFileInfos(manifest, fileInfos);
}
public List<BundleInfo> GetImporterListByFileInfos(PackageManifest manifest, ImportFileInfo[] fileInfos)
{
if (manifest == null)
return new List<BundleInfo>();
List<BundleInfo> result = new List<BundleInfo>();
foreach (var fileInfo in fileInfos)
{
string filePath = fileInfo.FilePath;
if (string.IsNullOrEmpty(filePath))
continue;
PackageBundle packageBundle = null;
if (string.IsNullOrEmpty(fileInfo.BundleName) == false)
{
if (manifest.TryGetPackageBundleByBundleName(fileInfo.BundleName, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, bundle name : {fileInfo.BundleName}");
continue;
}
}
else if (string.IsNullOrEmpty(fileInfo.BundleGUID) == false)
{
if (manifest.TryGetPackageBundleByBundleGUID(fileInfo.BundleGUID, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, bundle guid : {fileInfo.BundleGUID}");
continue;
}
}
else
{
string fileName = System.IO.Path.GetFileName(filePath);
if (manifest.TryGetPackageBundleByFileName(fileName, out packageBundle) == false)
{
YooLogger.Warning($"Not found package bundle, file name : {fileName}");
continue;
}
}
if (packageBundle != null)
{ {
var fileSystem = GetBelongFileSystem(packageBundle); var fileSystem = GetBelongFileSystem(packageBundle);
if (fileSystem == null) if (fileSystem == null)
@@ -435,10 +463,6 @@ namespace YooAsset
result.Add(bundleInfo); result.Add(bundleInfo);
} }
} }
else
{
YooLogger.Warning($"Not found package bundle, importer file path : {filePath}");
}
} }
return result; return result;
} }

View File

@@ -496,7 +496,7 @@ namespace YooAsset
if (bundleInfo.IsNeedDownloadFromRemote()) if (bundleInfo.IsNeedDownloadFromRemote())
return true; return true;
BundleInfo[] depends = _bundleQuery.GetDependBundleInfos(assetInfo); List<BundleInfo> depends = _bundleQuery.GetDependBundleInfos(assetInfo);
foreach (var depend in depends) foreach (var depend in depends)
{ {
if (depend.IsNeedDownloadFromRemote()) if (depend.IsNeedDownloadFromRemote())
@@ -555,6 +555,7 @@ namespace YooAsset
private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority) private RawFileHandle LoadRawFileInternal(AssetInfo assetInfo, bool waitForAsyncComplete, uint priority)
{ {
assetInfo.LoadMethod = AssetInfo.ELoadMethod.LoadRawFile;
var handle = _resourceManager.LoadRawFileAsync(assetInfo, priority); var handle = _resourceManager.LoadRawFileAsync(assetInfo, priority);
if (waitForAsyncComplete) if (waitForAsyncComplete)
handle.WaitForAsyncComplete(); handle.WaitForAsyncComplete();
@@ -969,7 +970,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -982,7 +983,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -995,7 +996,7 @@ namespace YooAsset
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1011,11 +1012,11 @@ namespace YooAsset
DebugCheckInitialize(); DebugCheckInitialize();
var assetInfo = ConvertLocationToAssetInfo(location, null); var assetInfo = ConvertLocationToAssetInfo(location, null);
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo }; AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
} }
public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain, timeout); return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1035,11 +1036,11 @@ namespace YooAsset
var assetInfo = ConvertLocationToAssetInfo(location, null); var assetInfo = ConvertLocationToAssetInfo(location, null);
assetInfos.Add(assetInfo); assetInfos.Add(assetInfo);
} }
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain);
} }
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain, timeout); return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1054,11 +1055,11 @@ namespace YooAsset
{ {
DebugCheckInitialize(); DebugCheckInitialize();
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo }; AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
} }
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain, timeout); return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1072,11 +1073,11 @@ namespace YooAsset
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain, timeout); return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain);
} }
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain, timeout); return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain);
} }
#endregion #endregion
@@ -1089,7 +1090,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeImpl.CreateResourceUnpackerByAll(unpackingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1101,7 +1102,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(string tag, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeImpl.CreateResourceUnpackerByTags(new string[] { tag }, unpackingMaxNumber, failedTryAgain);
} }
/// <summary> /// <summary>
@@ -1113,7 +1114,7 @@ namespace YooAsset
public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain) public ResourceUnpackerOperation CreateResourceUnpacker(string[] tags, int unpackingMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain, int.MaxValue); return _playModeImpl.CreateResourceUnpackerByTags(tags, unpackingMaxNumber, failedTryAgain);
} }
#endregion #endregion
@@ -1128,7 +1129,20 @@ namespace YooAsset
public ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain) public ResourceImporterOperation CreateResourceImporter(string[] filePaths, int importerMaxNumber, int failedTryAgain)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceImporterByFilePaths(filePaths, importerMaxNumber, failedTryAgain, int.MaxValue); 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);
} }
#endregion #endregion

View File

@@ -0,0 +1,14 @@

namespace YooAsset
{
/// <summary>
/// 资源清单文件处理服务接口
/// </summary>
public interface IManifestProcessServices
{
/// <summary>
/// 处理资源清单(压缩或加密)
/// </summary>
byte[] ProcessManifest(byte[] fileData);
}
}

View File

@@ -0,0 +1,14 @@

namespace YooAsset
{
/// <summary>
/// 资源清单文件处理服务接口
/// </summary>
public interface IManifestRestoreServices
{
/// <summary>
/// 还原资源清单(解压或解密)
/// </summary>
byte[] RestoreManifest(byte[] fileData);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b17060f9f11771e4cbcb0201fce446e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,19 +0,0 @@

namespace YooAsset
{
/// <summary>
/// 资源清单文件处理服务接口
/// </summary>
public interface IManifestServices
{
/// <summary>
/// 处理资源清单(压缩和加密)
/// </summary>
byte[] ProcessManifest(byte[] fileData);
/// <summary>
/// 还原资源清单(解压和解密)
/// </summary>
byte[] RestoreManifest(byte[] fileData);
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 8c5a1726d94498e4cbe30f5f510cc796 guid: 36626e333f5e25c4581bc91db0189714
folderAsset: yes folderAsset: yes
DefaultImporter: DefaultImporter:
externalObjects: {} externalObjects: {}

View File

@@ -0,0 +1,48 @@
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace YooAsset
{
public class PreprocessBuildCatalog : UnityEditor.Build.IPreprocessBuildWithReport
{
public int callbackOrder { get { return 0; } }
/// <summary>
/// 在构建应用程序前自动生成内置资源目录文件。
/// 原理搜索StreamingAssets目录下的所有资源文件将这些文件信息写入文件然后在运行时做查询用途。
/// </summary>
public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
{
YooLogger.Log("Begin to create catalog file !");
string rootPath = YooAssetSettingsData.GetYooDefaultBuildinRoot();
DirectoryInfo rootDirectory = new DirectoryInfo(rootPath);
if (rootDirectory.Exists == false)
{
Debug.LogWarning($"Can not found StreamingAssets root directory : {rootPath}");
return;
}
// 搜索所有Package目录
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories();
foreach (var subDirectory in subDirectories)
{
string packageName = subDirectory.Name;
string pacakgeDirectory = subDirectory.FullName;
try
{
bool result = CatalogTools.CreateCatalogFile(null, packageName, pacakgeDirectory); //TODO 自行处理解密
if (result == false)
{
Debug.LogError($"Create package {packageName} catalog file failed ! See the detail error in console !");
}
}
catch (System.Exception ex)
{
Debug.LogError($"Create package {packageName} catalog file failed ! {ex.Message}");
}
}
}
}
}

View File

@@ -58,7 +58,7 @@ public class CopyBuildinManifestOperation : GameAsyncOperation
string sourcePath = GetBuildinHashFilePath(); string sourcePath = GetBuildinHashFilePath();
string destPath = GetCacheHashFilePath(); string destPath = GetCacheHashFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _hashFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
OperationSystem.StartOperation(_packageName, _hashFileRequestOp); OperationSystem.StartOperation(_packageName, _hashFileRequestOp);
} }
@@ -97,7 +97,7 @@ public class CopyBuildinManifestOperation : GameAsyncOperation
string sourcePath = GetBuildinManifestFilePath(); string sourcePath = GetBuildinManifestFilePath();
string destPath = GetCacheManifestFilePath(); string destPath = GetCacheManifestFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath); string url = DownloadSystemHelper.ConvertToWWWPath(sourcePath);
_manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath); _manifestFileRequestOp = new UnityWebFileRequestOperation(url, destPath, 60);
OperationSystem.StartOperation(_packageName, _manifestFileRequestOp); OperationSystem.StartOperation(_packageName, _manifestFileRequestOp);
} }

View File

@@ -44,7 +44,7 @@ public class GetBuildinPackageVersionOperation : GameAsyncOperation
{ {
string filePath = GetBuildinPackageVersionFilePath(); string filePath = GetBuildinPackageVersionFilePath();
string url = DownloadSystemHelper.ConvertToWWWPath(filePath); string url = DownloadSystemHelper.ConvertToWWWPath(filePath);
_versionFileRequestOp = new UnityWebTextRequestOperation(url); _versionFileRequestOp = new UnityWebTextRequestOperation(url, 60);
OperationSystem.StartOperation(_packageName, _versionFileRequestOp); OperationSystem.StartOperation(_packageName, _versionFileRequestOp);
} }

View File

@@ -37,8 +37,10 @@ public class SpriteAtlasLoader : MonoBehaviour
return; return;
} }
var atlas = loadHandle.AssetObject as SpriteAtlas;
_loadedAtlas.Add(atlasName, atlas);
_loadHandles.Add(loadHandle); _loadHandles.Add(loadHandle);
callback.Invoke(loadHandle.AssetObject as SpriteAtlas); callback.Invoke(atlas);
} }
} }
} }

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: bcc739bb54706c347b7ee54cbe51b69c
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,98 @@
using System.Collections;
using UnityEngine;
namespace YooAsset
{
internal class FileSystemTester
{
public IEnumerator RunTester(IFileSystem fileSystem, string testLocation)
{
string packageName = fileSystem.PackageName;
// 初始化小游戏文件系统
Debug.Log("初始化小游戏文件系统!");
var initializeFileSystemOp = fileSystem.InitializeFileSystemAsync();
OperationSystem.StartOperation(packageName, initializeFileSystemOp);
yield return initializeFileSystemOp;
if (initializeFileSystemOp.Status != EOperationStatus.Succeed)
{
Debug.LogError($"初始化小游戏文件系统失败!{initializeFileSystemOp.Error}");
yield break;
}
// 请求资源版本
Debug.Log("请求资源版本信息!");
var requestPackageVersionOp = fileSystem.RequestPackageVersionAsync(true, 60);
OperationSystem.StartOperation(packageName, requestPackageVersionOp);
yield return requestPackageVersionOp;
if (requestPackageVersionOp.Status != EOperationStatus.Succeed)
{
Debug.LogError($"请求资源版本信息失败!{requestPackageVersionOp.Error}");
yield break;
}
// 请求资源清单
string packageVersion = requestPackageVersionOp.PackageVersion;
Debug.Log($"加载资源清单文件!{packageVersion}");
var loadPackageManifestOp = fileSystem.LoadPackageManifestAsync(packageVersion, 60);
OperationSystem.StartOperation(packageName, loadPackageManifestOp);
yield return loadPackageManifestOp;
if (loadPackageManifestOp.Status != EOperationStatus.Succeed)
{
Debug.LogError($"加载资源清单文件失败!{loadPackageManifestOp.Error}");
yield break;
}
// 预下载资源包
Debug.Log("预下载资源包!");
{
var manifest = loadPackageManifestOp.Manifest;
var packageBundle = GetPackageBundle(manifest, testLocation);
var options = new DownloadFileOptions(1);
var downloadFileOp = fileSystem.DownloadFileAsync(packageBundle, options);
OperationSystem.StartOperation(packageName, downloadFileOp);
yield return downloadFileOp;
if (downloadFileOp.Status != EOperationStatus.Succeed)
{
Debug.LogError($"预下载资源包失败!{downloadFileOp.Error}");
yield break;
}
else
{
Debug.Log("预下载资源包成功!");
}
}
// 加载资源包
Debug.Log("加载资源包!");
{
var manifest = loadPackageManifestOp.Manifest;
var packageBundle = GetPackageBundle(manifest, testLocation);
var loadBundleFileOp = fileSystem.LoadBundleFile(packageBundle);
OperationSystem.StartOperation(packageName, loadBundleFileOp);
yield return loadBundleFileOp;
if (loadBundleFileOp.Status != EOperationStatus.Succeed)
{
Debug.LogError($"加载资源包失败!{loadBundleFileOp.Error}");
yield break;
}
else
{
Debug.Log("加载资源包成功!");
}
// 卸载资源包
loadBundleFileOp.Result.UnloadBundleFile();
}
Debug.Log("完整测试成功!");
}
private PackageBundle GetPackageBundle(PackageManifest manifest, string location)
{
var assetInfo = manifest.ConvertLocationToAssetInfo(location, typeof(GameObject));
var packageBundle = manifest.GetMainPackageBundle(assetInfo.Asset);
return packageBundle;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19ed2b81fece5b84fa771a5eeb108572
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#if UNITY_WEBGL && DOUYINMINIGAME
using System.Collections;
using UnityEngine;
namespace YooAsset
{
internal class TiktokFileSystemTest : MonoBehaviour
{
private void Awake()
{
YooAssets.Initialize();
}
private IEnumerator Start()
{
string packageName = "DefaultPackage";
string testLocation = "asteroid01";
string hostServer = "http://127.0.0.1/CDN/WebGL/yoo";
string packageRoot = $"{StarkSDKSpace.StarkFileSystemManager.USER_DATA_PATH}/__GAME_FILE_CACHE";
IRemoteServices remoteServices = new RemoteServices(hostServer);
TiktokFileSystem fileSystem = new TiktokFileSystem();
fileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
fileSystem.OnCreate(packageName, packageRoot);
FileSystemTester tester = new FileSystemTester();
yield return tester.RunTester(fileSystem, testLocation);
}
private class RemoteServices : IRemoteServices
{
private readonly string _hostServer;
public RemoteServices(string hostServer)
{
_hostServer = hostServer;
}
string IRemoteServices.GetRemoteMainURL(string fileName)
{
return $"{_hostServer}/{fileName}";
}
string IRemoteServices.GetRemoteFallbackURL(string fileName)
{
return $"{_hostServer}/{fileName}";
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ec9d17e765ccd4642aa3aa9ca0580799
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,49 @@
#if UNITY_WEBGL && WEIXINMINIGAME
using System.Collections;
using UnityEngine;
namespace YooAsset
{
internal class WechatFileSystemTest : MonoBehaviour
{
private void Awake()
{
YooAssets.Initialize();
}
private IEnumerator Start()
{
string packageName = "DefaultPackage";
string testLocation = "asteroid01";
string hostServer = "http://127.0.0.1/CDN/WebGL/yoo";
string packageRoot = $"{WeChatWASM.WX.env.USER_DATA_PATH}/__GAME_FILE_CACHE";
IRemoteServices remoteServices = new RemoteServices(hostServer);
WechatFileSystem fileSystem = new WechatFileSystem();
fileSystem.SetParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
fileSystem.OnCreate(packageName, packageRoot);
FileSystemTester tester = new FileSystemTester();
yield return tester.RunTester(fileSystem, testLocation);
}
private class RemoteServices : IRemoteServices
{
private readonly string _hostServer;
public RemoteServices(string hostServer)
{
_hostServer = hostServer;
}
string IRemoteServices.GetRemoteMainURL(string fileName)
{
return $"{_hostServer}/{fileName}";
}
string IRemoteServices.GetRemoteFallbackURL(string fileName)
{
return $"{_hostServer}/{fileName}";
}
}
}
}
#endif

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3036392c24e1a3b49b7628fbf6cc24d8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Some files were not shown because too many files have changed in this diff Show More