Compare commits

...

22 Commits

Author SHA1 Message Date
何冠峰
b1f02049cc Update CHANGELOG.md 2025-09-17 16:59:24 +08:00
何冠峰
512886cdf6 Update package.json 2025-09-17 16:58:59 +08:00
何冠峰
0c3ccc5c2f refactor: 适配引擎版本 2025-09-17 16:49:21 +08:00
何冠峰
b0ea03170f refactor : 移除下载器的timeout参数
可以使用看门狗机制代替。
2025-09-17 15:53:22 +08:00
何冠峰
2c3b890329 feat #642 2025-09-17 15:39:47 +08:00
何冠峰
0f39cb9444 update space shooter 2025-09-17 10:53:56 +08:00
何冠峰
8acc16d3f6 perf #632 2025-09-17 10:53:40 +08:00
何冠峰
fd1715a89b fix 修正无效警告 2025-09-17 10:51:24 +08:00
何冠峰
0934c813d1 fix #644 2025-09-13 18:18:31 +08:00
何冠峰
be71d38cd8 update AssetBundleBuilder 2025-09-11 19:20:16 +08:00
何冠峰
4cdfde31da update AssetArtScanner 2025-09-11 19:19:55 +08:00
何冠峰
0133549ef8 feat #638
修复问题,防止游离的Bundle加载任务出现。
2025-09-11 14:03:42 +08:00
何冠峰
81d9eb47c8 feat #638 2025-09-11 11:07:13 +08:00
何冠峰
5fde689f1f feat #640 2025-09-10 21:19:58 +08:00
何冠峰
5d51bfe751 feat #639
修复问题
2025-09-10 21:00:51 +08:00
何冠峰
ed86edd2b0 feat #639 2025-09-10 20:15:52 +08:00
何冠峰
f627b5b59a Update CHANGELOG.md 2025-09-10 12:05:31 +08:00
何冠峰
549ec74519 Update CHANGELOG.md 2025-09-09 20:06:53 +08:00
何冠峰
247ee31348 Update package.json 2025-09-09 20:06:31 +08:00
何冠峰
90d3a53bc3 fix #631 2025-09-09 19:06:17 +08:00
何冠峰
19f1d67a61 feat : 弱引用资源句柄 2025-09-09 18:31:02 +08:00
何冠峰
a71c46d1c4 feat : 构建过程图集依赖计算增加开关 2025-09-08 19:00:55 +08:00
38 changed files with 961 additions and 103 deletions

View File

