diff --git a/CHANGELOG.md b/CHANGELOG.md index a841cff..fb266af 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,88 @@ 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 + { + /// + /// 模拟虚拟下载模式 + /// + public bool VirtualDownloadMode { private set; get; } = false; + + /// + /// 模拟虚拟下载的网速(单位:字节) + /// + public int VirtualDownloadSpeed { private set; get; } = 1024; + } + ``` + +- (#640) 新增了文件系统参数:VIRTUAL_WEBGL_MODE + + 编辑器下不需要构建AB,也可以模拟小游戏开发环境,等同真机运行环境。 + + ```csharp + class DefaultEditorFIleSystem + { + /// + /// 模拟WebGL平台模式 + /// + public bool VirtualWebGLMode { private set; get; } = false; + } + ``` + +- (#642) 新增了文件系统参数:DOWNLOAD_WATCH_DOG_TIME + + 监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务! + + ```csharp + class DefaultCacheFIleSystem + { + /// + /// 自定义参数:下载任务的看门狗机制监控时间 + /// + public int DownloadWatchDogTime { private set; get; } = int.MaxValue; + } + ``` + +### Changed + +- 下载器参数timeout移除。 + + 可以使用文件系统的看门狗机制代替。 + +- (#632) IFilterRule接口变动。 + + 收集器可以指定搜寻的资源类型,在收集目录资产量巨大的情况下,可以极大加快打包速度! + + ```csharp + public interface IFilterRule + { + /// + /// 搜寻的资源类型 + /// 说明:使用引擎方法搜索获取所有资源列表 + /// + string FindAssetType { get; } + } + ``` + + + ## [2.3.15] - 2025-09-09 **重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。 @@ -69,7 +151,9 @@ All notable changes to this package will be documented in this file. - (#617) 新增资源收集配置参数:SupportExtensionless - 在不需要模糊加载模式的前提下,开启此选项,可以降低运行时内存大小。 + 在不需要模糊加载模式的前提下,关闭此选项,可以降低运行时内存大小。 + + 该选项默认开启! ```csharp public class CollectCommand diff --git a/Editor/AssetArtScanner/AssetArtScannerSetting.cs b/Editor/AssetArtScanner/AssetArtScannerSetting.cs index dd54aa6..128e021 100644 --- a/Editor/AssetArtScanner/AssetArtScannerSetting.cs +++ b/Editor/AssetArtScanner/AssetArtScannerSetting.cs @@ -46,7 +46,7 @@ namespace YooAsset.Editor } catch (Exception e) { - return new ScannerResult(e.StackTrace); + return new ScannerResult(e.Message, e.StackTrace); } } diff --git a/Editor/AssetArtScanner/ScannerResult.cs b/Editor/AssetArtScanner/ScannerResult.cs index 94b71fd..a956269 100644 --- a/Editor/AssetArtScanner/ScannerResult.cs +++ b/Editor/AssetArtScanner/ScannerResult.cs @@ -18,6 +18,11 @@ namespace YooAsset.Editor /// public string ErrorInfo { private set; get; } + /// + /// 错误堆栈 + /// + public string ErrorStack { private set; get; } + /// /// 是否成功 /// @@ -33,9 +38,10 @@ namespace YooAsset.Editor } - public ScannerResult(string error) + public ScannerResult(string error, string stack) { ErrorInfo = error; + ErrorStack = stack; } public ScannerResult(string filePath, ScanReport report) { diff --git a/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs b/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs index fe4e251..3f45711 100644 --- a/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs +++ b/Editor/AssetBundleBuilder/BuildSystem/BuildResult.cs @@ -21,6 +21,11 @@ namespace YooAsset.Editor /// public string ErrorInfo; + /// + /// 构建失败的堆栈 + /// + public string ErrorStack; + /// /// 输出的补丁包目录 /// diff --git a/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs b/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs index 25d6590..9ee48f3 100644 --- a/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs +++ b/Editor/AssetBundleBuilder/BuildSystem/BuildRunner.cs @@ -51,6 +51,7 @@ namespace YooAsset.Editor EditorTools.ClearProgressBar(); buildResult.FailedTask = task.GetType().Name; buildResult.ErrorInfo = e.ToString(); + buildResult.ErrorStack = e.StackTrace; buildResult.Success = false; break; } diff --git a/Editor/AssetBundleCollector/AssetBundleCollector.cs b/Editor/AssetBundleCollector/AssetBundleCollector.cs index 56e31cd..944ff91 100644 --- a/Editor/AssetBundleCollector/AssetBundleCollector.cs +++ b/Editor/AssetBundleCollector/AssetBundleCollector.cs @@ -139,14 +139,30 @@ namespace YooAsset.Editor /// public List GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group) { + bool ignoreStaticCollector = command.IsFlagSet(ECollectFlags.IgnoreStaticCollector); + if (ignoreStaticCollector) + { + if (CollectorType == ECollectorType.StaticAssetCollector) + return new List(); + } + + bool ignoreDependCollector = command.IsFlagSet(ECollectFlags.IgnoreDependCollector); + if (ignoreDependCollector) + { + if (CollectorType == ECollectorType.DependAssetCollector) + return new List(); + } + Dictionary result = new Dictionary(1000); // 收集打包资源路径 List findAssets = new List(); if (AssetDatabase.IsValidFolder(CollectPath)) { - string collectDirectory = CollectPath; - string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory); + IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName); + string findAssetType = filterRuleInstance.FindAssetType; + string searchFolder = CollectPath; + string[] findResult = EditorTools.FindAssets(findAssetType, searchFolder); findAssets.AddRange(findResult); } else @@ -262,8 +278,8 @@ namespace YooAsset.Editor } private List GetAllDependencies(CollectCommand command, string mainAssetPath) { - // 注意:模拟构建模式下不需要收集依赖资源 - if (command.SimulateBuild) + bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies); + if (ignoreGetDependencies) return new List(); string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true); diff --git a/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs b/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs index 29b8cd8..3bb19f3 100644 --- a/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs +++ b/Editor/AssetBundleCollector/AssetBundleCollectorWindow.cs @@ -1028,7 +1028,7 @@ namespace YooAsset.Editor IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName); string packageName = _packageNameTxt.value; var command = new CollectCommand(packageName, ignoreRule); - command.SimulateBuild = true; + command.SetFlag(ECollectFlags.IgnoreGetDependencies, true); command.UniqueBundleName = _uniqueBundleNameToogle.value; command.EnableAddressable = _enableAddressableToogle.value; command.SupportExtensionless = _supportExtensionlessToogle.value; diff --git a/Editor/AssetBundleCollector/CollectCommand.cs b/Editor/AssetBundleCollector/CollectCommand.cs index 9780120..c04bfe9 100644 --- a/Editor/AssetBundleCollector/CollectCommand.cs +++ b/Editor/AssetBundleCollector/CollectCommand.cs @@ -1,6 +1,26 @@  namespace YooAsset.Editor { + public enum ECollectFlags + { + None = 0, + + /// + /// 不收集依赖资源 + /// + IgnoreGetDependencies = 1 << 0, + + /// + /// 忽略静态收集器 + /// + IgnoreStaticCollector = 1 << 1, + + /// + /// 忽略依赖收集器 + /// + IgnoreDependCollector = 1 << 2, + } + public class CollectCommand { /// @@ -17,7 +37,20 @@ namespace YooAsset.Editor /// /// 模拟构建模式 /// - public bool SimulateBuild { set; get; } + public bool SimulateBuild + { + set + { + SetFlag(ECollectFlags.IgnoreGetDependencies, value); + SetFlag(ECollectFlags.IgnoreStaticCollector, value); + SetFlag(ECollectFlags.IgnoreDependCollector, value); + } + } + + /// + /// 窗口收集模式 + /// + public int CollectFlags { set; get; } = 0; /// /// 资源包名唯一化 @@ -70,5 +103,24 @@ namespace YooAsset.Editor PackageName = packageName; IgnoreRule = ignoreRule; } + + /// + /// 设置标记位 + /// + public void SetFlag(ECollectFlags flag, bool isOn) + { + if (isOn) + CollectFlags |= (int)flag; // 开启指定标志位 + else + CollectFlags &= ~(int)flag; // 关闭指定标志位 + } + + /// + /// 查询标记位 + /// + public bool IsFlagSet(ECollectFlags flag) + { + return (CollectFlags & (int)flag) != 0; + } } } \ No newline at end of file diff --git a/Editor/AssetBundleCollector/CollectRules/IFilterRule.cs b/Editor/AssetBundleCollector/CollectRules/IFilterRule.cs index 090c061..03ee266 100644 --- a/Editor/AssetBundleCollector/CollectRules/IFilterRule.cs +++ b/Editor/AssetBundleCollector/CollectRules/IFilterRule.cs @@ -23,7 +23,13 @@ namespace YooAsset.Editor public interface IFilterRule { /// - /// 是否为收集资源 + /// 搜寻的资源类型 + /// 说明:使用引擎方法搜索获取所有资源列表 + /// + string FindAssetType { get; } + + /// + /// 验证搜寻的资源是否为收集资源 /// /// 如果收集该资源返回TRUE bool IsCollectAsset(FilterRuleData data); diff --git a/Editor/AssetBundleCollector/DefaultRules/DefaultFilterRule.cs b/Editor/AssetBundleCollector/DefaultRules/DefaultFilterRule.cs index e1eb3b6..a2d6b20 100644 --- a/Editor/AssetBundleCollector/DefaultRules/DefaultFilterRule.cs +++ b/Editor/AssetBundleCollector/DefaultRules/DefaultFilterRule.cs @@ -9,6 +9,11 @@ namespace YooAsset.Editor [DisplayName("收集所有资源")] public class CollectAll : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.All.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { return true; @@ -18,6 +23,11 @@ namespace YooAsset.Editor [DisplayName("收集场景")] public class CollectScene : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.Scene.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { string extension = Path.GetExtension(data.AssetPath); @@ -28,6 +38,11 @@ namespace YooAsset.Editor [DisplayName("收集预制体")] public class CollectPrefab : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.Prefab.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { return Path.GetExtension(data.AssetPath) == ".prefab"; @@ -37,6 +52,11 @@ namespace YooAsset.Editor [DisplayName("收集精灵类型的纹理")] public class CollectSprite : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.Sprite.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath); @@ -58,6 +78,11 @@ namespace YooAsset.Editor [DisplayName("收集着色器")] public class CollectShader : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.Shader.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { return Path.GetExtension(data.AssetPath) == ".shader"; @@ -67,6 +92,11 @@ namespace YooAsset.Editor [DisplayName("收集着色器变种集合")] public class CollectShaderVariants : IFilterRule { + public string FindAssetType + { + get { return EAssetSearchType.All.ToString(); } + } + public bool IsCollectAsset(FilterRuleData data) { return Path.GetExtension(data.AssetPath) == ".shadervariants"; diff --git a/Editor/EditorDefine.cs b/Editor/EditorDefine.cs index d3a9801..898d20a 100644 --- a/Editor/EditorDefine.cs +++ b/Editor/EditorDefine.cs @@ -39,6 +39,7 @@ namespace YooAsset.Editor Shader, Sprite, Texture, + RenderTexture, VideoClip, } diff --git a/Editor/EditorExtension/ClearBuildCache/ClearBuildCache.cs b/Editor/EditorExtension/ClearBuildCache/ClearBuildCache.cs index 636166a..9d7c665 100644 --- a/Editor/EditorExtension/ClearBuildCache/ClearBuildCache.cs +++ b/Editor/EditorExtension/ClearBuildCache/ClearBuildCache.cs @@ -22,4 +22,4 @@ namespace YooAsset.Editor } } } -} +} \ No newline at end of file diff --git a/Editor/EditorExtension/CreateBuildinCatalog/CreateBuildinCatalogWindow.cs b/Editor/EditorExtension/CreateBuildinCatalog/CreateBuildinCatalogWindow.cs index ea3983c..c2d10fa 100644 --- a/Editor/EditorExtension/CreateBuildinCatalog/CreateBuildinCatalogWindow.cs +++ b/Editor/EditorExtension/CreateBuildinCatalog/CreateBuildinCatalogWindow.cs @@ -89,4 +89,4 @@ namespace YooAsset.Editor .ToList(); } } -} +} \ No newline at end of file diff --git a/Editor/EditorExtension/PackageComparator/PackageComparatorWindow.cs b/Editor/EditorExtension/PackageComparator/PackageComparatorWindow.cs index 897691f..98257b4 100644 --- a/Editor/EditorExtension/PackageComparator/PackageComparatorWindow.cs +++ b/Editor/EditorExtension/PackageComparator/PackageComparatorWindow.cs @@ -9,7 +9,7 @@ namespace YooAsset.Editor public class PackageComparatorWindow : EditorWindow { static PackageComparatorWindow _thisInstance; - + [MenuItem("YooAsset/Tools/补丁包比对工具", false, 102)] static void ShowWindow() { diff --git a/Editor/EditorExtension/PackageImporter/PackageImporterWindow.cs b/Editor/EditorExtension/PackageImporter/PackageImporterWindow.cs index b1dfa7e..1583323 100644 --- a/Editor/EditorExtension/PackageImporter/PackageImporterWindow.cs +++ b/Editor/EditorExtension/PackageImporter/PackageImporterWindow.cs @@ -87,4 +87,4 @@ namespace YooAsset.Editor AssetDatabase.Refresh(); } } -} +} \ No newline at end of file diff --git a/Editor/EditorExtension/ShaderVariantCollector/ShaderVariantCollectorWindow.cs b/Editor/EditorExtension/ShaderVariantCollector/ShaderVariantCollectorWindow.cs index 8d82f0b..5875ac9 100644 --- a/Editor/EditorExtension/ShaderVariantCollector/ShaderVariantCollectorWindow.cs +++ b/Editor/EditorExtension/ShaderVariantCollector/ShaderVariantCollectorWindow.cs @@ -147,4 +147,4 @@ public class ShaderVariantCollectorWindow : EditorWindow return result; } } -#endif +#endif \ No newline at end of file diff --git a/Editor/EditorTools.cs b/Editor/EditorTools.cs index c3a6824..07c5051 100644 --- a/Editor/EditorTools.cs +++ b/Editor/EditorTools.cs @@ -169,6 +169,28 @@ namespace YooAsset.Editor /// 指定搜索的文件夹列表 /// 返回搜集到的资源路径列表 public static string[] FindAssets(EAssetSearchType searchType, string[] searchInFolders) + { + return FindAssets(searchType.ToString(), searchInFolders); + } + + /// + /// 搜集资源 + /// + /// 搜集的资源类型 + /// 指定搜索的文件夹 + /// 返回搜集到的资源路径列表 + public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder) + { + return FindAssets(searchType.ToString(), new string[] { searchInFolder }); + } + + /// + /// 搜集资源 + /// + /// 搜集的资源类型 + /// 指定搜索的文件夹列表 + /// 返回搜集到的资源路径列表 + public static string[] FindAssets(string searchType, string[] searchInFolders) { // 注意:AssetDatabase.FindAssets()不支持末尾带分隔符的文件夹路径 for (int i = 0; i < searchInFolders.Length; i++) @@ -179,7 +201,7 @@ namespace YooAsset.Editor // 注意:获取指定目录下的所有资源对象(包括子文件夹) string[] guids; - if (searchType == EAssetSearchType.All) + if (string.IsNullOrEmpty(searchType) || searchType == EAssetSearchType.All.ToString()) guids = AssetDatabase.FindAssets(string.Empty, searchInFolders); else guids = AssetDatabase.FindAssets($"t:{searchType}", searchInFolders); @@ -206,7 +228,7 @@ namespace YooAsset.Editor /// 搜集的资源类型 /// 指定搜索的文件夹 /// 返回搜集到的资源路径列表 - public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder) + public static string[] FindAssets(string searchType, string searchInFolder) { return FindAssets(searchType, new string[] { searchInFolder }); } diff --git a/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs b/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs new file mode 100644 index 0000000..1923bfd --- /dev/null +++ b/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs @@ -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 !"; + } + } + } +} \ No newline at end of file diff --git a/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs.meta b/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs.meta new file mode 100644 index 0000000..c59ceee --- /dev/null +++ b/Runtime/DownloadSystem/Operation/Internal/UnityVirtualBundleRequestOperation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9e71e850eded0da43906cb4f7cb75629 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs b/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs index f764296..6681b28 100644 --- a/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs +++ b/Runtime/FileSystem/DefaultCacheFileSystem/DefaultCacheFileSystem.cs @@ -96,6 +96,11 @@ namespace YooAsset /// public int DownloadMaxRequestPerFrame { private set; get; } = int.MaxValue; + /// + /// 自定义参数:下载任务的看门狗机制监控时间 + /// + public int DownloadWatchDogTime { private set; get; } = int.MaxValue; + /// /// 自定义参数:启用断点续传的最小尺寸 /// @@ -252,6 +257,11 @@ namespace YooAsset int convertValue = Convert.ToInt32(value); 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) { ResumeDownloadMinimumSize = Convert.ToInt64(value); diff --git a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadFileOperation.cs b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadFileOperation.cs index 0f2279a..cb02201 100644 --- a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadFileOperation.cs +++ b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadFileOperation.cs @@ -17,6 +17,11 @@ namespace YooAsset protected readonly PackageBundle _bundle; protected readonly string _tempFilePath; + private bool _watchDogInit = false; + private bool _watchDogAborted = false; + private ulong _lastDownloadBytes; + private double _lastGetDataTime; + /// /// 引用计数 /// @@ -33,6 +38,47 @@ namespace YooAsset return $"RefCount : {RefCount}"; } + /// + /// 更新看门狗监测 + /// 说明:监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务! + /// + 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(); //终止网络请求 + } + } + } + /// /// 减少引用计数 /// diff --git a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadLocalFileOperation.cs b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadLocalFileOperation.cs index 5600ad7..b3961ec 100644 --- a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadLocalFileOperation.cs +++ b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadLocalFileOperation.cs @@ -4,7 +4,7 @@ using UnityEngine.Networking; namespace YooAsset { - internal class UnityDownloadLocalFileOperation : UnityDownloadFileOperation + internal sealed class UnityDownloadLocalFileOperation : UnityDownloadFileOperation { private VerifyTempFileOperation _verifyOperation; private ESteps _steps = ESteps.None; @@ -42,6 +42,8 @@ namespace YooAsset DownloadProgress = _webRequest.downloadProgress; DownloadedBytes = (long)_webRequest.downloadedBytes; Progress = DownloadProgress; + + UpdateWatchDog(); if (_webRequest.isDone == false) return; diff --git a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadNormalFileOperation.cs b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadNormalFileOperation.cs index ce88310..d2ded35 100644 --- a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadNormalFileOperation.cs +++ b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadNormalFileOperation.cs @@ -39,6 +39,8 @@ namespace YooAsset DownloadProgress = _webRequest.downloadProgress; DownloadedBytes = (long)_webRequest.downloadedBytes; Progress = DownloadProgress; + + UpdateWatchDog(); if (_webRequest.isDone == false) return; diff --git a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadResumeFileOperation.cs b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadResumeFileOperation.cs index a774817..7a0cf47 100644 --- a/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadResumeFileOperation.cs +++ b/Runtime/FileSystem/DefaultCacheFileSystem/Operation/internal/UnityDownloadResumeFileOperation.cs @@ -56,6 +56,8 @@ namespace YooAsset DownloadProgress = _webRequest.downloadProgress; DownloadedBytes = _fileOriginLength + (long)_webRequest.downloadedBytes; Progress = DownloadProgress; + + UpdateWatchDog(); if (_webRequest.isDone == false) return; diff --git a/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs b/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs index b4108bc..429b0d0 100644 --- a/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs +++ b/Runtime/FileSystem/DefaultEditorFileSystem/DefaultEditorFileSystem.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; namespace YooAsset { @@ -7,6 +8,7 @@ namespace YooAsset /// internal class DefaultEditorFileSystem : IFileSystem { + protected readonly Dictionary _records = new Dictionary(10000); protected string _packageRoot; /// @@ -37,15 +39,30 @@ namespace YooAsset } #region 自定义参数 + /// + /// 模拟WebGL平台模式 + /// + public bool VirtualWebGLMode { private set; get; } = false; + + /// + /// 模拟虚拟下载模式 + /// + public bool VirtualDownloadMode { private set; get; } = false; + + /// + /// 模拟虚拟下载的网速(单位:字节) + /// + public int VirtualDownloadSpeed { private set; get; } = 1024; + /// /// 异步模拟加载最小帧数 /// - public int _asyncSimulateMinFrame = 1; + public int AsyncSimulateMinFrame { private set; get; } = 1; /// /// 异步模拟加载最大帧数 /// - public int _asyncSimulateMaxFrame = 1; + public int AsyncSimulateMaxFrame { private set; get; } = 1; #endregion public DefaultEditorFileSystem() @@ -73,7 +90,10 @@ namespace YooAsset } 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) { @@ -92,13 +112,25 @@ namespace YooAsset 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) { - _asyncSimulateMaxFrame = Convert.ToInt32(value); + AsyncSimulateMaxFrame = Convert.ToInt32(value); } else { @@ -124,11 +156,21 @@ namespace YooAsset } public virtual bool Exists(PackageBundle bundle) { - return true; + if (VirtualDownloadMode) + { + return _records.ContainsKey(bundle.BundleGUID); + } + else + { + return true; + } } public virtual bool NeedDownload(PackageBundle bundle) { - return false; + if (Belong(bundle) == false) + return false; + + return Exists(bundle) == false; } public virtual bool NeedUnpack(PackageBundle bundle) { @@ -165,6 +207,11 @@ namespace YooAsset } #region 内部方法 + public void RecordDownloadFile(PackageBundle bundle) + { + if (_records.ContainsKey(bundle.BundleGUID) == false) + _records.Add(bundle.BundleGUID, bundle.BundleName); + } public string GetEditorPackageVersionFilePath() { string fileName = YooAssetSettingsData.GetPackageVersionFileName(PackageName); @@ -182,12 +229,12 @@ namespace YooAsset } 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 } diff --git a/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs index 8edfc97..9056001 100644 --- a/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs +++ b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/DEFSLoadBundleOperation.cs @@ -6,6 +6,7 @@ namespace YooAsset protected enum ESteps { None, + CheckExist, DownloadFile, LoadAssetBundle, CheckResult, @@ -14,6 +15,7 @@ namespace YooAsset private readonly DefaultEditorFileSystem _fileSystem; private readonly PackageBundle _bundle; + protected FSDownloadFileOperation _downloadFileOp; private int _asyncSimulateFrame; private ESteps _steps = ESteps.None; @@ -24,26 +26,74 @@ namespace YooAsset } internal override void InternalStart() { - _steps = ESteps.DownloadFile; + _steps = ESteps.CheckExist; + _asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame(); } internal override void InternalUpdate() { if (_steps == ESteps.None || _steps == ESteps.Done) return; + if (_steps == ESteps.CheckExist) + { + if (_fileSystem.Exists(_bundle)) + { + DownloadProgress = 1f; + DownloadedBytes = _bundle.FileSize; + _steps = ESteps.LoadAssetBundle; + } + else + { + _steps = ESteps.DownloadFile; + } + } + if (_steps == ESteps.DownloadFile) { - _asyncSimulateFrame = _fileSystem.GetAsyncSimulateFrame(); - DownloadProgress = 1f; - DownloadedBytes = _bundle.FileSize; - _steps = ESteps.LoadAssetBundle; + 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 (IsWaitForAsyncComplete) { - _steps = ESteps.CheckResult; + 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; + } } else { diff --git a/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs new file mode 100644 index 0000000..963c378 --- /dev/null +++ b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs @@ -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; + } + } + } + + /// + /// 获取网络请求地址 + /// + protected string GetRequestURL() + { + // 轮流返回请求地址 + _requestCount++; + if (_requestCount % 2 == 0) + return _options.FallbackURL; + else + return _options.MainURL; + } + } +} \ No newline at end of file diff --git a/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs.meta b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs.meta new file mode 100644 index 0000000..fe0f5b4 --- /dev/null +++ b/Runtime/FileSystem/DefaultEditorFileSystem/Operation/internal/DownloadVirutalBundleOperation.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f043dc0e0f147334380cfd0720636544 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime/FileSystem/FileSystemParametersDefine.cs b/Runtime/FileSystem/FileSystemParametersDefine.cs index b93f238..0f4829a 100644 --- a/Runtime/FileSystem/FileSystemParametersDefine.cs +++ b/Runtime/FileSystem/FileSystemParametersDefine.cs @@ -15,8 +15,12 @@ namespace YooAsset public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLOAD"; 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_WATCH_DOG_TIME = "DOWNLOAD_WATCH_DOG_TIME"; 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 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_MAX_FRAME = "ASYNC_SIMULATE_MAX_FRAME"; public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST"; diff --git a/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs b/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs index c23d0e9..038a54a 100644 --- a/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs +++ b/Runtime/ResourceManager/Operation/Internal/LoadBundleFileOperation.cs @@ -83,6 +83,7 @@ namespace YooAsset { if (_loadBundleOp == null) { + // 统计计数增加 _resManager.BundleLoadingCounter++; _loadBundleOp = LoadBundleInfo.LoadBundleFile(); _loadBundleOp.StartOperation(); @@ -163,11 +164,12 @@ namespace YooAsset { IsDestroyed = true; - // Check fatal + // 注意:正在加载中的任务不可以销毁 + if (_steps == ESteps.LoadBundleFile) + throw new Exception($"Bundle file loader is not done : {LoadBundleInfo.Bundle.BundleName}"); + if (RefCount > 0) 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) Result.UnloadBundleFile(); @@ -178,7 +180,8 @@ namespace YooAsset /// public bool CanDestroyLoader() { - if (IsDone == false) + // 注意:正在加载中的任务不可以销毁 + if (_steps == ESteps.LoadBundleFile) return false; if (RefCount > 0) diff --git a/Runtime/ResourceManager/Provider/ProviderOperation.cs b/Runtime/ResourceManager/Provider/ProviderOperation.cs index c4079dc..02e6357 100644 --- a/Runtime/ResourceManager/Provider/ProviderOperation.cs +++ b/Runtime/ResourceManager/Provider/ProviderOperation.cs @@ -67,6 +67,16 @@ namespace YooAsset /// public bool IsDestroyed { private set; get; } = false; + /// + /// 加载任务是否进行中 + /// + private bool IsLoading + { + get + { + return _steps == ESteps.WaitBundleLoader || _steps == ESteps.ProcessBundleResult; + } + } private ESteps _steps = ESteps.None; protected readonly ResourceManager _resManager; @@ -109,6 +119,13 @@ namespace YooAsset if (_steps == ESteps.None || _steps == ESteps.Done) return; + // 注意:未在加载中的任务可以挂起! + if (IsLoading == false) + { + if (RefCount <= 0) + return; + } + if (_steps == ESteps.StartBundleLoader) { foreach (var bundleLoader in _bundleLoaders) @@ -192,8 +209,9 @@ namespace YooAsset // 检测是否为正常销毁 if (IsDone == false) { - Error = "User abort !"; + _steps = ESteps.Done; Status = EOperationStatus.Failed; + Error = "User abort !"; } // 减少引用计数 @@ -208,8 +226,8 @@ namespace YooAsset /// public bool CanDestroyProvider() { - // 注意:在进行资源加载过程时不可以销毁 - if (_steps == ESteps.ProcessBundleResult) + // 注意:正在加载中的任务不可以销毁 + if (IsLoading) return false; if (_resManager.UseWeakReferenceHandle) diff --git a/Runtime/ResourcePackage/Operation/PreDownloadContentOperation.cs b/Runtime/ResourcePackage/Operation/PreDownloadContentOperation.cs index eda69dc..5326a3f 100644 --- a/Runtime/ResourcePackage/Operation/PreDownloadContentOperation.cs +++ b/Runtime/ResourcePackage/Operation/PreDownloadContentOperation.cs @@ -101,8 +101,7 @@ namespace YooAsset /// /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain) { if (Status != EOperationStatus.Succeed) { @@ -121,8 +120,7 @@ namespace YooAsset /// 资源标签 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain) { if (Status != EOperationStatus.Succeed) { @@ -141,8 +139,7 @@ namespace YooAsset /// 资源标签列表 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain) { if (Status != EOperationStatus.Succeed) { @@ -161,8 +158,7 @@ namespace YooAsset /// 资源定位地址 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain) { if (Status != EOperationStatus.Succeed) { @@ -185,8 +181,7 @@ namespace YooAsset /// 资源定位地址列表 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain) { if (Status != EOperationStatus.Succeed) { diff --git a/Runtime/ResourcePackage/ResourcePackage.cs b/Runtime/ResourcePackage/ResourcePackage.cs index 53cc733..452893c 100644 --- a/Runtime/ResourcePackage/ResourcePackage.cs +++ b/Runtime/ResourcePackage/ResourcePackage.cs @@ -966,8 +966,7 @@ namespace YooAsset /// /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); return _playModeImpl.CreateResourceDownloaderByAll(downloadingMaxNumber, failedTryAgain); @@ -979,8 +978,7 @@ namespace YooAsset /// 资源标签 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(string tag, int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); return _playModeImpl.CreateResourceDownloaderByTags(new string[] { tag }, downloadingMaxNumber, failedTryAgain); @@ -992,8 +990,7 @@ namespace YooAsset /// 资源标签列表 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateResourceDownloader(string[] tags, int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); return _playModeImpl.CreateResourceDownloaderByTags(tags, downloadingMaxNumber, failedTryAgain); @@ -1006,15 +1003,14 @@ namespace YooAsset /// 下载资源对象所属资源包内所有资源对象依赖的资源包 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(string location, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); var assetInfo = ConvertLocationToAssetInfo(location, null); AssetInfo[] assetInfos = new AssetInfo[] { assetInfo }; return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain); } - public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(string location, int downloadingMaxNumber, int failedTryAgain) { return CreateBundleDownloader(location, false, downloadingMaxNumber, failedTryAgain); } @@ -1026,8 +1022,7 @@ namespace YooAsset /// 下载资源对象所属资源包内所有资源对象依赖的资源包 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(string[] locations, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); List assetInfos = new List(locations.Length); @@ -1038,7 +1033,7 @@ namespace YooAsset } 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); } @@ -1050,14 +1045,13 @@ namespace YooAsset /// 下载资源对象所属资源包内所有资源对象依赖的资源包 /// 同时下载的最大文件数 /// 下载失败的重试次数 - /// 超时时间 - public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, bool recursiveDownload, int downloadingMaxNumber, int failedTryAgain) { DebugCheckInitialize(); AssetInfo[] assetInfos = new AssetInfo[] { assetInfo }; return _playModeImpl.CreateResourceDownloaderByPaths(assetInfos, recursiveDownload, downloadingMaxNumber, failedTryAgain); } - public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain, int timeout = 60) + public ResourceDownloaderOperation CreateBundleDownloader(AssetInfo assetInfo, int downloadingMaxNumber, int failedTryAgain) { return CreateBundleDownloader(assetInfo, false, downloadingMaxNumber, failedTryAgain); } @@ -1069,13 +1063,12 @@ 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) { DebugCheckInitialize(); 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); } diff --git a/Samples~/Space Shooter/GameSetting/AssetBundleCollectorSetting.asset b/Samples~/Space Shooter/GameSetting/AssetBundleCollectorSetting.asset index 0f948d7..76185d0 100644 --- a/Samples~/Space Shooter/GameSetting/AssetBundleCollectorSetting.asset +++ b/Samples~/Space Shooter/GameSetting/AssetBundleCollectorSetting.asset @@ -35,7 +35,7 @@ MonoBehaviour: CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately - FilterRuleName: CollectAll + FilterRuleName: CollectPrefab AssetTags: UserData: - CollectPath: Assets/Samples/Space Shooter/GameRes/Entity @@ -43,7 +43,7 @@ MonoBehaviour: CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately - FilterRuleName: CollectAll + FilterRuleName: CollectPrefab AssetTags: UserData: - CollectPath: Assets/Samples/Space Shooter/GameRes/Audio @@ -101,7 +101,7 @@ MonoBehaviour: CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately - FilterRuleName: CollectAll + FilterRuleName: CollectScene AssetTags: UserData: - CollectPath: Assets/Samples/Space Shooter/GameRes/SceneArt @@ -122,7 +122,7 @@ MonoBehaviour: CollectorType: 0 AddressRuleName: AddressByFileName PackRuleName: PackSeparately - FilterRuleName: CollectAll + FilterRuleName: CollectPrefab AssetTags: UserData: - CollectPath: Assets/Samples/Space Shooter/GameRes/UIPanelArt @@ -146,7 +146,7 @@ MonoBehaviour: CollectorType: 1 AddressRuleName: AddressByFileName PackRuleName: PackDirectory - FilterRuleName: CollectAll + FilterRuleName: CollectSprite AssetTags: UserData: - CollectPath: Assets/Samples/Space Shooter/GameRes/UISpriteAtlas diff --git a/package.json b/package.json index 316ed25..7877605 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.alicizax.unity.tuyoogame.yooasset", "displayName": "YooAsset", - "version": "2.3.15", + "version": "2.3.16", "unity": "2019.4", "description": "unity3d resources management system.", "author": {