Compare commits

...

40 Commits

Author SHA1 Message Date
何冠峰
101236db8a Update CHANGELOG.md 2025-10-30 20:49:54 +08:00
何冠峰
37de007b3f Update package.json 2025-10-30 20:49:51 +08:00
何冠峰
d570ba8d74 fix #661 2025-10-30 18:31:06 +08:00
何冠峰
2a956099ae 移除程序集里冗余引用 2025-10-30 11:25:21 +08:00
何冠峰
74037a5a29 fix #670 2025-10-28 19:16:51 +08:00
何冠峰
861f850a32 Merge branch 'dev' of https://github.com/tuyoogame/YooAsset into dev 2025-10-27 17:42:32 +08:00
何冠峰
8b1b5f988a fix #669 2025-10-27 17:42:29 +08:00
何冠峰
efafd1173f Merge pull request #667 from yueh0607/fix/chinese-input-textfield
Fix Chinese input issue in TextField by enabling isDelayed
2025-10-27 09:50:52 +08:00
yzp
03e49ff1fb Fix Chinese input issue in TextField by enabling isDelayed
Fixed an issue where Chinese IME candidate characters were being incorrectly inserted into TextFields (PackageDesc, GroupDesc, etc.), causing garbled text like "默认包baobabmo'rmom".

The fix sets `isDelayed = true` on all TextFields in AssetBundleCollectorWindow, which defers value change callbacks until the user completes input (by pressing Enter or losing focus), thus avoiding interference from IME candidate characters.

Modified TextFields:
- PackageName
- PackageDesc
- GroupName
- GroupDesc
- GroupTags
- User Data (collector)
- Asset Tags (collector)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 00:01:48 +08:00
何冠峰
ea34be1f00 fix #646 2025-10-15 17:27:08 +08:00
何冠峰
831a9981e3 Update SearchCacheFilesOperation.cs 2025-10-14 16:58:06 +08:00
何冠峰
9de4aaa658 Merge pull request #656 from AlanLiu90/dev
优化SearchCacheFilesOperation
2025-10-14 16:43:07 +08:00
Alan Liu
3579a23bd5 优化SearchCacheFilesOperation 2025-10-13 18:55:49 +08:00
何冠峰
c865ddc7f2 feat #650 2025-10-10 10:20:02 +08:00
何冠峰
0bde506aec feat #648 2025-10-09 19:10:26 +08:00
何冠峰
15005b3d30 sample : 程序集宏支持
YOO_MACRO_SUPPORT开启扩展代码
2025-10-09 19:07:03 +08:00
何冠峰
4caf733ac6 fix #652 2025-10-09 16:17:44 +08:00
何冠峰
014b17f5cb feat #643 2025-10-09 16:14:31 +08:00
何冠峰
f3ebda0c04 refactor : 重构资源清单反序列化逻辑 2025-09-30 15:35:32 +08:00
何冠峰
5602addaca fix #645
修复极端情况下Shader变种收集不完整的问题
2025-09-24 16:37:46 +08:00
何冠峰
c4ae67aa8e perf: 资源扫描不再主动生成报告文件 2025-09-23 11:08:55 +08:00
何冠峰
bbcc3bf971 style : 修改代码注释说明 2025-09-19 10:05:45 +08:00
何冠峰
8b0e75b9b3 feat : 扩展Taptap小游戏文件类 2025-09-19 10:05:16 +08:00
何冠峰
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
74 changed files with 1339 additions and 379 deletions

View File