@@ -2,6 +2,188 @@
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.16] - 2025-09-17
### Improvements
- (#638) 优化了Provider加载机制引用计数为零时自动挂起
### Fixed
- (#644) [**严重**] 修复了2.3.15版本,资产量巨大的情况下,编辑器下模拟模式初始化耗时很久的问题。
### Added
- (#639) 新增了文件系统参数VIRTUAL_DOWNLOAD_MODE 和 VIRTUAL_DOWNLOAD_SPEED
编辑器下不需要构建AB也可以模拟远端资源下载等同真机运行环境。
```csharp
class DefaultEditorFIleSystem
{
/// <summary>
/// 模拟虚拟下载模式
/// </summary>
public bool VirtualDownloadMode { private set; get; } = false;
/// <summary>
/// 模拟虚拟下载的网速(单位:字节)
/// </summary>
public int VirtualDownloadSpeed { private set; get; } = 1024;
}
```
- (#640) 新增了文件系统参数VIRTUAL_WEBGL_MODE
编辑器下不需要构建AB也可以模拟小游戏开发环境等同真机运行环境。
```csharp
class DefaultEditorFIleSystem
{
/// <summary>
/// 模拟WebGL平台模式
/// </summary>
public bool VirtualWebGLMode { private set; get; } = false;
}
```
- (#642) 新增了文件系统参数DOWNLOAD_WATCH_DOG_TIME
监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
```csharp
class DefaultCacheFIleSystem
{
/// <summary>
/// 自定义参数:下载任务的看门狗机制监控时间
/// </summary>
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
}
```
### Changed
- 下载器参数timeout移除。
可以使用文件系统的看门狗机制代替。
- (#632) IFilterRule接口变动。
收集器可以指定搜寻的资源类型,在收集目录资产量巨大的情况下,可以极大加快打包速度!
```csharp
public interface IFilterRule
{
/// <summary>
/// 搜寻的资源类型
/// 说明:使用引擎方法搜索获取所有资源列表
/// </summary>
string FindAssetType { get; }
}
```
## [2.3.15] - 2025-09-09
**重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。
### Improvements
- 重构了UniTask扩展库的目录结构和说明文档。
- 重构了内置文件系统类的加载和拷贝逻辑,解决在一些特殊机型上遇到的偶发性拷贝失败问题。
- 增加了生成内置清单文件的窗口工具详情见扩展工程里CreateBuildinCatalog目录。
- 优化了异步操作系统的繁忙检测机制。
- (#621) 资源配置页面可以展示DependCollector和StaticCollector包含的文件列表内容。
- (#627) 优化了资源清单部分字段类型CRC字段从字符串类型调整为整形可以降低清单尺寸。
### Fixed
- 修复了构建页面扩展类缺少指定属性报错的问题。
- (#611) 修复了资源扫描器配置页面,修改备注信息后会丢失焦点的问题。
- (#622) 修复了纯鸿蒙系统读取内置加密文件失败的问题。
- (#620) 修复了LINUX系统URL地址转换失败的问题。
- (#631) 修复了NET 4.x程序集库Math.Clamp导致的编译错误。
### Added
- 新增了支持支付宝小游戏的文件系统扩展类。
- 新增了支持Taptap小游戏的文件系统扩展类。
- 新增了资源系统初始化参数UseWeakReferenceHandle
目前处于预览版可以在引擎设置页面开启宏YOOASSET_EXPERIMENTAL
```csharp
/// <summary>
/// 启用弱引用资源句柄
/// </summary>
public bool UseWeakReferenceHandle = false;
```
- 内置文件系统和缓存文件系统新增初始化参数FILE_VERIFY_MAX_CONCURRENCY
```csharp
/// <summary>
/// 自定义参数:初始化的时候缓存文件校验最大并发数
/// </summary>
public int FileVerifyMaxConcurrency { private set; get; }
```
- (#623) 内置构建管线新增构建参数StripUnityVersion
```csharp
/// <summary>
/// 从文件头里剥离Unity版本信息
/// </summary>
public bool StripUnityVersion = false;
```
- 可编程构建管线新增构建参数TrackSpriteAtlasDependencies
```csharp
/// <summary>
/// 自动建立资源对象对图集的依赖关系
/// </summary>
public bool TrackSpriteAtlasDependencies = false;
```
- (#617) 新增资源收集配置参数SupportExtensionless
在不需要模糊加载模式的前提下,关闭此选项,可以降低运行时内存大小。
该选项默认开启!
```csharp
public class CollectCommand
{
/// <summary>
/// 支持无后缀名的资源定位地址
/// </summary>
public bool SupportExtensionless { set; get; }
}
```
- (#625) 异步操作系统类新增监听方法。
```csharp
class OperationSystem
{
/// <summary>
/// 监听任务开始
/// </summary>
public static void RegisterStartCallback(Action<string, AsyncOperationBase> callback);
/// <summary>
/// 监听任务结束
/// </summary>
public static void RegisterFinishCallback(Action<string, AsyncOperationBase> callback);
}
```
## [2.3.14] - 2025-07-23 ## [2.3.14] - 2025-07-23
**重要****所有下载相关的超时参数timeout已更新判定逻辑** **重要****所有下载相关的超时参数timeout已更新判定逻辑**

View File

@@ -46,7 +46,7 @@ namespace YooAsset.Editor
} }
catch (Exception e) catch (Exception e)
{ {
return new ScannerResult(e.StackTrace); return new ScannerResult(e.Message, e.StackTrace);
} }
} }

View File

@@ -18,6 +18,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string ErrorInfo { private set; get; } public string ErrorInfo { private set; get; }
/// <summary>
/// 错误堆栈
/// </summary>
public string ErrorStack { private set; get; }
/// <summary> /// <summary>
/// 是否成功 /// 是否成功
/// </summary> /// </summary>
@@ -33,9 +38,10 @@ namespace YooAsset.Editor
} }
public ScannerResult(string error) public ScannerResult(string error, string stack)
{ {
ErrorInfo = error; ErrorInfo = error;
ErrorStack = stack;
} }
public ScannerResult(string filePath, ScanReport report) public ScannerResult(string filePath, ScanReport report)
{ {

View File

@@ -308,11 +308,18 @@ namespace YooAsset.Editor
// 注意:如果是可编程构建管线,需要补充内置资源包 // 注意:如果是可编程构建管线,需要补充内置资源包
// 注意:该步骤依赖前面的操作! // 注意:该步骤依赖前面的操作!
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>(); var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (buildResultContext != null) if (buildResultContext != null)
{ {
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName); ProcessBuiltinBundleReference(manifest, buildResultContext.BuiltinShadersBundleName);
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName); ProcessBuiltinBundleReference(manifest, buildResultContext.MonoScriptsBundleName);
var buildParametersContext = context.TryGetContextObject<BuildParametersContext>();
var buildParameters = buildParametersContext.Parameters;
if (buildParameters is ScriptableBuildParameters scriptableBuildParameters)
{
if (scriptableBuildParameters.TrackSpriteAtlasDependencies)
{
// 注意:检测是否开启图集模式 // 注意:检测是否开启图集模式
// 说明:需要记录主资源对象对图集的依赖关系! // 说明:需要记录主资源对象对图集的依赖关系!
if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled) if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
@@ -321,12 +328,14 @@ namespace YooAsset.Editor
foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList) foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList)
{ {
string spriteAtlasBundleName = spriteAtlasAsset.BundleName; string spriteAtlasBundleName = spriteAtlasAsset.BundleName;
ProcessBuiltinBundleReference(context, manifest, spriteAtlasBundleName); ProcessBuiltinBundleReference(manifest, spriteAtlasBundleName);
} }
} }
} }
} }
private void ProcessBuiltinBundleReference(BuildContext context, PackageManifest manifest, string builtinBundleName) }
}
private void ProcessBuiltinBundleReference(PackageManifest manifest, string builtinBundleName)
{ {
if (string.IsNullOrEmpty(builtinBundleName)) if (string.IsNullOrEmpty(builtinBundleName))
return; return;

View File

@@ -29,6 +29,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool IgnoreTypeTreeChanges = true; public bool IgnoreTypeTreeChanges = true;
/// <summary>
/// 自动建立资源对象对图集的依赖关系
/// </summary>
public bool TrackSpriteAtlasDependencies = false;
/// <summary> /// <summary>
/// 生成代码防裁剪配置 /// 生成代码防裁剪配置

View File

@@ -21,6 +21,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string ErrorInfo; public string ErrorInfo;
/// <summary>
/// 构建失败的堆栈
/// </summary>
public string ErrorStack;
/// <summary> /// <summary>
/// 输出的补丁包目录 /// 输出的补丁包目录
/// </summary> /// </summary>

View File

@@ -51,6 +51,7 @@ namespace YooAsset.Editor
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
buildResult.FailedTask = task.GetType().Name; buildResult.FailedTask = task.GetType().Name;
buildResult.ErrorInfo = e.ToString(); buildResult.ErrorInfo = e.ToString();
buildResult.ErrorStack = e.StackTrace;
buildResult.Success = false; buildResult.Success = false;
break; break;
} }

View File

@@ -139,14 +139,30 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group) public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
{ {
bool ignoreStaticCollector = command.IsFlagSet(ECollectFlags.IgnoreStaticCollector);
if (ignoreStaticCollector)
{
if (CollectorType == ECollectorType.StaticAssetCollector)
return new List<CollectAssetInfo>();
}
bool ignoreDependCollector = command.IsFlagSet(ECollectFlags.IgnoreDependCollector);
if (ignoreDependCollector)
{
if (CollectorType == ECollectorType.DependAssetCollector)
return new List<CollectAssetInfo>();
}
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
// 收集打包资源路径 // 收集打包资源路径
List<string> findAssets = new List<string>(); List<string> findAssets = new List<string>();
if (AssetDatabase.IsValidFolder(CollectPath)) if (AssetDatabase.IsValidFolder(CollectPath))
{ {
string collectDirectory = CollectPath; IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory); string findAssetType = filterRuleInstance.FindAssetType;
string searchFolder = CollectPath;
string[] findResult = EditorTools.FindAssets(findAssetType, searchFolder);
findAssets.AddRange(findResult); findAssets.AddRange(findResult);
} }
else else
@@ -262,8 +278,8 @@ namespace YooAsset.Editor
} }
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath) private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{ {
// 注意:模拟构建模式下不需要收集依赖资源 bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies);
if (command.SimulateBuild) if (ignoreGetDependencies)
return new List<AssetInfo>(); return new List<AssetInfo>();
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true); string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);

View File

@@ -1028,7 +1028,7 @@ namespace YooAsset.Editor
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName); IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
string packageName = _packageNameTxt.value; string packageName = _packageNameTxt.value;
var command = new CollectCommand(packageName, ignoreRule); var command = new CollectCommand(packageName, ignoreRule);
command.SimulateBuild = true; command.SetFlag(ECollectFlags.IgnoreGetDependencies, true);
command.UniqueBundleName = _uniqueBundleNameToogle.value; command.UniqueBundleName = _uniqueBundleNameToogle.value;
command.EnableAddressable = _enableAddressableToogle.value; command.EnableAddressable = _enableAddressableToogle.value;
command.SupportExtensionless = _supportExtensionlessToogle.value; command.SupportExtensionless = _supportExtensionlessToogle.value;

View File

@@ -1,6 +1,26 @@
 
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
public enum ECollectFlags
{
None = 0,
/// <summary>
/// 不收集依赖资源
/// </summary>
IgnoreGetDependencies = 1 << 0,
/// <summary>
/// 忽略静态收集器
/// </summary>
IgnoreStaticCollector = 1 << 1,
/// <summary>
/// 忽略依赖收集器
/// </summary>
IgnoreDependCollector = 1 << 2,
}
public class CollectCommand public class CollectCommand
{ {
/// <summary> /// <summary>
@@ -17,7 +37,20 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 模拟构建模式 /// 模拟构建模式
/// </summary> /// </summary>
public bool SimulateBuild { set; get; } public bool SimulateBuild
{
set
{
SetFlag(ECollectFlags.IgnoreGetDependencies, value);
SetFlag(ECollectFlags.IgnoreStaticCollector, value);
SetFlag(ECollectFlags.IgnoreDependCollector, value);
}
}
/// <summary>
/// 窗口收集模式
/// </summary>
public int CollectFlags { set; get; } = 0;
/// <summary> /// <summary>
/// 资源包名唯一化 /// 资源包名唯一化
@@ -70,5 +103,24 @@ namespace YooAsset.Editor
PackageName = packageName; PackageName = packageName;
IgnoreRule = ignoreRule; IgnoreRule = ignoreRule;
} }
/// <summary>
/// 设置标记位
/// </summary>
public void SetFlag(ECollectFlags flag, bool isOn)
{
if (isOn)
CollectFlags |= (int)flag; // 开启指定标志位
else
CollectFlags &= ~(int)flag; // 关闭指定标志位
}
/// <summary>
/// 查询标记位
/// </summary>
public bool IsFlagSet(ECollectFlags flag)
{
return (CollectFlags & (int)flag) != 0;
}
} }
} }

View File

@@ -23,7 +23,13 @@ namespace YooAsset.Editor
public interface IFilterRule public interface IFilterRule
{ {
/// <summary> /// <summary>
/// 是否为收集资源 /// 搜寻的资源类型
/// 说明:使用引擎方法搜索获取所有资源列表
/// </summary>
string FindAssetType { get; }
/// <summary>
/// 验证搜寻的资源是否为收集资源
/// </summary> /// </summary>
/// <returns>如果收集该资源返回TRUE</returns> /// <returns>如果收集该资源返回TRUE</returns>
bool IsCollectAsset(FilterRuleData data); bool IsCollectAsset(FilterRuleData data);

View File

@@ -9,6 +9,11 @@ namespace YooAsset.Editor
[DisplayName("收集所有资源")] [DisplayName("收集所有资源")]
public class CollectAll : IFilterRule public class CollectAll : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.All.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
return true; return true;
@@ -18,6 +23,11 @@ namespace YooAsset.Editor
[DisplayName("收集场景")] [DisplayName("收集场景")]
public class CollectScene : IFilterRule public class CollectScene : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.Scene.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
string extension = Path.GetExtension(data.AssetPath); string extension = Path.GetExtension(data.AssetPath);
@@ -28,6 +38,11 @@ namespace YooAsset.Editor
[DisplayName("收集预制体")] [DisplayName("收集预制体")]
public class CollectPrefab : IFilterRule public class CollectPrefab : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.Prefab.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
return Path.GetExtension(data.AssetPath) == ".prefab"; return Path.GetExtension(data.AssetPath) == ".prefab";
@@ -37,6 +52,11 @@ namespace YooAsset.Editor
[DisplayName("收集精灵类型的纹理")] [DisplayName("收集精灵类型的纹理")]
public class CollectSprite : IFilterRule public class CollectSprite : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.Sprite.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath); var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
@@ -58,6 +78,11 @@ namespace YooAsset.Editor
[DisplayName("收集着色器")] [DisplayName("收集着色器")]
public class CollectShader : IFilterRule public class CollectShader : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.Shader.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
return Path.GetExtension(data.AssetPath) == ".shader"; return Path.GetExtension(data.AssetPath) == ".shader";
@@ -67,6 +92,11 @@ namespace YooAsset.Editor
[DisplayName("收集着色器变种集合")] [DisplayName("收集着色器变种集合")]
public class CollectShaderVariants : IFilterRule public class CollectShaderVariants : IFilterRule
{ {
public string FindAssetType
{
get { return EAssetSearchType.All.ToString(); }
}
public bool IsCollectAsset(FilterRuleData data) public bool IsCollectAsset(FilterRuleData data)
{ {
return Path.GetExtension(data.AssetPath) == ".shadervariants"; return Path.GetExtension(data.AssetPath) == ".shadervariants";

View File

@@ -39,6 +39,7 @@ namespace YooAsset.Editor
Shader, Shader,
Sprite, Sprite,
Texture, Texture,
RenderTexture,
VideoClip, VideoClip,
} }

View File

@@ -169,6 +169,28 @@ namespace YooAsset.Editor
/// <param name="searchInFolders">指定搜索的文件夹列表</param> /// <param name="searchInFolders">指定搜索的文件夹列表</param>
/// <returns>返回搜集到的资源路径列表</returns> /// <returns>返回搜集到的资源路径列表</returns>
public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders) public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders)
{
return FindAssets(searchType.ToString(), searchInFolders);
}
/// <summary>
/// 搜集资源
/// </summary>
/// <param name="searchType">搜集的资源类型</param>
/// <param name="searchInFolder">指定搜索的文件夹</param>
/// <returns>返回搜集到的资源路径列表</returns>
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
{
return FindAssets(searchType.ToString(), new string[] { searchInFolder });
}
/// <summary>
/// 搜集资源
/// </summary>
/// <param name="searchType">搜集的资源类型</param>
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
/// <returns>返回搜集到的资源路径列表</returns>
public static string[] FindAssets(string searchType, string[] searchInFolders)
{ {
// 注意AssetDatabase.FindAssets()不支持末尾带分隔符的文件夹路径 // 注意AssetDatabase.FindAssets()不支持末尾带分隔符的文件夹路径
for (int i = 0; i < searchInFolders.Length; i++) for (int i = 0; i < searchInFolders.Length; i++)
@@ -179,7 +201,7 @@ namespace YooAsset.Editor
// 注意:获取指定目录下的所有资源对象(包括子文件夹) // 注意:获取指定目录下的所有资源对象(包括子文件夹)
string[] guids; string[] guids;
if (searchType == EAssetSearchType.All) if (string.IsNullOrEmpty(searchType) || searchType == EAssetSearchType.All.ToString())
guids = AssetDatabase.FindAssets(string.Empty, searchInFolders); guids = AssetDatabase.FindAssets(string.Empty, searchInFolders);
else else
guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders); guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders);
@@ -206,7 +228,7 @@ namespace YooAsset.Editor
/// <param name="searchType">搜集的资源类型</param> /// <param name="searchType">搜集的资源类型</param>
/// <param name="searchInFolder">指定搜索的文件夹</param> /// <param name="searchInFolder">指定搜索的文件夹</param>
/// <returns>返回搜集到的资源路径列表</returns> /// <returns>返回搜集到的资源路径列表</returns>
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder) public static string[] FindAssets(string searchType, string searchInFolder)
{ {
return FindAssets(searchType, new string[] { searchInFolder }); return FindAssets(searchType, new string[] { searchInFolder });
} }