@@ -2,6 +2,149 @@
All notable changes to this package will be documented in this file.
## [2.3.17] - 2025-10-30
**非常重要**:修复了#627优化导致的资源清单CRC值为空的问题
该问题会导致下载的损坏文件验证通过。
影响范围v2.3.15版本v2.3.16版本。
**非常重要**(#661) 修复了Package销毁过程中遇到正在加载的AssetBundle会导致无法卸载的问题。
该问题是偶现引擎会提示AssetBundle已经加载无法加载新的文件导致资源对象加载失败
影响范围:所有版本!
### Improvements
- 重构并统一了资源清单的反序列化逻辑。
### Fixed
- (#645) 修复了着色器变种收集工具,在极端情况下变种收集不完整的问题。
- (#646) 修复了EditorSimulateMode模式下开启模拟下载tag不生效的问题。
- (#667) 修复了所有编辑器窗口针对中文IME的输入问题。
- (#670) 修复了Catalog文件生成过程中白名单未考虑自定义清单前缀名。
### Improvements
- (#650) 解决互相依赖的资源包无法卸载的问题。需要开启宏定义YOOASSET_EXPERIMENTAL
- (#655) 优化了初始化的时候缓存文件搜索效率。安卓平台性能提升1倍IOS平台性能提升3倍。
### Added
- (#643) 新增构建参数,可以节省资源清单运行时内存
```csharp
class ScriptableBuildParameters
{
/// <summary>
/// 使用可寻址地址代替资源路径
/// 说明:开启此项可以节省运行时清单占用的内存!
/// </summary>
public bool ReplaceAssetPathWithAddress = false;
}
```
- (#648) 新增初始化参数,可以自动释放引用计数为零的资源包
```csharp
class InitializeParameters
{
/// <summary>
/// 当资源引用计数为零的时候自动释放资源包
/// </summary>
public bool AutoUnloadBundleWhenUnused = false;
}
```
### Changed
- 程序集宏定义代码转移到扩展工程。参考MacroSupport文件夹。
## [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
**重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。
@@ -69,7 +212,9 @@ All notable changes to this package will be documented in this file.
- (#617) 新增资源收集配置参数SupportExtensionless
在不需要模糊加载模式的前提下,开启此选项,可以降低运行时内存大小。
在不需要模糊加载模式的前提下,关闭此选项,可以降低运行时内存大小。
该选项默认开启!
```csharp
public class CollectCommand

View File

@@ -32,21 +32,14 @@ namespace YooAsset.Editor
// 开始扫描工作
ScanReport report = scanner.RunScanner();
// 检测报告合法性
report.CheckError();
// 保存扫描结果
string saveDirectory = scanner.SaveDirectory;
if (string.IsNullOrEmpty(saveDirectory))
saveDirectory = "Assets/";
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
ScanReportConfig.ExportJsonConfig(filePath, report);
return new ScannerResult(filePath, report);
// 返回扫描结果
return new ScannerResult(report);
}
catch (Exception e)
{
return new ScannerResult(e.StackTrace);
return new ScannerResult(e.Message, e.StackTrace);
}
}

View File

@@ -3,11 +3,6 @@ namespace YooAsset.Editor
{
public class ScannerResult
{
/// <summary>
/// 生成的报告文件路径
/// </summary>
public string ReprotFilePath { private set; get; }
/// <summary>
/// 报告对象
/// </summary>
@@ -18,6 +13,11 @@ namespace YooAsset.Editor
/// </summary>
public string ErrorInfo { private set; get; }
/// <summary>
/// 错误堆栈
/// </summary>
public string ErrorStack { private set; get; }
/// <summary>
/// 是否成功
/// </summary>
@@ -33,15 +33,14 @@ namespace YooAsset.Editor
}
public ScannerResult(string error)
public ScannerResult(string error, string stack)
{
ErrorInfo = error;
ErrorStack = stack;
}
public ScannerResult(string filePath, ScanReport report)
public ScannerResult(ScanReport report)
{
ReprotFilePath = filePath;
Report = report;
ErrorInfo = string.Empty;
}
/// <summary>
@@ -55,5 +54,19 @@ namespace YooAsset.Editor
reproterWindow.ImportSingleReprotFile(Report);
}
}
/// <summary>
/// 保存报告文件
/// </summary>
public void SaveReportFile(string saveDirectory)
{
if (Report == null)
throw new System.Exception("Scan report is invalid !");
if (string.IsNullOrEmpty(saveDirectory))
saveDirectory = "Assets/";
string filePath = $"{saveDirectory}/{Report.ReportName}_{Report.ReportDesc}.json";
ScanReportConfig.ExportJsonConfig(filePath, Report);
}
}
}

View File

@@ -106,7 +106,27 @@ namespace YooAsset.Editor
/// </summary>
public string[] GetAllPackAssetPaths()
{
return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
List<string> results = new List<string>(AllPackAssets.Count);
for (int i = 0; i < AllPackAssets.Count; i++)
{
var packAsset = AllPackAssets[i];
results.Add(packAsset.AssetInfo.AssetPath);
}
return results.ToArray();
}
/// <summary>
/// 获取构建的资源可寻址列表
/// </summary>
public string[] GetAllPackAssetAddress()
{
List<string> results = new List<string>(AllPackAssets.Count);
for (int i = 0; i < AllPackAssets.Count; i++)
{
var packAsset = AllPackAssets[i];
results.Add(packAsset.Address);
}
return results.ToArray();
}
/// <summary>
@@ -153,13 +173,15 @@ namespace YooAsset.Editor
/// <summary>
/// 创建AssetBundleBuild类
/// </summary>
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
{
// 注意我们不再支持AssetBundle的变种机制
AssetBundleBuild build = new AssetBundleBuild();
build.assetBundleName = BundleName;
build.assetBundleVariant = string.Empty;
build.assetNames = GetAllPackAssetPaths();
if (replaceAssetPathWithAddress)
build.addressableNames = GetAllPackAssetAddress();
return build;
}

View File

@@ -96,12 +96,12 @@ namespace YooAsset.Editor
/// <summary>
/// 获取构建管线里需要的数据
/// </summary>
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddres)
{
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
foreach (var bundleInfo in _bundleInfoDic.Values)
{
builds.Add(bundleInfo.CreatePipelineBuild());
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddres));
}
return builds.ToArray();
}

View File

@@ -19,7 +19,7 @@ namespace YooAsset.Editor
/// <summary>
/// 创建补丁清单文件到输出目录
/// </summary>
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, bool replaceAssetPathWithAddress, BuildContext context)
{
var buildMapContext = context.GetContextObject<BuildMapContext>();
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
manifest.ReplaceAssetPathWithAddress = replaceAssetPathWithAddress;
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
manifest.BuildBundleType = buildParameters.BuildBundleType;
manifest.BuildPipeline = buildParameters.BuildPipeline;
@@ -58,7 +59,13 @@ namespace YooAsset.Editor
// 4. 处理内置资源包
if (processBundleDepends)
{
// 注意:初始化资源清单建立引用关系
manifest.Initialize();
ProcessBuiltinBundleDependency(context, manifest);
}
// 创建资源清单文本文件
{
@@ -302,9 +309,6 @@ namespace YooAsset.Editor
#region YOOASSET_LEGACY_DEPENDENCY
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
{
// 注意:初始化资源清单建立引用关系
ManifestTools.InitManifest(manifest);
// 注意:如果是可编程构建管线,需要补充内置资源包
// 注意:该步骤依赖前面的操作!
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();

View File

@@ -54,6 +54,7 @@ namespace YooAsset.Editor
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
buildReport.Summary.ReplaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
}
else if (buildParameters is ScriptableBuildParameters)
{
@@ -61,6 +62,7 @@ namespace YooAsset.Editor
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
buildReport.Summary.ReplaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;

View File

@@ -23,7 +23,8 @@ namespace YooAsset.Editor
// 开始构建
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
var bundleBuilds = buildMapContext.GetPipelineBuilds(builtinBuildParameters.ReplaceAssetPathWithAddress);
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, bundleBuilds, buildOptions, buildParametersContext.Parameters.BuildTarget);
if (unityManifest == null)
{
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");

View File

@@ -11,7 +11,10 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
CreateManifestFile(true, true, context);
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
bool replaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
}
protected override string[] GetBundleDepends(BuildContext context, string bundleName)

View File

@@ -27,6 +27,12 @@ namespace YooAsset.Editor
/// </summary>
public bool IgnoreTypeTreeChanges = true;
/// <summary>
/// 使用可寻址地址代替资源路径
/// 说明:开启此项可以节省运行时清单占用的内存!
/// </summary>
public bool ReplaceAssetPathWithAddress = false;
/// <summary>
/// 获取内置构建管线的构建选项

View File

@@ -7,7 +7,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
CreateManifestFile(false, false, context);
CreateManifestFile(false, true, false, context);
}
protected override string[] GetBundleDepends(BuildContext context, string bundleName)

View File

@@ -9,7 +9,7 @@ namespace YooAsset.Editor
{
void IBuildTask.Run(BuildContext context)
{
CreateManifestFile(false, true, context);
CreateManifestFile(false, true, false, context);
}
protected override string[] GetBundleDepends(BuildContext context, string bundleName)

View File

@@ -24,7 +24,8 @@ namespace YooAsset.Editor
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
// 构建内容
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
var bundleBuilds = buildMapContext.GetPipelineBuilds(scriptableBuildParameters.ReplaceAssetPathWithAddress);
var buildContent = new BundleBuildContent(bundleBuilds);
// 开始构建
IBundleBuildResults buildResults;

View File

@@ -13,7 +13,10 @@ namespace YooAsset.Editor
void IBuildTask.Run(BuildContext context)
{
CreateManifestFile(true, true, context);
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
bool replaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
}
protected override string[] GetBundleDepends(BuildContext context, string bundleName)

View File

@@ -29,6 +29,12 @@ namespace YooAsset.Editor
/// </summary>
public bool IgnoreTypeTreeChanges = true;
/// <summary>
/// 使用可寻址地址代替资源路径
/// 说明:开启此项可以节省运行时清单占用的内存!
/// </summary>
public bool ReplaceAssetPathWithAddress = false;
/// <summary>
/// 自动建立资源对象对图集的依赖关系
/// </summary>

View File

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

View File

@@ -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;
}

View File

@@ -139,14 +139,30 @@ namespace YooAsset.Editor
/// </summary>
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);
// 收集打包资源路径
List<string> findAssets = new List<string>();
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<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{
// 注意:模拟构建模式下不需要收集依赖资源
if (command.SimulateBuild)
bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies);
if (ignoreGetDependencies)
return new List<AssetInfo>();
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);

View File

@@ -236,6 +236,7 @@ namespace YooAsset.Editor
// 包裹名称
_packageNameTxt = root.Q<TextField>("PackageName");
_packageNameTxt.isDelayed = true;
_packageNameTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
@@ -249,6 +250,7 @@ namespace YooAsset.Editor
// 包裹备注
_packageDescTxt = root.Q<TextField>("PackageDesc");
_packageDescTxt.isDelayed = true;
_packageDescTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
@@ -286,6 +288,7 @@ namespace YooAsset.Editor
// 分组名称
_groupNameTxt = root.Q<TextField>("GroupName");
_groupNameTxt.isDelayed = true;
_groupNameTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
@@ -300,6 +303,7 @@ namespace YooAsset.Editor
// 分组备注
_groupDescTxt = root.Q<TextField>("GroupDesc");
_groupDescTxt.isDelayed = true;
_groupDescTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
@@ -314,6 +318,7 @@ namespace YooAsset.Editor
// 分组的资源标签
_groupTagsTxt = root.Q<TextField>("GroupTags");
_groupTagsTxt.isDelayed = true;
_groupTagsTxt.RegisterValueChangedCallback(evt =>
{
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
@@ -817,6 +822,7 @@ namespace YooAsset.Editor
var textField = new TextField();
textField.name = "TextField0";
textField.label = "User Data";
textField.isDelayed = true;
textField.style.width = 200;
elementBottom.Add(textField);
var label = textField.Q<Label>();
@@ -826,6 +832,7 @@ namespace YooAsset.Editor
var textField = new TextField();
textField.name = "TextField1";
textField.label = "Asset Tags";
textField.isDelayed = true;
textField.style.width = 100;
textField.style.marginLeft = 20;
textField.style.flexGrow = 1;
@@ -1028,7 +1035,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;

View File

@@ -1,6 +1,26 @@

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
{
/// <summary>
@@ -17,7 +37,20 @@ namespace YooAsset.Editor
/// <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>
/// 资源包名唯一化
@@ -70,5 +103,24 @@ namespace YooAsset.Editor
PackageName = packageName;
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
{
/// <summary>
/// 是否为收集资源
/// 搜寻的资源类型
/// 说明:使用引擎方法搜索获取所有资源列表
/// </summary>
string FindAssetType { get; }
/// <summary>
/// 验证搜寻的资源是否为收集资源
/// </summary>
/// <returns>如果收集该资源返回TRUE</returns>
bool IsCollectAsset(FilterRuleData data);

View File

@@ -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";

View File

@@ -81,6 +81,7 @@ namespace YooAsset.Editor
public ECompressOption CompressOption;
public bool DisableWriteTypeTree;
public bool IgnoreTypeTreeChanges;
public bool ReplaceAssetPathWithAddress;
public bool WriteLinkXML = true;
public string CacheServerHost;
public int CacheServerPort;

View File

@@ -74,6 +74,7 @@ namespace YooAsset.Editor
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
BindListViewItem("ReplaceAssetPathWithAddress", $"{buildReport.Summary.ReplaceAssetPathWithAddress}");
BindListViewItem(string.Empty, string.Empty);
BindListViewHeader("Build Results");

View File

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

View File

@@ -169,6 +169,28 @@ namespace YooAsset.Editor
/// <param name="searchInFolders">指定搜索的文件夹列表</param>
/// <returns>返回搜集到的资源路径列表</returns>
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()不支持末尾带分隔符的文件夹路径
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
/// <param name="searchType">搜集的资源类型</param>
/// <param name="searchInFolder">指定搜索的文件夹</param>
/// <returns>返回搜集到的资源路径列表</returns>
public static string[] FindAssets(EAssetSearchType searchType, string searchInFolder)
public static string[] FindAssets(string searchType, 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

@@ -63,14 +63,19 @@ namespace YooAsset
{
"link.xml",
"buildlogtep.json",
$"{packageName}.version",
$"{packageName}_{packageVersion}.bytes",
$"{packageName}_{packageVersion}.hash",
$"{packageName}_{packageVersion}.json",
$"{packageName}_{packageVersion}.report",
DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName,
DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName
};
string packageVersionFileName = YooAssetSettingsData.GetPackageVersionFileName(packageName);
string packageHashFileName = YooAssetSettingsData.GetPackageHashFileName(packageName, packageVersion);
string manifestBinaryFIleName = YooAssetSettingsData.GetManifestBinaryFileName(packageName, packageVersion);
string manifestJsonFIleName = YooAssetSettingsData.GetManifestJsonFileName(packageName, packageVersion);
string reportFileName = YooAssetSettingsData.GetBuildReportFileName(packageName, packageVersion);
whiteFileList.Add(packageVersionFileName);
whiteFileList.Add(packageHashFileName);
whiteFileList.Add(manifestBinaryFIleName);
whiteFileList.Add(manifestJsonFIleName);
whiteFileList.Add(reportFileName);
// 记录所有内置资源文件
DirectoryInfo rootDirectory = new DirectoryInfo(packageDirectory);

View File

@@ -90,7 +90,7 @@ namespace YooAsset
public string CopyBuildinPackageManifestDestRoot { private set; get; }
/// <summary>
/// 自定义参数:解密方法
/// 自定义参数:解密服务接口的实例
/// </summary>
public IDecryptionServices DecryptionServices { private set; get; }
@@ -100,7 +100,7 @@ namespace YooAsset
public IManifestRestoreServices ManifestServices { private set; get; }
/// <summary>
/// 自定义参数:拷贝内置文件服务
/// 自定义参数:拷贝内置文件接口的实例
/// </summary>
public ICopyLocalFileServices CopyLocalFileServices { private set; get; }
#endregion

View File

@@ -57,7 +57,7 @@ namespace YooAsset
#region
/// <summary>
/// 自定义参数:远程服务接口
/// 自定义参数:远程服务接口的实例类
/// </summary>
public IRemoteServices RemoteServices { private set; get; }
@@ -96,6 +96,11 @@ namespace YooAsset
/// </summary>
public int DownloadMaxRequestPerFrame { private set; get; } = int.MaxValue;
/// <summary>
/// 自定义参数:下载任务的看门狗机制监控时间
/// </summary>
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
/// <summary>
/// 自定义参数:启用断点续传的最小尺寸
/// </summary>
@@ -107,7 +112,7 @@ namespace YooAsset
public List<long> ResumeDownloadResponseCodes { private set; get; } = null;
/// <summary>
/// 自定义参数:解密方法
/// 自定义参数:解密服务接口的实例
/// </summary>
public IDecryptionServices DecryptionServices { private set; get; }
@@ -117,7 +122,7 @@ namespace YooAsset
public IManifestRestoreServices ManifestServices { private set; get; }
/// <summary>
/// 自定义参数:拷贝内置文件服务
/// 自定义参数:拷贝内置文件接口的实例
/// </summary>
public ICopyLocalFileServices CopyLocalFileServices { private set; get; }
#endregion
@@ -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);

View File

@@ -11,6 +11,7 @@ namespace YooAsset
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadAssetBundle,
CheckResult,
Done,
@@ -63,6 +64,17 @@ namespace YooAsset
}
}
if (_steps == ESteps.DownloadFile)
{
// 中断下载
if (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
@@ -94,6 +106,23 @@ namespace YooAsset
}
}
if (_steps == ESteps.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
if (_steps == ESteps.LoadAssetBundle)
{
if (_bundle.Encrypted)
@@ -251,6 +280,7 @@ namespace YooAsset
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadCacheRawBundle,
Done,
}
@@ -310,6 +340,17 @@ namespace YooAsset
}
}
if (_steps == ESteps.DownloadFile)
{
// 中断下载
if (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
if (_steps == ESteps.DownloadFile)
{
if (_downloadFileOp == null)
@@ -341,6 +382,23 @@ namespace YooAsset
}
}
if (_steps == ESteps.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
if (_steps == ESteps.LoadCacheRawBundle)
{
string filePath = _fileSystem.GetCacheBundleFileLoadPath(_bundle);

View File

@@ -16,7 +16,7 @@ namespace YooAsset
}
private readonly DefaultCacheFileSystem _fileSystem;
private IEnumerator<DirectoryInfo> _filesEnumerator = null;
private IEnumerator<string> _filesEnumerator = null;
private float _verifyStartTime;
private ESteps _steps = ESteps.None;
@@ -42,11 +42,11 @@ namespace YooAsset
if (_steps == ESteps.Prepare)
{
DirectoryInfo rootDirectory = new DirectoryInfo(_fileSystem.GetCacheBundleFilesRoot());
if (rootDirectory.Exists)
string rootDirectory = _fileSystem.GetCacheBundleFilesRoot();
if (Directory.Exists(rootDirectory))
{
var directorieInfos = rootDirectory.EnumerateDirectories();
_filesEnumerator = directorieInfos.GetEnumerator();
var directories = Directory.EnumerateDirectories(rootDirectory);
_filesEnumerator = directories.GetEnumerator();
}
_steps = ESteps.SearchFiles;
}
@@ -76,15 +76,15 @@ namespace YooAsset
break;
var rootFoder = _filesEnumerator.Current;
var childDirectories = rootFoder.GetDirectories();
var childDirectories = Directory.EnumerateDirectories(rootFoder);
foreach (var chidDirectory in childDirectories)
{
string bundleGUID = chidDirectory.Name;
string bundleGUID = Path.GetFileName(chidDirectory);
if (_fileSystem.IsRecordBundleFile(bundleGUID))
continue;
// 创建验证元素类
string fileRootPath = chidDirectory.FullName;
string fileRootPath = chidDirectory;
string dataFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleDataFileName}";
string infoFilePath = $"{fileRootPath}/{DefaultCacheFileSystemDefine.BundleInfoFileName}";
@@ -108,17 +108,15 @@ namespace YooAsset
return isFindItem;
}
private string FindDataFileExtension(DirectoryInfo directoryInfo)
private string FindDataFileExtension(string directory)
{
string dataFileExtension = string.Empty;
var fileInfos = directoryInfo.GetFiles();
foreach (var fileInfo in fileInfos)
string searchPattern = DefaultCacheFileSystemDefine.BundleDataFileName + "*";
var dataFiles = Directory.EnumerateFiles(directory, searchPattern);
foreach (var filePath in dataFiles)
{
if (fileInfo.Name.StartsWith(DefaultCacheFileSystemDefine.BundleDataFileName))
{
dataFileExtension = fileInfo.Extension;
break;
}
dataFileExtension = Path.GetExtension(filePath);
break;
}
return dataFileExtension;
}

View File

@@ -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;
/// <summary>
/// 引用计数
/// </summary>
@@ -33,6 +38,47 @@ namespace YooAsset
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>

View File

@@ -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;

View File

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

View File

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

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
namespace YooAsset
{
@@ -7,6 +8,7 @@ namespace YooAsset
/// </summary>
internal class DefaultEditorFileSystem : IFileSystem
{
protected readonly Dictionary<string, string> _records = new Dictionary<string, string>(10000);
protected string _packageRoot;
/// <summary>
@@ -37,15 +39,30 @@ namespace YooAsset
}
#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>
public int _asyncSimulateMinFrame = 1;
public int AsyncSimulateMinFrame { private set; get; } = 1;
/// <summary>
/// 异步模拟加载最大帧数
/// </summary>
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
}

View File

@@ -6,7 +6,9 @@ namespace YooAsset
protected enum ESteps
{
None,
CheckExist,
DownloadFile,
AbortDownload,
LoadAssetBundle,
CheckResult,
Done,
@@ -14,6 +16,7 @@ namespace YooAsset
private readonly DefaultEditorFileSystem _fileSystem;
private readonly PackageBundle _bundle;
protected FSDownloadFileOperation _downloadFileOp;
private int _asyncSimulateFrame;
private ESteps _steps = ESteps.None;
@@ -24,26 +27,102 @@ 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 (AbortDownloadFile)
{
if (_downloadFileOp != null)
_downloadFileOp.AbortOperation();
_steps = ESteps.AbortDownload;
}
}
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.AbortDownload)
{
if (_downloadFileOp != null)
{
if (IsWaitForAsyncComplete)
_downloadFileOp.WaitForAsyncComplete();
_downloadFileOp.UpdateOperation();
if (_downloadFileOp.IsDone == false)
return;
}
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort download file !";
}
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
{

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

@@ -44,12 +44,12 @@ namespace YooAsset
public bool DisableUnityWebCache { private set; get; } = false;
/// <summary>
/// 自定义参数:跨域下载服务接口
/// 自定义参数:远程服务接口的实例类(支持跨域下载)
/// </summary>
public IRemoteServices RemoteServices { private set; get; }
/// <summary>
/// 自定义参数:解密方法
/// 自定义参数:解密服务接口的实例
/// </summary>
public IWebDecryptionServices DecryptionServices { private set; get; }

View File

@@ -58,7 +58,7 @@ namespace YooAsset
public bool DisableUnityWebCache { private set; get; } = false;
/// <summary>
/// 自定义参数:解密方法
/// 自定义参数:解密服务接口的实例
/// </summary>
public IWebDecryptionServices DecryptionServices { private set; get; }

View File

@@ -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";

View File

@@ -17,6 +17,11 @@ namespace YooAsset
/// 下载大小
/// </summary>
public long DownloadedBytes { protected set; get; } = 0;
/// <summary>
/// 终止下载文件
/// </summary>
public bool AbortDownloadFile = false;
}
internal sealed class FSLoadBundleCompleteOperation : FSLoadBundleOperation

View File

@@ -43,6 +43,11 @@ namespace YooAsset
/// </summary>
public int BundleLoadingMaxConcurrency = int.MaxValue;
/// <summary>
/// 当资源引用计数为零的时候自动释放资源包
/// </summary>
public bool AutoUnloadBundleWhenUnused = false;
/// <summary>
/// WebGL平台强制同步加载资源对象
/// </summary>

View File

@@ -36,6 +36,9 @@ namespace YooAsset
{
get
{
if (_watch == null)
return false;
// NOTE : 单次调用开销约1微秒
return _watch.ElapsedMilliseconds - _frameTime >= MaxTimeSlice;
}

View File

@@ -23,6 +23,11 @@ namespace YooAsset
if (IsValidWithWarning == false)
return;
Provider.ReleaseHandle(this);
// 主动卸载零引用的资源包
if (Provider.RefCount == 0)
Provider.TryUnloadBundle();
Provider = null;
}
@@ -146,11 +151,11 @@ namespace YooAsset
/// </summary>
public System.Threading.Tasks.Task Task
{
get
get
{
if (IsValidWithWarning == false)
return null;
return Provider.Task;
return Provider.Task;
}
}

View File

@@ -83,6 +83,7 @@ namespace YooAsset
{
if (_loadBundleOp == null)
{
// 统计计数增加
_resManager.BundleLoadingCounter++;
_loadBundleOp = LoadBundleInfo.LoadBundleFile();
_loadBundleOp.StartOperation();
@@ -163,14 +164,22 @@ 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();
if (IsDone == false)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Bundle loader destroyed !";
}
}
/// <summary>
@@ -178,10 +187,7 @@ namespace YooAsset
/// </summary>
public bool CanDestroyLoader()
{
if (IsDone == false)
return false;
if (RefCount > 0)
if (CanReleasableLoader() == false)
return false;
// YOOASSET_LEGACY_DEPENDENCY
@@ -191,14 +197,34 @@ namespace YooAsset
{
foreach (var bundleID in LoadBundleInfo.Bundle.ReferenceBundleIDs)
{
#if YOOASSET_EXPERIMENTAL
if (_resManager.CheckBundleReleasable(bundleID) == false)
return false;
#else
if (_resManager.CheckBundleDestroyed(bundleID) == false)
return false;
#endif
}
}
return true;
}
/// <summary>
/// 是否可以释放
/// </summary>
public bool CanReleasableLoader()
{
// 注意:正在加载中的任务不可以销毁
if (_steps == ESteps.LoadBundleFile)
return false;
if (RefCount > 0)
return false;
return true;
}
/// <summary>
/// 添加附属的资源提供者
/// </summary>
@@ -237,5 +263,28 @@ namespace YooAsset
_removeList.Clear();
}
}
/// <summary>
/// 尝试终止加载器
/// </summary>
public void TryAbortLoader()
{
if (IsDone == false)
{
if (_steps == ESteps.CheckConcurrency)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Abort bundle loader !";
}
if (_steps == ESteps.LoadBundleFile)
{
// 注意:终止下载器
if (_loadBundleOp != null)
_loadBundleOp.AbortDownloadFile = true;
}
}
}
}
}

View File

@@ -23,7 +23,7 @@ namespace YooAsset
None,
CheckOptions,
ReleaseAll,
AbortDownload,
TryAbortLoader,
CheckLoading,
DestroyAll,
Done,
@@ -78,15 +78,16 @@ namespace YooAsset
}
}
_steps = ESteps.AbortDownload;
_steps = ESteps.TryAbortLoader;
}
if (_steps == ESteps.AbortDownload)
if (_steps == ESteps.TryAbortLoader)
{
// 注意:终止所有载任务
// 尝试终止所有载任务
// 注意正在加载AssetBundle的任务无法终止
foreach (var loader in _resManager.LoaderDic.Values)
{
loader.AbortOperation();
loader.TryAbortLoader();
}
_steps = ESteps.CheckLoading;
}

View File

@@ -67,6 +67,16 @@ namespace YooAsset
/// </summary>
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;
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
/// </summary>
public bool CanDestroyProvider()
{
// 注意:在进行资源加载过程时不可以销毁
if (_steps == ESteps.ProcessBundleResult)
// 注意:正在加载中的任务不可以销毁
if (IsLoading)
return false;
if (_resManager.UseWeakReferenceHandle)
@@ -290,6 +308,17 @@ namespace YooAsset
}
}
/// <summary>
/// 尝试卸载资源包
/// </summary>
public void TryUnloadBundle()
{
if (_resManager.AutoUnloadBundleWhenUnused)
{
_resManager.TryUnloadUnusedAsset(MainAssetInfo, 10);
}
}
/// <summary>
/// 结束流程
/// </summary>

View File

@@ -17,6 +17,7 @@ namespace YooAsset
private int _bundleLoadingMaxConcurrency;
// 开发者配置选项
public bool AutoUnloadBundleWhenUnused { private set; get; }
public bool WebGLForceSyncLoadAsset { private set; get; }
public bool UseWeakReferenceHandle { private set; get; }
@@ -47,6 +48,7 @@ namespace YooAsset
public void Initialize(InitializeParameters parameters, IBundleQuery bundleServices)
{
_bundleLoadingMaxConcurrency = parameters.BundleLoadingMaxConcurrency;
AutoUnloadBundleWhenUnused = parameters.AutoUnloadBundleWhenUnused;
WebGLForceSyncLoadAsset = parameters.WebGLForceSyncLoadAsset;
UseWeakReferenceHandle = parameters.UseWeakReferenceHandle;
_bundleQuery = bundleServices;
@@ -327,6 +329,14 @@ namespace YooAsset
return true;
return bundleFileLoader.IsDestroyed;
}
internal bool CheckBundleReleasable(int bundleID)
{
string bundleName = _bundleQuery.GetMainBundleName(bundleID);
var bundleFileLoader = TryGetBundleFileLoader(bundleName);
if (bundleFileLoader == null)
return true;
return bundleFileLoader.CanReleasableLoader();
}
internal bool HasAnyLoader()
{
return LoaderDic.Count > 0;

View File

@@ -16,6 +16,13 @@ namespace YooAsset
/// <summary>
/// 文件格式版本
/// </summary>
public const string FileVersion = "2025.8.28";
public const string FileVersion = "2025.9.30";
public const string VERSION_2025_8_28 = "2025.8.28";
public const string VERSION_2025_9_30 = "2025.9.30";
/// <summary>
/// 版本兼容
/// </summary>
public const bool BackwardCompatible = true;
}
}

View File

@@ -62,6 +62,7 @@ namespace YooAsset
buffer.WriteBool(manifest.SupportExtensionless);
buffer.WriteBool(manifest.LocationToLower);
buffer.WriteBool(manifest.IncludeAssetGUID);
buffer.WriteBool(manifest.ReplaceAssetPathWithAddress);
buffer.WriteInt32(manifest.OutputNameStyle);
buffer.WriteInt32(manifest.BuildBundleType);
buffer.WriteUTF8(manifest.BuildPipeline);
@@ -119,7 +120,18 @@ namespace YooAsset
/// </summary>
public static PackageManifest DeserializeFromJson(string jsonContent)
{
return JsonUtility.FromJson<PackageManifest>(jsonContent);
var manifest = JsonUtility.FromJson<PackageManifest>(jsonContent);
// 初始化资源包
for (int i = 0; i < manifest.BundleList.Count; i++)
{
var packageBundle = manifest.BundleList[i];
packageBundle.InitBundle(manifest);
}
// 初始化资源清单
manifest.Initialize();
return manifest;
}
/// <summary>
@@ -127,218 +139,12 @@ namespace YooAsset
/// </summary>
public static PackageManifest DeserializeFromBinary(byte[] binaryData, IManifestRestoreServices services)
{
// 创建缓存器
BufferReader buffer;
if (services != null)
{
var resultBytes = services.RestoreManifest(binaryData);
buffer = new BufferReader(resultBytes);
}
else
{
buffer = new BufferReader(binaryData);
}
// 读取文件标记
uint fileSign = buffer.ReadUInt32();
if (fileSign != ManifestDefine.FileSign)
throw new Exception("Invalid manifest file !");
// 读取文件版本
string fileVersion = buffer.ReadUTF8();
if (fileVersion != ManifestDefine.FileVersion)
throw new Exception($"The manifest file version are not compatible : {fileVersion} != {ManifestDefine.FileVersion}");
PackageManifest manifest = new PackageManifest();
{
// 读取文件头信息
manifest.FileVersion = fileVersion;
manifest.EnableAddressable = buffer.ReadBool();
manifest.SupportExtensionless = buffer.ReadBool();
manifest.LocationToLower = buffer.ReadBool();
manifest.IncludeAssetGUID = buffer.ReadBool();
manifest.OutputNameStyle = buffer.ReadInt32();
manifest.BuildBundleType = buffer.ReadInt32();
manifest.BuildPipeline = buffer.ReadUTF8();
manifest.PackageName = buffer.ReadUTF8();
manifest.PackageVersion = buffer.ReadUTF8();
manifest.PackageNote = buffer.ReadUTF8();
// 检测配置
if (manifest.EnableAddressable && manifest.LocationToLower)
throw new Exception("Addressable not support location to lower !");
// 读取资源列表
int packageAssetCount = buffer.ReadInt32();
CreateAssetCollection(manifest, packageAssetCount);
for (int i = 0; i < packageAssetCount; i++)
{
var packageAsset = new PackageAsset();
packageAsset.Address = buffer.ReadUTF8();
packageAsset.AssetPath = buffer.ReadUTF8();
packageAsset.AssetGUID = buffer.ReadUTF8();
packageAsset.AssetTags = buffer.ReadUTF8Array();
packageAsset.BundleID = buffer.ReadInt32();
packageAsset.DependBundleIDs = buffer.ReadInt32Array();
FillAssetCollection(manifest, packageAsset);
}
// 读取资源包列表
int packageBundleCount = buffer.ReadInt32();
CreateBundleCollection(manifest, packageBundleCount);
for (int i = 0; i < packageBundleCount; i++)
{
var packageBundle = new PackageBundle();
packageBundle.BundleName = buffer.ReadUTF8();
packageBundle.UnityCRC = buffer.ReadUInt32();
packageBundle.FileHash = buffer.ReadUTF8();
packageBundle.FileCRC = buffer.ReadUInt32();
packageBundle.FileSize = buffer.ReadInt64();
packageBundle.Encrypted = buffer.ReadBool();
packageBundle.Tags = buffer.ReadUTF8Array();
packageBundle.DependBundleIDs = buffer.ReadInt32Array();
FillBundleCollection(manifest, packageBundle);
}
}
// 初始化资源清单
InitManifest(manifest);
return manifest;
DeserializeManifestOperation operation = new DeserializeManifestOperation(services, binaryData);
operation.StartOperation();
operation.WaitForAsyncComplete();
return operation.Manifest;
}
#region
public static void InitManifest(PackageManifest manifest)
{
// 填充资源包内包含的主资源列表
foreach (var packageAsset in manifest.AssetList)
{
int bundleID = packageAsset.BundleID;
if (bundleID >= 0 && bundleID < manifest.BundleList.Count)
{
var packageBundle = manifest.BundleList[bundleID];
packageBundle.IncludeMainAssets.Add(packageAsset);
}
else
{
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {packageAsset.AssetPath}");
}
}
// 填充资源包引用关系
for (int index = 0; index < manifest.BundleList.Count; index++)
{
var sourceBundle = manifest.BundleList[index];
foreach (int dependIndex in sourceBundle.DependBundleIDs)
{
var dependBundle = manifest.BundleList[dependIndex];
dependBundle.AddReferenceBundleID(index);
}
}
}
public static void CreateAssetCollection(PackageManifest manifest, int assetCount)
{
manifest.AssetList = new List<PackageAsset>(assetCount);
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
if (manifest.EnableAddressable)
{
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
}
else
{
if (manifest.LocationToLower)
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2, StringComparer.OrdinalIgnoreCase);
else
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
}
if (manifest.IncludeAssetGUID)
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
else
manifest.AssetPathMapping2 = new Dictionary<string, string>();
}
public static void FillAssetCollection(PackageManifest manifest, PackageAsset packageAsset)
{
// 添加到列表集合
manifest.AssetList.Add(packageAsset);
// 注意:我们不允许原始路径存在重名
string assetPath = packageAsset.AssetPath;
if (manifest.AssetDic.ContainsKey(assetPath))
throw new System.Exception($"AssetPath have existed : {assetPath}");
else
manifest.AssetDic.Add(assetPath, packageAsset);
// 填充AssetPathMapping1
{
string location = packageAsset.AssetPath;
// 添加原生路径的映射
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
// 添加无后缀名路径的映射
if (manifest.SupportExtensionless)
{
string locationWithoutExtension = Path.ChangeExtension(location, null);
if (ReferenceEquals(location, locationWithoutExtension) == false)
{
if (manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
YooLogger.Warning($"Location have existed : {locationWithoutExtension}");
else
manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
}
}
}
// 添加可寻址地址
if (manifest.EnableAddressable)
{
string location = packageAsset.Address;
if (string.IsNullOrEmpty(location) == false)
{
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
}
}
// 填充AssetPathMapping2
if (manifest.IncludeAssetGUID)
{
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
else
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
}
}
public static void CreateBundleCollection(PackageManifest manifest, int bundleCount)
{
manifest.BundleList = new List<PackageBundle>(bundleCount);
manifest.BundleDic1 = new Dictionary<string, PackageBundle>(bundleCount);
manifest.BundleDic2 = new Dictionary<string, PackageBundle>(bundleCount);
manifest.BundleDic3 = new Dictionary<string, PackageBundle>(bundleCount);
}
public static void FillBundleCollection(PackageManifest manifest, PackageBundle packageBundle)
{
// 初始化资源包
packageBundle.InitBundle(manifest);
// 添加到列表集合
manifest.BundleList.Add(packageBundle);
manifest.BundleDic1.Add(packageBundle.BundleName, packageBundle);
manifest.BundleDic2.Add(packageBundle.FileName, packageBundle);
manifest.BundleDic3.Add(packageBundle.BundleGUID, packageBundle);
}
#endregion
/// <summary>
/// 获取资源文件的后缀名
/// </summary>

View File

@@ -13,13 +13,15 @@ namespace YooAsset
}
private readonly ResourcePackage _resourcePackage;
private readonly UnloadAllAssetsOptions _options;
private UnloadAllAssetsOperation _unloadAllAssetsOp;
private ESteps _steps = ESteps.None;
public DestroyOperation(ResourcePackage resourcePackage)
public DestroyOperation(ResourcePackage resourcePackage, UnloadAllAssetsOptions options)
{
_resourcePackage = resourcePackage;
_options = options;
}
internal override void InternalStart()
@@ -64,7 +66,7 @@ namespace YooAsset
{
if (_unloadAllAssetsOp == null)
{
_unloadAllAssetsOp = _resourcePackage.UnloadAllAssetsAsync();
_unloadAllAssetsOp = _resourcePackage.UnloadAllAssetsAsync(_options);
_unloadAllAssetsOp.StartOperation();
AddChildOperation(_unloadAllAssetsOp);
}

View File

@@ -84,7 +84,10 @@ namespace YooAsset
// 读取文件版本
string fileVersion = _buffer.ReadUTF8();
if (fileVersion != ManifestDefine.FileVersion)
Version fileVer = new Version(fileVersion);
Version ver2025_8_28 = new Version(ManifestDefine.VERSION_2025_8_28);
Version ver2025_9_30 = new Version(ManifestDefine.VERSION_2025_9_30);
if (fileVer < ver2025_8_28)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
@@ -99,6 +102,10 @@ namespace YooAsset
Manifest.SupportExtensionless = _buffer.ReadBool();
Manifest.LocationToLower = _buffer.ReadBool();
Manifest.IncludeAssetGUID = _buffer.ReadBool();
if (fileVer >= ver2025_9_30)
Manifest.ReplaceAssetPathWithAddress = _buffer.ReadBool();
else
Manifest.ReplaceAssetPathWithAddress = false;
Manifest.OutputNameStyle = _buffer.ReadInt32();
Manifest.BuildBundleType = _buffer.ReadInt32();
Manifest.BuildPipeline = _buffer.ReadUTF8();
@@ -109,6 +116,8 @@ namespace YooAsset
// 检测配置
if (Manifest.EnableAddressable && Manifest.LocationToLower)
throw new System.Exception("Addressable not support location to lower !");
if (Manifest.EnableAddressable == false && Manifest.ReplaceAssetPathWithAddress)
throw new System.Exception("Replace asset path with address need enable Addressable !");
_steps = ESteps.PrepareAssetList;
}
@@ -117,26 +126,44 @@ namespace YooAsset
{
_packageAssetCount = _buffer.ReadInt32();
_progressTotalValue = _packageAssetCount;
ManifestTools.CreateAssetCollection(Manifest, _packageAssetCount);
CreateAssetCollection(Manifest, _packageAssetCount);
_steps = ESteps.DeserializeAssetList;
}
if (_steps == ESteps.DeserializeAssetList)
{
bool replaceAssetPath = false;
if (UnityEngine.Application.isPlaying)
{
if (Manifest.EnableAddressable && Manifest.ReplaceAssetPathWithAddress)
replaceAssetPath = true;
}
while (_packageAssetCount > 0)
{
var packageAsset = new PackageAsset();
packageAsset.Address = _buffer.ReadUTF8();
packageAsset.AssetPath = _buffer.ReadUTF8();
if (replaceAssetPath)
{
packageAsset.AssetPath = packageAsset.Address;
_buffer.SkipUTF8(); //跳过解析AssetPath
}
else
{
packageAsset.AssetPath = _buffer.ReadUTF8();
}
packageAsset.AssetGUID = _buffer.ReadUTF8();
packageAsset.AssetTags = _buffer.ReadUTF8Array();
packageAsset.BundleID = _buffer.ReadInt32();
packageAsset.DependBundleIDs = _buffer.ReadInt32Array();
ManifestTools.FillAssetCollection(Manifest, packageAsset);
FillAssetCollection(Manifest, packageAsset, replaceAssetPath);
_packageAssetCount--;
Progress = 1f - _packageAssetCount / _progressTotalValue;
if (OperationSystem.IsBusy)
break;
if (IsWaitForAsyncComplete == false)
{
if (OperationSystem.IsBusy)
break;
}
}
if (_packageAssetCount <= 0)
@@ -149,7 +176,7 @@ namespace YooAsset
{
_packageBundleCount = _buffer.ReadInt32();
_progressTotalValue = _packageBundleCount;
ManifestTools.CreateBundleCollection(Manifest, _packageBundleCount);
CreateBundleCollection(Manifest, _packageBundleCount);
_steps = ESteps.DeserializeBundleList;
}
if (_steps == ESteps.DeserializeBundleList)
@@ -165,12 +192,15 @@ namespace YooAsset
packageBundle.Encrypted = _buffer.ReadBool();
packageBundle.Tags = _buffer.ReadUTF8Array();
packageBundle.DependBundleIDs = _buffer.ReadInt32Array();
ManifestTools.FillBundleCollection(Manifest, packageBundle);
FillBundleCollection(Manifest, packageBundle);
_packageBundleCount--;
Progress = 1f - _packageBundleCount / _progressTotalValue;
if (OperationSystem.IsBusy)
break;
if (IsWaitForAsyncComplete == false)
{
if (OperationSystem.IsBusy)
break;
}
}
if (_packageBundleCount <= 0)
@@ -181,7 +211,7 @@ namespace YooAsset
if (_steps == ESteps.InitManifest)
{
ManifestTools.InitManifest(Manifest);
Manifest.Initialize();
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
@@ -194,5 +224,117 @@ namespace YooAsset
Error = e.Message;
}
}
internal override void InternalWaitForAsyncComplete()
{
while (true)
{
if (ExecuteWhileDone())
{
_steps = ESteps.Done;
break;
}
}
}
private void CreateAssetCollection(PackageManifest manifest, int assetCount)
{
manifest.AssetList = new List<PackageAsset>(assetCount);
manifest.AssetDic = new Dictionary<string, PackageAsset>(assetCount);
if (manifest.EnableAddressable)
{
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 3);
}
else
{
if (manifest.LocationToLower)
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2, StringComparer.OrdinalIgnoreCase);
else
manifest.AssetPathMapping1 = new Dictionary<string, string>(assetCount * 2);
}
if (manifest.IncludeAssetGUID)
manifest.AssetPathMapping2 = new Dictionary<string, string>(assetCount);
else
manifest.AssetPathMapping2 = new Dictionary<string, string>();
}
private void FillAssetCollection(PackageManifest manifest, PackageAsset packageAsset, bool replaceAssetPath)
{
// 添加到列表集合
manifest.AssetList.Add(packageAsset);
// 注意:我们不允许原始路径存在重名
string assetPath = packageAsset.AssetPath;
if (manifest.AssetDic.ContainsKey(assetPath))
throw new System.Exception($"AssetPath have existed : {assetPath}");
else
manifest.AssetDic.Add(assetPath, packageAsset);
// 填充AssetPathMapping1
{
string location = packageAsset.AssetPath;
// 添加原生路径的映射
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
// 添加无后缀名路径的映射
if (manifest.SupportExtensionless)
{
string locationWithoutExtension = Path.ChangeExtension(location, null);
if (ReferenceEquals(location, locationWithoutExtension) == false)
{
if (manifest.AssetPathMapping1.ContainsKey(locationWithoutExtension))
YooLogger.Warning($"Location have existed : {locationWithoutExtension}");
else
manifest.AssetPathMapping1.Add(locationWithoutExtension, packageAsset.AssetPath);
}
}
}
// 填充AssetPathMapping2
if (manifest.IncludeAssetGUID)
{
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
else
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
}
// 添加可寻址地址
if (manifest.EnableAddressable && replaceAssetPath == false)
{
string location = packageAsset.Address;
if (string.IsNullOrEmpty(location) == false)
{
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
}
}
}
private void CreateBundleCollection(PackageManifest manifest, int bundleCount)
{
manifest.BundleList = new List<PackageBundle>(bundleCount);
manifest.BundleDic1 = new Dictionary<string, PackageBundle>(bundleCount);
manifest.BundleDic2 = new Dictionary<string, PackageBundle>(bundleCount);
manifest.BundleDic3 = new Dictionary<string, PackageBundle>(bundleCount);
}
private void FillBundleCollection(PackageManifest manifest, PackageBundle packageBundle)
{
// 初始化资源包
packageBundle.InitBundle(manifest);
// 添加到列表集合
manifest.BundleList.Add(packageBundle);
manifest.BundleDic1.Add(packageBundle.BundleName, packageBundle);
manifest.BundleDic2.Add(packageBundle.FileName, packageBundle);
manifest.BundleDic3.Add(packageBundle.BundleGUID, packageBundle);
}
}
}

View File

@@ -101,8 +101,7 @@ namespace YooAsset
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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
/// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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
/// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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
/// <param name="location">资源定位地址</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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
/// <param name="locations">资源定位地址列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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)
{

View File

@@ -28,6 +28,11 @@ namespace YooAsset
/// </summary>
public bool IncludeAssetGUID;
/// <summary>
/// 使用可寻址地址代替资源路径
/// </summary>
public bool ReplaceAssetPathWithAddress;
/// <summary>
/// 文件名称样式
/// </summary>

View File

@@ -36,6 +36,11 @@ namespace YooAsset
/// </summary>
public bool IncludeAssetGUID;
/// <summary>
/// 使用可寻址地址代替资源路径
/// </summary>
public bool ReplaceAssetPathWithAddress;
/// <summary>
/// 文件名称样式
/// </summary>
@@ -113,6 +118,38 @@ namespace YooAsset
public Dictionary<string, PackageBundle> BundleDic3;
/// <summary>
/// 初始化资源清单
/// </summary>
public void Initialize()
{
// 填充资源包内包含的主资源列表
foreach (var packageAsset in AssetList)
{
int bundleID = packageAsset.BundleID;
if (bundleID >= 0 && bundleID < BundleList.Count)
{
var packageBundle = BundleList[bundleID];
packageBundle.IncludeMainAssets.Add(packageAsset);
}
else
{
throw new Exception($"Invalid bundle id : {bundleID} Asset path : {packageAsset.AssetPath}");
}
}
// 填充资源包引用关系
for (int index = 0; index < BundleList.Count; index++)
{
var sourceBundle = BundleList[index];
foreach (int dependIndex in sourceBundle.DependBundleIDs)
{
var dependBundle = BundleList[dependIndex];
dependBundle.AddReferenceBundleID(index);
}
}
}
/// <summary>
/// 获取包裹的详细信息
/// </summary>
@@ -124,6 +161,7 @@ namespace YooAsset
details.SupportExtensionless = SupportExtensionless;
details.LocationToLower = LocationToLower;
details.IncludeAssetGUID = IncludeAssetGUID;
details.ReplaceAssetPathWithAddress = ReplaceAssetPathWithAddress;
details.OutputNameStyle = OutputNameStyle;
details.BuildBundleType = BuildBundleType;
details.BuildPipeline = BuildPipeline;

View File

@@ -209,7 +209,10 @@ namespace YooAsset
/// </summary>
public DestroyOperation DestroyAsync()
{
var operation = new DestroyOperation(this);
var options = new UnloadAllAssetsOptions();
options.ReleaseAllHandles = true;
options.LockLoadOperation = true;
var operation = new DestroyOperation(this, options);
OperationSystem.StartOperation(null, operation);
return operation;
}
@@ -966,8 +969,7 @@ namespace YooAsset
/// </summary>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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 +981,7 @@ namespace YooAsset
/// <param name="tag">资源标签</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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 +993,7 @@ namespace YooAsset
/// <param name="tags">资源标签列表</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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 +1006,14 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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 +1025,7 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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<AssetInfo> assetInfos = new List<AssetInfo>(locations.Length);
@@ -1038,7 +1036,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 +1048,13 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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 +1066,12 @@ namespace YooAsset
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包</param>
/// <param name="downloadingMaxNumber">同时下载的最大文件数</param>
/// <param name="failedTryAgain">下载失败的重试次数</param>
/// <param name="timeout">超时时间</param>
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);
}

View File

@@ -120,6 +120,15 @@ namespace YooAsset
return (ulong)ReadInt64();
}
public void SkipUTF8()
{
ushort count = ReadUInt16();
if (count == 0)
return;
CheckReaderIndex(count);
_index += count;
}
public string ReadUTF8()
{
ushort count = ReadUInt16();

View File

@@ -76,13 +76,7 @@ namespace YooAsset
/// <summary>
/// Gets the computed hash value.
/// </summary>
public uint CRCValue
{
get
{
return _currentCrc;
}
}
public uint CRCValue { private set; get; }
/// <summary>
/// Initializes a new instance of the <see cref="CRC32Algorithm"/> class.
@@ -115,6 +109,8 @@ namespace YooAsset
/// </summary>
protected override byte[] HashFinal()
{
CRCValue = _currentCrc;
if (BitConverter.IsLittleEndian)
return new[] { (byte)_currentCrc, (byte)(_currentCrc >> 8), (byte)(_currentCrc >> 16), (byte)(_currentCrc >> 24) };
else

View File

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

View File

@@ -1,6 +1,6 @@
using System.Collections.Generic;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor
{
public class MacroDefine

View File

@@ -5,7 +5,7 @@ using System.Text;
using System.Xml;
using UnityEditor;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor
{
[InitializeOnLoad]

View File

@@ -6,7 +6,7 @@ using System.Xml;
using UnityEditor;
using UnityEngine;
#if YOO_ASSET_EXPERIMENT
#if YOO_MACRO_SUPPORT
namespace YooAsset.Editor.Experiment
{
[InitializeOnLoad]

View File

@@ -106,6 +106,9 @@ public static class ShaderVariantCollector
if (_steps == ESteps.CollectSleeping)
{
if (ShaderUtil.anythingCompiling)
return;
if (_elapsedTime.ElapsedMilliseconds > SleepMilliseconds)
{
DestroyAllSpheres();

View File

@@ -8,10 +8,20 @@ using TapTapMiniGame;
public static class TaptapFileSystemCreater
{
public static FileSystemParameters CreateFileSystemParameters(string packageRoot)
public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteServices remoteServices)
{
string fileSystemClass = $"{nameof(TaptapFileSystem)},YooAsset.MiniGame";
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
return fileSystemParams;
}
public static FileSystemParameters CreateFileSystemParameters(string packageRoot, IRemoteServices remoteServices, IWebDecryptionServices decryptionServices)
{
string fileSystemClass = $"{nameof(TaptapFileSystem)},YooAsset.MiniGame";
var fileSystemParams = new FileSystemParameters(fileSystemClass, packageRoot);
fileSystemParams.AddParameter(FileSystemParametersDefine.REMOTE_SERVICES, remoteServices);
fileSystemParams.AddParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, decryptionServices);
return fileSystemParams;
}
}

View File

@@ -6,7 +6,6 @@
"GUID:5efd170ecd8084500bed5692932fe14e",
"GUID:bb21d6197862c4c3e863390dec9859a7",
"GUID:870f26a2ffa82429195df0861505c5d5",
"GUID:870f26a2ffa82429195df0861505c5d5",
"GUID:6921e41464907054da1a045ea64ca16f"
],
"includePlatforms": [],

View File

@@ -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

View File

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