View File

@@ -0,0 +1,65 @@
using UnityEngine.Networking;
using UnityEngine;
namespace YooAsset
{
internal class UnityVirtualBundleRequestOperation : UnityWebRequestOperation
{
protected enum ESteps
{
None,
Download,
Done,
}
private readonly PackageBundle _bundle;
private readonly int _downloadSpeed;
private ESteps _steps = ESteps.None;
internal UnityVirtualBundleRequestOperation(PackageBundle packageBundle, int downloadSpeed, string url) : base(url)
{
_bundle = packageBundle;
_downloadSpeed = downloadSpeed;
}
internal override void InternalStart()
{
_steps = ESteps.Download;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.Download)
{
// 模拟下载进度
float progress = 0;
if (DownloadedBytes > 0)
progress = DownloadedBytes / _bundle.FileSize;
long downloadBytes = (long)((double)_downloadSpeed * Time.deltaTime);
Progress = progress;
DownloadProgress = progress;
DownloadedBytes += downloadBytes;
if (DownloadedBytes < _bundle.FileSize)
return;
Progress = 1f;
DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize;
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
internal override void InternalWaitForAsyncComplete()
{
if (_steps != ESteps.Done)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Try load bundle {_bundle.BundleName} from remote !";
}
}
}
}

View File

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

View File

@@ -172,7 +172,7 @@ namespace YooAsset
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY) else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
{ {
int convertValue = Convert.ToInt32(value); int convertValue = Convert.ToInt32(value);
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue); FileVerifyMaxConcurrency = Mathf.Clamp(convertValue, 1, int.MaxValue);
} }
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION) else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
{ {

View File

@@ -2,6 +2,7 @@
using System.IO; using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using UnityEngine;
namespace YooAsset namespace YooAsset
{ {
@@ -95,6 +96,11 @@ namespace YooAsset
/// </summary> /// </summary>
public int DownloadMaxRequestPerFrame { private set; get; } = int.MaxValue; public int DownloadMaxRequestPerFrame { private set; get; } = int.MaxValue;
/// <summary>
/// 自定义参数:下载任务的看门狗机制监控时间
/// </summary>
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
/// <summary> /// <summary>
/// 自定义参数:启用断点续传的最小尺寸 /// 自定义参数:启用断点续传的最小尺寸
/// </summary> /// </summary>
@@ -231,7 +237,7 @@ namespace YooAsset
else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY) else if (name == FileSystemParametersDefine.FILE_VERIFY_MAX_CONCURRENCY)
{ {
int convertValue = Convert.ToInt32(value); int convertValue = Convert.ToInt32(value);
FileVerifyMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue); FileVerifyMaxConcurrency = Mathf.Clamp(convertValue, 1, int.MaxValue);
} }
else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION) else if (name == FileSystemParametersDefine.APPEND_FILE_EXTENSION)
{ {
@@ -244,12 +250,17 @@ namespace YooAsset
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY) else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY)
{ {
int convertValue = Convert.ToInt32(value); int convertValue = Convert.ToInt32(value);
DownloadMaxConcurrency = Math.Clamp(convertValue, 1, int.MaxValue); DownloadMaxConcurrency = Mathf.Clamp(convertValue, 1, int.MaxValue);
} }
else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME) else if (name == FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME)
{ {
int convertValue = Convert.ToInt32(value); int convertValue = Convert.ToInt32(value);
DownloadMaxRequestPerFrame = Math.Clamp(convertValue, 1, int.MaxValue); DownloadMaxRequestPerFrame = Mathf.Clamp(convertValue, 1, int.MaxValue);
}
else if (name == FileSystemParametersDefine.DOWNLOAD_WATCH_DOG_TIME)
{
int convertValue = Convert.ToInt32(value);
DownloadWatchDogTime = Mathf.Clamp(convertValue, 1, int.MaxValue);
} }
else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE) else if (name == FileSystemParametersDefine.RESUME_DOWNLOAD_MINMUM_SIZE)
{ {

View File

@@ -17,6 +17,11 @@ namespace YooAsset
protected readonly PackageBundle _bundle; protected readonly PackageBundle _bundle;
protected readonly string _tempFilePath; protected readonly string _tempFilePath;
private bool _watchDogInit = false;
private bool _watchDogAborted = false;
private ulong _lastDownloadBytes;
private double _lastGetDataTime;
/// <summary> /// <summary>
/// 引用计数 /// 引用计数
/// </summary> /// </summary>
@@ -33,6 +38,47 @@ namespace YooAsset
return $"RefCount : {RefCount}"; return $"RefCount : {RefCount}";
} }
/// <summary>
/// 更新看门狗监测
/// 说明:监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
/// </summary>
protected void UpdateWatchDog()
{
if (_fileSystem.DownloadWatchDogTime == int.MaxValue)
return;
if (_watchDogAborted)
return;
#if UNITY_2020_3_OR_NEWER
double realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartupAsDouble;
#else
double realtimeSinceStartup = UnityEngine.Time.realtimeSinceStartup;
#endif
if (_watchDogInit == false)
{
_watchDogInit = true;
_lastDownloadBytes = 0;
_lastGetDataTime = realtimeSinceStartup;
}
if (_webRequest.downloadedBytes != _lastDownloadBytes)
{
_lastDownloadBytes = _webRequest.downloadedBytes;
_lastGetDataTime = realtimeSinceStartup;
}
else
{
double deltaTime = realtimeSinceStartup - _lastGetDataTime;
if (deltaTime > _fileSystem.DownloadWatchDogTime)
{
_watchDogAborted = true;
InternalAbort(); //终止网络请求
}
}
}
/// <summary> /// <summary>
/// 减少引用计数 /// 减少引用计数
/// </summary> /// </summary>

View File

@@ -4,7 +4,7 @@ using UnityEngine.Networking;
namespace YooAsset namespace YooAsset
{ {
internal class UnityDownloadLocalFileOperation : UnityDownloadFileOperation internal sealed class UnityDownloadLocalFileOperation : UnityDownloadFileOperation
{ {
private VerifyTempFileOperation _verifyOperation; private VerifyTempFileOperation _verifyOperation;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -42,6 +42,8 @@ namespace YooAsset
DownloadProgress = _webRequest.downloadProgress; DownloadProgress = _webRequest.downloadProgress;
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
UpdateWatchDog();
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
return; return;

View File

@@ -39,6 +39,8 @@ namespace YooAsset
DownloadProgress = _webRequest.downloadProgress; DownloadProgress = _webRequest.downloadProgress;
DownloadedBytes = (long)_webRequest.downloadedBytes; DownloadedBytes = (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
UpdateWatchDog();
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
return; return;

View File

@@ -56,6 +56,8 @@ namespace YooAsset
DownloadProgress = _webRequest.downloadProgress; DownloadProgress = _webRequest.downloadProgress;
DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes; DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes;
Progress = DownloadProgress; Progress = DownloadProgress;
UpdateWatchDog();
if (_webRequest.isDone == false) if (_webRequest.isDone == false)
return; return;

View File

@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
@@ -7,6 +8,7 @@ namespace YooAsset
/// </summary> /// </summary>
internal class DefaultEditorFileSystem : IFileSystem internal class DefaultEditorFileSystem : IFileSystem
{ {
protected readonly Dictionary<string, string> _records = new Dictionary<string, string>(10000);
protected string _packageRoot; protected string _packageRoot;
/// <summary> /// <summary>
@@ -37,15 +39,30 @@ namespace YooAsset
} }
#region #region
/// <summary>
/// 模拟WebGL平台模式
/// </summary>
public bool VirtualWebGLMode { private set; get; } = false;
/// <summary>
/// 模拟虚拟下载模式
/// </summary>
public bool VirtualDownloadMode { private set; get; } = false;
/// <summary>
/// 模拟虚拟下载的网速(单位:字节)
/// </summary>
public int VirtualDownloadSpeed { private set; get; } = 1024;
/// <summary> /// <summary>
/// 异步模拟加载最小帧数 /// 异步模拟加载最小帧数
/// </summary> /// </summary>
public int _asyncSimulateMinFrame = 1; public int AsyncSimulateMinFrame { private set; get; } = 1;
/// <summary> /// <summary>
/// 异步模拟加载最大帧数 /// 异步模拟加载最大帧数
/// </summary> /// </summary>
public int _asyncSimulateMaxFrame = 1; public int AsyncSimulateMaxFrame { private set; get; } = 1;
#endregion #endregion
public DefaultEditorFileSystem() public DefaultEditorFileSystem()
@@ -73,7 +90,10 @@ namespace YooAsset
} }
public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options) public virtual FSDownloadFileOperation DownloadFileAsync(PackageBundle bundle, DownloadFileOptions options)
{ {
throw new System.NotImplementedException(); string mainURL = bundle.BundleName;
options.SetURL(mainURL, mainURL);
var downloader = new DownloadVirtualBundleOperation(this, bundle, options);
return downloader;
} }
public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle) public virtual FSLoadBundleOperation LoadBundleFile(PackageBundle bundle)
{ {
@@ -92,13 +112,25 @@ namespace YooAsset
public virtual void SetParameter(string name, object value) public virtual void SetParameter(string name, object value)
{ {
if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME) if (name == FileSystemParametersDefine.VIRTUAL_WEBGL_MODE)
{ {
_asyncSimulateMinFrame = Convert.ToInt32(value); VirtualWebGLMode = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.VIRTUAL_DOWNLOAD_MODE)
{
VirtualDownloadMode = Convert.ToBoolean(value);
}
else if (name == FileSystemParametersDefine.VIRTUAL_DOWNLOAD_SPEED)
{
VirtualDownloadSpeed = Convert.ToInt32(value);
}
else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME)
{
AsyncSimulateMinFrame = Convert.ToInt32(value);
} }
else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME) else if (name == FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME)
{ {
_asyncSimulateMaxFrame = Convert.ToInt32(value); AsyncSimulateMaxFrame = Convert.ToInt32(value);
} }
else else
{ {
@@ -123,12 +155,22 @@ namespace YooAsset
return true; return true;
} }
public virtual bool Exists(PackageBundle bundle) public virtual bool Exists(PackageBundle bundle)
{
if (VirtualDownloadMode)
{
return _records.ContainsKey(bundle.BundleGUID);
}
else
{ {
return true; return true;
} }
}
public virtual bool NeedDownload(PackageBundle bundle) public virtual bool NeedDownload(PackageBundle bundle)
{ {
if (Belong(bundle) == false)
return false; return false;
return Exists(bundle) == false;
} }
public virtual bool NeedUnpack(PackageBundle bundle) public virtual bool NeedUnpack(PackageBundle bundle)
{ {
@@ -165,6 +207,11 @@ namespace YooAsset
} }
#region #region
public void RecordDownloadFile(PackageBundle bundle)
{
if (_records.ContainsKey(bundle.BundleGUID) == false)
_records.Add(bundle.BundleGUID, bundle.BundleName);
}
public string GetEditorPackageVersionFilePath() public string GetEditorPackageVersionFilePath()
{ {
string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName); string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName);
@@ -182,12 +229,12 @@ namespace YooAsset
} }
public int GetAsyncSimulateFrame() public int GetAsyncSimulateFrame()
{ {
if (_asyncSimulateMinFrame > _asyncSimulateMaxFrame) if (AsyncSimulateMinFrame > AsyncSimulateMaxFrame)
{ {
_asyncSimulateMinFrame = _asyncSimulateMaxFrame; AsyncSimulateMinFrame = AsyncSimulateMaxFrame;
} }
return UnityEngine.Random.Range(_asyncSimulateMinFrame, _asyncSimulateMaxFrame + 1); return UnityEngine.Random.Range(AsyncSimulateMinFrame, AsyncSimulateMaxFrame + 1);
} }
#endregion #endregion
} }

View File

@@ -6,6 +6,7 @@ namespace YooAsset
protected enum ESteps protected enum ESteps
{ {
None, None,
CheckExist,
DownloadFile, DownloadFile,
LoadAssetBundle, LoadAssetBundle,
CheckResult, CheckResult,
@@ -14,6 +15,7 @@ namespace YooAsset
private readonly DefaultEditorFileSystem _fileSystem; private readonly DefaultEditorFileSystem _fileSystem;
private readonly PackageBundle _bundle; private readonly PackageBundle _bundle;
protected FSDownloadFileOperation _downloadFileOp;
private int _asyncSimulateFrame; private int _asyncSimulateFrame;
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
@@ -24,27 +26,75 @@ namespace YooAsset
} }
internal override void InternalStart() internal override void InternalStart()
{ {
_steps = ESteps.DownloadFile; _steps = ESteps.CheckExist;
_asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame();
} }
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.DownloadFile) if (_steps == ESteps.CheckExist)
{
if (_fileSystem.Exists(_bundle))
{ {
_asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame();
DownloadProgress = 1f; DownloadProgress = 1f;
DownloadedBytes = _bundle.FileSize; DownloadedBytes = _bundle.FileSize;
_steps = ESteps.LoadAssetBundle; _steps = ESteps.LoadAssetBundle;
} }
else
{
_steps = ESteps.DownloadFile;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
{
DownloadFileOptions options = new DownloadFileOptions(int.MaxValue);
_downloadFileOp = _fileSystem.DownloadFileAsync(_bundle, options);
_downloadFileOp.StartOperation();
AddChildOperation(_downloadFileOp);
}
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
DownloadProgress = _downloadFileOp.DownloadProgress;
DownloadedBytes = _downloadFileOp.DownloadedBytes;
if (_downloadFileOp.IsDone == false)
return;
if (_downloadFileOp.Status == EOperationStatus.Succeed)
{
_steps = ESteps.LoadAssetBundle;
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _downloadFileOp.Error;
}
}
if (_steps == ESteps.LoadAssetBundle) if (_steps == ESteps.LoadAssetBundle)
{ {
if (IsWaitForAsyncComplete) if (IsWaitForAsyncComplete)
{
if (_fileSystem.VirtualWebGLMode)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Virtual WebGL Mode only support asyn load method !";
YooLogger.Error(Error);
}
else
{ {
_steps = ESteps.CheckResult; _steps = ESteps.CheckResult;
} }
}
else else
{ {
if (_asyncSimulateFrame <= 0) if (_asyncSimulateFrame <= 0)

View File

@@ -0,0 +1,156 @@
using UnityEngine;
namespace YooAsset
{
internal class DownloadVirtualBundleOperation : FSDownloadFileOperation
{
protected enum ESteps
{
None,
CheckExists,
CreateRequest,
CheckRequest,
TryAgain,
Done,
}
// 下载参数
protected readonly DefaultEditorFileSystem _fileSystem;
protected readonly DownloadFileOptions _options;
protected UnityVirtualBundleRequestOperation _unityDownloadFileOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected int _failedTryAgain;
private ESteps _steps = ESteps.None;
internal DownloadVirtualBundleOperation(DefaultEditorFileSystem fileSystem, PackageBundle bundle, DownloadFileOptions options) : base(bundle)
{
_fileSystem = fileSystem;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{
_steps = ESteps.CheckExists;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
// 检测文件是否存在
if (_steps == ESteps.CheckExists)
{
if (_fileSystem.Exists(Bundle))
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
_steps = ESteps.CreateRequest;
}
}
// 创建下载器
if (_steps == ESteps.CreateRequest)
{
if (_options.IsValid() == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Download file options is invalid !";
Debug.Log(Error);
return;
}
string url = GetRequestURL();
int speed = _fileSystem.VirtualDownloadSpeed;
_unityDownloadFileOp = new UnityVirtualBundleRequestOperation(Bundle, speed, url);
_unityDownloadFileOp.StartOperation();
_steps = ESteps.CheckRequest;
}
// 检测下载结果
if (_steps == ESteps.CheckRequest)
{
if (IsWaitForAsyncComplete)
_unityDownloadFileOp.WaitForAsyncComplete();
// 因为并发数量限制,下载器可能被挂起!
if (_unityDownloadFileOp.Status == EOperationStatus.None)
return;
_unityDownloadFileOp.UpdateOperation();
Progress = _unityDownloadFileOp.Progress;
DownloadedBytes = _unityDownloadFileOp.DownloadedBytes;
DownloadProgress = _unityDownloadFileOp.DownloadProgress;
if (_unityDownloadFileOp.IsDone == false)
return;
if (_unityDownloadFileOp.Status == EOperationStatus.Succeed)
{
_fileSystem.RecordDownloadFile(Bundle);
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
else
{
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0)
{
_steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_unityDownloadFileOp.URL} Try again !");
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _unityDownloadFileOp.Error;
YooLogger.Error(Error);
}
}
}
// 重新尝试下载
if (_steps == ESteps.TryAgain)
{
_tryAgainTimer += Time.unscaledDeltaTime;
if (_tryAgainTimer > 1f)
{
_tryAgainTimer = 0f;
_failedTryAgain--;
Progress = 0f;
DownloadProgress = 0f;
DownloadedBytes = 0;
_steps = ESteps.CreateRequest;
}
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
/// <summary>
/// 获取网络请求地址
/// </summary>
protected string GetRequestURL()
{
// 轮流返回请求地址
_requestCount++;
if (_requestCount % 2 == 0)
return _options.FallbackURL;
else
return _options.MainURL;
}
}
}

View File

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

View File

@@ -15,8 +15,12 @@ namespace YooAsset
public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLOAD"; 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 DOWNLOAD_WATCH_DOG_TIME = "DOWNLOAD_WATCH_DOG_TIME";
public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE"; public const string RESUME_DOWNLOAD_MINMUM_SIZE = "RESUME_DOWNLOAD_MINMUM_SIZE";
public const string RESUME_DOWNLOAD_RESPONSE_CODES = "RESUME_DOWNLOAD_RESPONSE_CODES"; public const string RESUME_DOWNLOAD_RESPONSE_CODES = "RESUME_DOWNLOAD_RESPONSE_CODES";
public const string VIRTUAL_WEBGL_MODE = "VIRTUAL_WEBGL_MODE";
public const string VIRTUAL_DOWNLOAD_MODE = "VIRTUAL_DOWNLOAD_MODE";
public const string VIRTUAL_DOWNLOAD_SPEED = "VIRTUAL_DOWNLOAD_SPEED";
public const string ASYNC_SIMULATE_MIN_FRAME = "ASYNC_SIMULATE_MIN_FRAME"; public const string ASYNC_SIMULATE_MIN_FRAME = "ASYNC_SIMULATE_MIN_FRAME";
public const string ASYNC_SIMULATE_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME"; public const string ASYNC_SIMULATE_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME";
public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST"; public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST";

View File

@@ -47,6 +47,15 @@ namespace YooAsset
/// WebGL平台强制同步加载资源对象 /// WebGL平台强制同步加载资源对象
/// </summary> /// </summary>
public bool WebGLForceSyncLoadAsset = false; public bool WebGLForceSyncLoadAsset = false;
#if YOOASSET_EXPERIMENTAL
/// <summary>
/// 启用弱引用资源句柄
/// </summary>
public bool UseWeakReferenceHandle = false;
#else
internal bool UseWeakReferenceHandle = false;
#endif
} }
/// <summary> /// <summary>

View File

@@ -83,6 +83,7 @@ namespace YooAsset
{ {
if (_loadBundleOp == null) if (_loadBundleOp == null)
{ {
// 统计计数增加
_resManager.BundleLoadingCounter++; _resManager.BundleLoadingCounter++;
_loadBundleOp = LoadBundleInfo.LoadBundleFile(); _loadBundleOp = LoadBundleInfo.LoadBundleFile();
_loadBundleOp.StartOperation(); _loadBundleOp.StartOperation();
@@ -163,11 +164,12 @@ namespace YooAsset
{ {
IsDestroyed = true; IsDestroyed = true;
// Check fatal // 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.LoadBundleFile)
throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}");
if (RefCount > 0) if (RefCount > 0)
throw new Exception($"Bundle file loader ref is not zero : {LoadBundleInfo.Bundle.BundleName}"); throw new Exception($"Bundle file loader ref is not zero : {LoadBundleInfo.Bundle.BundleName}");
if (IsDone == false)
throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}");
if (Result != null) if (Result != null)
Result.UnloadBundleFile(); Result.UnloadBundleFile();
@@ -178,7 +180,8 @@ namespace YooAsset
/// </summary> /// </summary>
public bool CanDestroyLoader() public bool CanDestroyLoader()
{ {
if (IsDone == false) // 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.LoadBundleFile)
return false; return false;
if (RefCount > 0) if (RefCount > 0)

View File

@@ -17,7 +17,7 @@ namespace YooAsset
AddChildOperation(_loadAllAssetsOp); AddChildOperation(_loadAllAssetsOp);
#if UNITY_WEBGL #if UNITY_WEBGL
if (_resManager.WebGLForceSyncLoadAsset()) if (_resManager.WebGLForceSyncLoadAsset)
_loadAllAssetsOp.WaitForAsyncComplete(); _loadAllAssetsOp.WaitForAsyncComplete();
#endif #endif
} }

View File

@@ -17,7 +17,7 @@ namespace YooAsset
AddChildOperation(_loadAssetOp); AddChildOperation(_loadAssetOp);
#if UNITY_WEBGL #if UNITY_WEBGL
if (_resManager.WebGLForceSyncLoadAsset()) if (_resManager.WebGLForceSyncLoadAsset)
_loadAssetOp.WaitForAsyncComplete(); _loadAssetOp.WaitForAsyncComplete();
#endif #endif
} }

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System;
namespace YooAsset namespace YooAsset
{ {
@@ -66,12 +67,23 @@ namespace YooAsset
/// </summary> /// </summary>
public bool IsDestroyed { private set; get; } = false; public bool IsDestroyed { private set; get; } = false;
/// <summary>
/// 加载任务是否进行中
/// </summary>
private bool IsLoading
{
get
{
return _steps == ESteps.WaitBundleLoader || _steps == ESteps.ProcessBundleResult;
}
}
private ESteps _steps = ESteps.None; private ESteps _steps = ESteps.None;
protected readonly ResourceManager _resManager; protected readonly ResourceManager _resManager;
private readonly LoadBundleFileOperation _mainBundleLoader; private readonly LoadBundleFileOperation _mainBundleLoader;
private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>(10); private readonly List<LoadBundleFileOperation> _bundleLoaders = new List<LoadBundleFileOperation>(10);
private readonly HashSet<HandleBase> _handles = new HashSet<HandleBase>(); private readonly HashSet<HandleBase> _handles = new HashSet<HandleBase>();
private readonly LinkedList<WeakReference<HandleBase>> _weakReferences = new LinkedList<WeakReference<HandleBase>>();
public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo) public ProviderOperation(ResourceManager manager, string providerGUID, AssetInfo assetInfo)
{ {
@@ -107,6 +119,13 @@ namespace YooAsset
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
// 注意:未在加载中的任务可以挂起!
if (IsLoading == false)
{
if (RefCount <= 0)
return;
}
if (_steps == ESteps.StartBundleLoader) if (_steps == ESteps.StartBundleLoader)
{ {
foreach (var bundleLoader in _bundleLoaders) foreach (var bundleLoader in _bundleLoaders)
@@ -190,8 +209,9 @@ namespace YooAsset
// 检测是否为正常销毁 // 检测是否为正常销毁
if (IsDone == false) if (IsDone == false)
{ {
Error = "User abort !"; _steps = ESteps.Done;
Status = EOperationStatus.Failed; Status = EOperationStatus.Failed;
Error = "User abort !";
} }
// 减少引用计数 // 减少引用计数
@@ -206,10 +226,15 @@ namespace YooAsset
/// </summary> /// </summary>
public bool CanDestroyProvider() public bool CanDestroyProvider()
{ {
// 注意:在进行资源加载过程时不可以销毁 // 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.ProcessBundleResult) if (IsLoading)
return false; return false;
if (_resManager.UseWeakReferenceHandle)
{
TryCleanupWeakReference();
}
return RefCount <= 0; return RefCount <= 0;
} }
@@ -222,7 +247,15 @@ namespace YooAsset
RefCount++; RefCount++;
HandleBase handle = HandleFactory.CreateHandle(this, typeof(T)); HandleBase handle = HandleFactory.CreateHandle(this, typeof(T));
if (_resManager.UseWeakReferenceHandle)
{
var weakRef = new WeakReference<HandleBase>(handle);
_weakReferences.AddLast(weakRef);
}
else
{
_handles.Add(handle); _handles.Add(handle);
}
return handle as T; return handle as T;
} }
@@ -234,8 +267,16 @@ namespace YooAsset
if (RefCount <= 0) if (RefCount <= 0)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
if (_resManager.UseWeakReferenceHandle)
{
if (RemoveWeakReference(handle) == false)
throw new System.Exception("Should never get here !");
}
else
{
if (_handles.Remove(handle) == false) if (_handles.Remove(handle) == false)
throw new System.Exception("Should never get here !"); throw new System.Exception("Should never get here !");
}
// 引用计数减少 // 引用计数减少
RefCount--; RefCount--;
@@ -245,6 +286,19 @@ namespace YooAsset
/// 释放所有资源句柄 /// 释放所有资源句柄
/// </summary> /// </summary>
public void ReleaseAllHandles() public void ReleaseAllHandles()
{
if (_resManager.UseWeakReferenceHandle)
{
List<WeakReference<HandleBase>> tempers = _weakReferences.ToList();
foreach (var weakRef in tempers)
{
if (weakRef.TryGetTarget(out HandleBase target))
{
target.Release();
}
}
}
else
{ {
List<HandleBase> tempers = _handles.ToList(); List<HandleBase> tempers = _handles.ToList();
foreach (var handle in tempers) foreach (var handle in tempers)
@@ -252,6 +306,7 @@ namespace YooAsset
handle.Release(); handle.Release();
} }
} }
}
/// <summary> /// <summary>
/// 结束流程 /// 结束流程
@@ -264,12 +319,29 @@ namespace YooAsset
// 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。 // 注意:创建临时列表是为了防止外部逻辑在回调函数内创建或者释放资源句柄。
// 注意:回调方法如果发生异常,会阻断列表里的后续回调方法! // 注意:回调方法如果发生异常,会阻断列表里的后续回调方法!
if (_resManager.UseWeakReferenceHandle)
{
List<WeakReference<HandleBase>> tempers = _weakReferences.ToList();
foreach (var weakRef in tempers)
{
if (weakRef.TryGetTarget(out HandleBase target))
{
if (target.IsValid)
{
target.InvokeCallback();
}
}
}
}
else
{
List<HandleBase> tempers = _handles.ToList(); List<HandleBase> tempers = _handles.ToList();
foreach (var hande in tempers) foreach (var handle in tempers)
{ {
if (hande.IsValid) if (handle.IsValid)
{ {
hande.InvokeCallback(); handle.InvokeCallback();
}
} }
} }
} }
@@ -294,6 +366,50 @@ namespace YooAsset
return status; return status;
} }
/// <summary>
/// 移除指定句柄的弱引用对象
/// </summary>
private bool RemoveWeakReference(HandleBase handle)
{
bool removed = false;
var currentNode = _weakReferences.First;
while (currentNode != null)
{
var nextNode = currentNode.Next;
if (currentNode.Value.TryGetTarget(out HandleBase target))
{
if (ReferenceEquals(target, handle))
{
_weakReferences.Remove(currentNode);
removed = true;
break;
}
}
currentNode = nextNode;
}
return removed;
}
/// <summary>
/// 清理所有失效的弱引用
/// </summary>
private void TryCleanupWeakReference()
{
var currentNode = _weakReferences.First;
while (currentNode != null)
{
var nextNode = currentNode.Next;
if (currentNode.Value.TryGetTarget(out HandleBase target) == false)
{
_weakReferences.Remove(currentNode);
// 引用计数减少
RefCount--;
}
currentNode = nextNode;
}
}
#region #region
/// <summary> /// <summary>
/// 出生的场景 /// 出生的场景

View File

@@ -17,7 +17,7 @@ namespace YooAsset
AddChildOperation(_loadSubAssetsOp); AddChildOperation(_loadSubAssetsOp);
#if UNITY_WEBGL #if UNITY_WEBGL
if (_resManager.WebGLForceSyncLoadAsset()) if (_resManager.WebGLForceSyncLoadAsset)
_loadSubAssetsOp.WaitForAsyncComplete(); _loadSubAssetsOp.WaitForAsyncComplete();
#endif #endif
} }

View File

@@ -15,7 +15,10 @@ namespace YooAsset
private long _sceneCreateIndex = 0; private long _sceneCreateIndex = 0;
private IBundleQuery _bundleQuery; private IBundleQuery _bundleQuery;
private int _bundleLoadingMaxConcurrency; private int _bundleLoadingMaxConcurrency;
private bool _webGLForceSyncLoadAsset;
// 开发者配置选项
public bool WebGLForceSyncLoadAsset { private set; get; }
public bool UseWeakReferenceHandle { private set; get; }
/// <summary> /// <summary>
/// 所属包裹 /// 所属包裹
@@ -44,7 +47,8 @@ namespace YooAsset
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices) public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
{ {
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency; _bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
_webGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset; WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
UseWeakReferenceHandle = parameters.UseWeakReferenceHandle;
_bundleQuery = bundleServices; _bundleQuery = bundleServices;
SceneManager.sceneUnloaded += OnSceneUnloaded; SceneManager.sceneUnloaded += OnSceneUnloaded;
} }
@@ -331,10 +335,6 @@ namespace YooAsset
{ {
return BundleLoadingCounter >= _bundleLoadingMaxConcurrency; return BundleLoadingCounter >= _bundleLoadingMaxConcurrency;
} }
internal bool WebGLForceSyncLoadAsset()
{
return _webGLForceSyncLoadAsset;
}
private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo) private LoadBundleFileOperation CreateBundleFileLoaderInternal(BundleInfo bundleInfo)
{ {

View File

@@ -101,8 +101,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
@@ -121,8 +120,7 @@ namespace YooAsset
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
@@ -141,8 +139,7 @@ namespace YooAsset
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
@@ -161,8 +158,7 @@ namespace YooAsset
/// <param name="location">资源定位地址</param> /// <param name="location">资源定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {
@@ -185,8 +181,7 @@ namespace YooAsset
/// <param name="locations">资源定位地址列表</param> /// <param name="locations">资源定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
if (Status != EOperationStatus.Succeed) if (Status != EOperationStatus.Succeed)
{ {

View File

@@ -966,8 +966,7 @@ namespace YooAsset
/// </summary> /// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain); return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain);
@@ -979,8 +978,7 @@ namespace YooAsset
/// <param name="tag">资源标签</param> /// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain); return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain);
@@ -992,8 +990,7 @@ namespace YooAsset
/// <param name="tags">资源标签列表</param> /// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain); return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain);
@@ -1006,15 +1003,14 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param> /// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
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); 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)
{ {
return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain); return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain);
} }
@@ -1026,8 +1022,7 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param> /// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length); List<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -1038,7 +1033,7 @@ namespace YooAsset
} }
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos.ToArray(), recursiveDownload, downloadingMaxNumber, failedTryAgain); 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)
{ {
return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain); return CreateBundleDownloader(locations, false, downloadingMaxNumber, failedTryAgain);
} }
@@ -1050,14 +1045,13 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param> /// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
AssetInfo[] assetInfos = new AssetInfo[] { assetInfo }; AssetInfo[] assetInfos = new AssetInfo[] { assetInfo };
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain); 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)
{ {
return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain); return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain);
} }
@@ -1069,13 +1063,12 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param> /// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param> /// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param> /// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param> public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain)
public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo[] assetInfos, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60)
{ {
DebugCheckInitialize(); DebugCheckInitialize();
return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain); 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)
{ {
return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain); return CreateBundleDownloader(assetInfos, false, downloadingMaxNumber, failedTryAgain);
} }

View File

@@ -35,7 +35,7 @@ MonoBehaviour:
CollectorType: 0 CollectorType: 0
AddressRuleName: AddressByFileName AddressRuleName: AddressByFileName
PackRuleName: PackSeparately PackRuleName: PackSeparately
FilterRuleName: CollectAll FilterRuleName: CollectPrefab
AssetTags: AssetTags:
UserData: UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Entity - CollectPath: Assets/Samples/Space Shooter/GameRes/Entity
@@ -43,7 +43,7 @@ MonoBehaviour:
CollectorType: 0 CollectorType: 0
AddressRuleName: AddressByFileName AddressRuleName: AddressByFileName
PackRuleName: PackSeparately PackRuleName: PackSeparately
FilterRuleName: CollectAll FilterRuleName: CollectPrefab
AssetTags: AssetTags:
UserData: UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/Audio - CollectPath: Assets/Samples/Space Shooter/GameRes/Audio
@@ -101,7 +101,7 @@ MonoBehaviour:
CollectorType: 0 CollectorType: 0
AddressRuleName: AddressByFileName AddressRuleName: AddressByFileName
PackRuleName: PackSeparately PackRuleName: PackSeparately
FilterRuleName: CollectAll FilterRuleName: CollectScene
AssetTags: AssetTags:
UserData: UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/SceneArt - CollectPath: Assets/Samples/Space Shooter/GameRes/SceneArt
@@ -122,7 +122,7 @@ MonoBehaviour:
CollectorType: 0 CollectorType: 0
AddressRuleName: AddressByFileName AddressRuleName: AddressByFileName
PackRuleName: PackSeparately PackRuleName: PackSeparately
FilterRuleName: CollectAll FilterRuleName: CollectPrefab
AssetTags: AssetTags:
UserData: UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanelArt - CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanelArt
@@ -146,7 +146,7 @@ MonoBehaviour:
CollectorType: 1 CollectorType: 1
AddressRuleName: AddressByFileName AddressRuleName: AddressByFileName
PackRuleName: PackDirectory PackRuleName: PackDirectory
FilterRuleName: CollectAll FilterRuleName: CollectSprite
AssetTags: AssetTags:
UserData: UserData:
- CollectPath: Assets/Samples/Space Shooter/GameRes/UISpriteAtlas - CollectPath: Assets/Samples/Space Shooter/GameRes/UISpriteAtlas

View File

@@ -1,7 +1,7 @@
{ {
"name": "com.tuyoogame.yooasset", "name": "com.tuyoogame.yooasset",
"displayName": "YooAsset", "displayName": "YooAsset",
"version": "2.3.14", "version": "2.3.16",
"unity": "2019.4", "unity": "2019.4",
"description": "unity3d resources management system.", "description": "unity3d resources management system.",
"author": { "author": {