Compare commits

..

27 Commits

Author SHA1 Message Date
何冠峰
5df594f7dc Update CHANGELOG.md 2026-06-02 16:30:21 +08:00
何冠峰
5151bb555f Update package.json 2026-06-02 16:29:36 +08:00
何冠峰
c331dc9b58 perf: guard manifest duplicate-key checks behind UNITY_EDITOR || DEBUG 2026-06-02 16:21:25 +08:00
何冠峰
9d5f1b3aa4 fix: verify cache file against manifest FileCRC/FileSize instead of self-recorded .info values 2026-06-02 16:09:20 +08:00
何冠峰
93a9167100 fix #712
在禁用边玩边下的时候,加载原生文件流程未处理的问题。
2026-06-02 15:53:31 +08:00
何冠峰
54d1593dd2 fix #702
修复解压行为在包体内文件被篡改后,会无限尝试的问题。
2026-06-02 14:37:11 +08:00
何冠峰
a5f4b555e7 fix: resolve UnloadAllAssetsOperation deadlock when releasing zero-ref pending providers 2026-06-02 14:21:18 +08:00
何冠峰
20ae423bbe fix #734 2026-06-02 10:53:35 +08:00
何冠峰
d712a00458 Update .gitignore 2026-05-09 17:06:55 +08:00
何冠峰
c14244b2cf Update copyright year for TuYoo Games 2026-04-21 10:15:21 +08:00
何冠峰
4b6a8ca406 Update CHANGELOG.md 2025-12-04 18:30:51 +08:00
何冠峰
c8e45a6cae Update package.json 2025-12-04 18:30:46 +08:00
何冠峰
1fbc9d26a6 style : 修改注释说明 2025-12-04 18:16:40 +08:00
何冠峰
abb087b02e fix #700 2025-12-03 10:14:55 +08:00
何冠峰
aeaf03011f Merge pull request #694 from fslse/ClearBundleFilesByLocations
ClearBundleFilesByLocations
2025-11-22 09:39:21 +08:00
DESKTOP-FIVME83\Administrator
78d24ad3a6 清理指定地址的文件
(cherry picked from commit 41a1973be8f11c1629b334238546556f54101c35)
2025-11-21 16:29:21 +08:00
何冠峰
aab2c4625e feat #671 2025-11-13 15:54:08 +08:00
何冠峰
079ef75605 feat #682 2025-11-13 11:51:28 +08:00
何冠峰
75881b55f6 fix #683 2025-11-12 18:41:17 +08:00
何冠峰
2020c7d508 Merge pull request #687 from OpenLBE/dev
Localize UI strings to English in editor windows
2025-11-12 09:58:46 +08:00
lark
088d939346 Localize UI strings to English in editor windows
Replaced Chinese UI strings with English equivalents in various editor windows and dialogs, including AssetArtReporter, AssetArtScanner, and AssetBundleBuilder viewers. This improves accessibility for non-Chinese users and standardizes the language across the editor tools.
2025-11-11 14:43:49 +08:00
何冠峰
fa50e91c9f fix #684 2025-11-07 16:37:26 +08:00
何冠峰
2e7b992a4b Merge branch 'dev' of https://github.com/tuyoogame/YooAsset into dev 2025-11-07 16:23:54 +08:00
何冠峰
29fbbd97ff fix #678 2025-11-07 16:23:51 +08:00
何冠峰
abb150e33f Merge pull request #676 from coffeeofnosugar/dev
修复UniTask的扩展包问题
2025-11-04 15:59:20 +08:00
coffee
78e20f434e 修复UniTask的扩展包问题
Unity版本: 2021.3.45f1
yooasset版本:2.3.17
少了一个下划线
2025-11-01 23:24:03 +08:00
何冠峰
304222b788 Update EditorDefine.cs 2025-10-31 17:03:27 +08:00
49 changed files with 545 additions and 83 deletions

5
.gitignore vendored
View File

@@ -15,7 +15,9 @@
/Bundles/
/ProjectSettings/
/App/
/yoo/
/yoo/
/Assets/Docs
/Assets/Docs.meta
/Assets/StreamingAssets
/Assets/StreamingAssets.meta
/Assets/Samples
@@ -70,6 +72,7 @@ sysinfo.txt
# Builds
*.apk
*.unitypackage
*.zip
# Crashlytics generated file
crashlytics-build.properties

View File

@@ -2,6 +2,71 @@
All notable changes to this package will be documented in this file.
## [2.3.19] - 2026-06-02
### Fixed
- (#734) 修复了强制回收所有资源与自动卸载Bundle冲突。
- (#712) 修复了在禁用边玩边下的时候,加载原生文件流程未处理的问题。
- (#702) 修复了解压行为在包体内文件被篡改后,会无限尝试的问题。
- 修复了释放零引用待处理 Provider 时 UnloadAllAssetsOperation 死锁的问题。
- 修复了缓存文件校验改用清单的 FileCRC/FileSize而非来自 .info 文件的自记录值。
### Improvements
- 优化了资源清单重名键校验仅在 UNITY_EDITOR || DEBUG 下执行。
## [2.3.18] - 2025-12-04
### Fixed
- (#676) 修复了UniTask扩展包的编译报错。
- (#684) 修复了资源配置窗口Group列表数量过多的时候添加和删除按钮会变小的问题。
- (#700) [**严重**] 修复了小游戏扩展库的下载器再失败后重试逻辑不起效的问题。
### Added
- (#683) 新增了内置文件系统类初始化参数UNPACK_FILE_SYSTEM_ROOT
```csharp
class FileSystemParametersDefine
{
// 指定解压文件的根目录
public const string UNPACK_FILE_SYSTEM_ROOT = "UNPACK_FILE_SYSTEM_ROOT";
}
```
- (#682) 原生文件构建管线新增构建参数IncludePathInHash
```csharp
class RawFileBuildParameters : BuildParameters
{
/// <summary>
/// 文件哈希值计算包含路径信息
/// </summary>
public bool IncludePathInHash = false;
}
```
- (#671) 新增扩展工具,可以生成空的包裹内置资源目录文件。
```csharp
public class CreateEmptyCatalogWindow : EditorWindow
```
- (#694) 新增资源清理方式ClearBundleFilesByLocations
```csharp
public enum EFileClearMode
{
/// <summary>
/// 清理指定地址的文件
/// 说明需要指定参数可选string, string[], List<string>
/// </summary>
ClearBundleFilesByLocations,
}
```
## [2.3.17] - 2025-10-30
**非常重要**:修复了#627优化导致的资源清单CRC值为空的问题。
@@ -16,10 +81,6 @@ All notable changes to this package will be documented in this file.
影响范围:所有版本!
### Improvements
- 重构并统一了资源清单的反序列化逻辑。
### Fixed
- (#645) 修复了着色器变种收集工具,在极端情况下变种收集不完整的问题。
@@ -29,6 +90,7 @@ All notable changes to this package will be documented in this file.
### Improvements
- 重构并统一了资源清单的反序列化逻辑。
- (#650) 解决互相依赖的资源包无法卸载的问题。需要开启宏定义YOOASSET_EXPERIMENTAL
- (#655) 优化了初始化的时候缓存文件搜索效率。安卓平台性能提升1倍IOS平台性能提升3倍。

View File

@@ -261,14 +261,14 @@ namespace YooAsset.Editor
catch (System.Exception e)
{
_reportCombiner = null;
_titleLabel.text = "导入报告失败!";
_titleLabel.text = "Failed to import report!";
_descLabel.text = e.Message;
UnityEngine.Debug.LogError(e.StackTrace);
}
}
private void FixAllBtn_clicked()
{
if (EditorUtility.DisplayDialog("提示", "修复全部资源(排除白名单和隐藏元素)", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", "Fix all resources (excluding whitelist and hidden elements)", "Yes", "No"))
{
if (_reportCombiner != null)
_reportCombiner.FixAll();
@@ -276,7 +276,7 @@ namespace YooAsset.Editor
}
private void FixSelectBtn_clicked()
{
if (EditorUtility.DisplayDialog("提示", "修复勾选资源(包含白名单和隐藏元素)", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", "Fix selected resources (including whitelist and hidden elements)", "Yes", "No"))
{
if (_reportCombiner != null)
_reportCombiner.FixSelect();
@@ -302,7 +302,7 @@ namespace YooAsset.Editor
}
private void ExportFilesBtn_clicked()
{
string selectFolderPath = EditorUtility.OpenFolderPanel("导入所有选中资源", EditorTools.GetProjectPath(), string.Empty);
string selectFolderPath = EditorUtility.OpenFolderPanel("Export all selected resources", EditorTools.GetProjectPath(), string.Empty);
if (string.IsNullOrEmpty(selectFolderPath) == false)
{
if (_reportCombiner != null)

View File

@@ -240,7 +240,7 @@ namespace YooAsset.Editor
}
private void ScanAllBtn_clicked()
{
if (EditorUtility.DisplayDialog("提示", $"开始全面扫描!", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", $"Start full scan!", "Yes", "No"))
{
string searchKeyWord = _scannerSearchField.value;
AssetArtScannerSettingData.ScanAll(searchKeyWord);
@@ -248,7 +248,7 @@ namespace YooAsset.Editor
}
else
{
Debug.LogWarning("全面扫描已经取消");
Debug.LogWarning("Full scan has been canceled.");
}
}
private void ScanBtn_clicked()

View File

@@ -44,9 +44,9 @@ namespace YooAsset.Editor
{
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, context);
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, context);
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, context);
}
// 4.更新补丁包输出的文件路径
@@ -62,8 +62,8 @@ namespace YooAsset.Editor
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context);
}
}

View File

@@ -40,17 +40,17 @@ namespace YooAsset.Editor
throw new Exception(message);
}
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
}
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileCRC32Value(filePath);
}
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return FileUtility.GetFileSize(filePath);

View File

@@ -19,16 +19,16 @@ namespace YooAsset.Editor
{
return 0;
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return GetFilePathTempHash(filePath);
}
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
{
return 0;
}
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
{
return GetBundleTempSize(bundleInfo);
}

View File

@@ -15,27 +15,55 @@ namespace YooAsset.Editor
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
if (rawFileBuildParameters.IncludePathInHash)
{
string filePath = bundleInfo.PackageSourceFilePath;
return GetFileMD5IncludePath(filePath);
}
else
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
}
}
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
{
return 0;
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
if (rawFileBuildParameters.IncludePathInHash)
{
string filePath = bundleInfo.PackageSourceFilePath;
return GetFileMD5IncludePath(filePath);
}
else
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
}
}
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileCRC32Value(filePath);
}
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return FileUtility.GetFileSize(filePath);
}
private string GetFileMD5IncludePath(string filePath)
{
string pathHash = HashUtility.StringMD5(filePath.ToLowerInvariant());
string contentHash = HashUtility.FileMD5(filePath);
string combined = pathHash + contentHash;
return HashUtility.StringMD5(combined);
}
}
}

View File

@@ -6,5 +6,9 @@ namespace YooAsset.Editor
{
public class RawFileBuildParameters : BuildParameters
{
/// <summary>
/// 文件哈希值计算包含路径信息
/// </summary>
public bool IncludePathInHash = false;
}
}

View File

@@ -40,17 +40,17 @@ namespace YooAsset.Editor
throw new Exception(message);
}
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileMD5(filePath);
}
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return HashUtility.FileCRC32Value(filePath);
}
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
{
string filePath = bundleInfo.PackageSourceFilePath;
return FileUtility.GetFileSize(filePath);

View File

@@ -82,14 +82,14 @@ namespace YooAsset.Editor
}
private void BuildButton_clicked()
{
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
{
EditorTools.ClearUnityConsole();
EditorApplication.delayCall += ExecuteBuild;
}
else
{
Debug.LogWarning("[Build] 打包已经取消");
Debug.LogWarning("[Build] Packaging has been canceled.");
}
}

View File

@@ -42,14 +42,14 @@ namespace YooAsset.Editor
}
private void BuildButton_clicked()
{
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
{
EditorTools.ClearUnityConsole();
EditorApplication.delayCall += ExecuteBuild;
}
else
{
Debug.LogWarning("[Build] 打包已经取消");
Debug.LogWarning("[Build] Packaging has been canceled.");
}
}

View File

@@ -77,14 +77,14 @@ namespace YooAsset.Editor
}
private void BuildButton_clicked()
{
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
{
EditorTools.ClearUnityConsole();
EditorApplication.delayCall += ExecuteBuild;
}
else
{
Debug.LogWarning("[Build] 打包已经取消");
Debug.LogWarning("[Build] Packaging has been canceled.");
}
}

View File

@@ -82,14 +82,14 @@ namespace YooAsset.Editor
}
private void BuildButton_clicked()
{
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]", "Yes", "No"))
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
{
EditorTools.ClearUnityConsole();
EditorApplication.delayCall += ExecuteBuild;
}
else
{
Debug.LogWarning("[Build] 打包已经取消");
Debug.LogWarning("[Build] Packaging has been canceled.");
}
}

View File

@@ -30,7 +30,7 @@
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center; flex-shrink: 0;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
</ui:VisualElement>
@@ -40,7 +40,7 @@
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center; flex-shrink: 0;">
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
</ui:VisualElement>

View File

@@ -88,8 +88,8 @@ namespace YooAsset.Editor
}
catch (Exception ex)
{
ClearDatabase(true);
Debug.LogError($"Failed to load cache database : {ex.Message}");
ClearDatabase(true);
}
finally
{
@@ -169,7 +169,8 @@ namespace YooAsset.Editor
File.Delete(_databaseFilePath);
}
_database.Clear();
if (_database != null)
_database.Clear();
}
/// <summary>

View File

@@ -41,6 +41,8 @@ namespace YooAsset.Editor
Texture,
RenderTexture,
VideoClip,
PlayableAsset,
TimelineAsset
}
/// <summary>

View File

@@ -118,6 +118,34 @@ namespace YooAsset
Debug.Log($"Succeed to save catalog file : {binaryFilePath}");
return true;
}
/// <summary>
/// 生成空的包裹内置资源目录文件
/// </summary>
public static bool CreateEmptyCatalogFile(string packageName, string packageVersion, string outputPath)
{
// 创建内置清单实例
var buildinFileCatalog = new DefaultBuildinFileCatalog();
buildinFileCatalog.FileVersion = CatalogDefine.FileVersion;
buildinFileCatalog.PackageName = packageName;
buildinFileCatalog.PackageVersion = packageVersion;
// 创建输出文件
string jsonFilePath = $"{outputPath}/{DefaultBuildinFileSystemDefine.BuildinCatalogJsonFileName}";
if (File.Exists(jsonFilePath))
File.Delete(jsonFilePath);
SerializeToJson(jsonFilePath, buildinFileCatalog);
// 创建输出文件
string binaryFilePath = $"{outputPath}/{DefaultBuildinFileSystemDefine.BuildinCatalogBinaryFileName}";
if (File.Exists(binaryFilePath))
File.Delete(binaryFilePath);
SerializeToBinary(binaryFilePath, buildinFileCatalog);
UnityEditor.AssetDatabase.Refresh();
Debug.Log($"Succeed to save catalog file : {binaryFilePath}");
return true;
}
#endif
/// <summary>

View File

@@ -89,6 +89,11 @@ namespace YooAsset
/// </summary>
public string CopyBuildinPackageManifestDestRoot { private set; get; }
/// <summary>
/// 自定义参数:解压文件系统的根目录
/// </summary>
public string UnpackFileSystemRoot { private set; get; }
/// <summary>
/// 自定义参数:解密服务接口的实例类
/// </summary>
@@ -190,6 +195,10 @@ namespace YooAsset
{
CopyBuildinPackageManifestDestRoot = (string)value;
}
else if (name == FileSystemParametersDefine.UNPACK_FILE_SYSTEM_ROOT)
{
UnpackFileSystemRoot = (string)value;
}
else if (name == FileSystemParametersDefine.DECRYPTION_SERVICES)
{
DecryptionServices = (IDecryptionServices)value;
@@ -226,7 +235,7 @@ namespace YooAsset
_unpackFileSystem.SetParameter(FileSystemParametersDefine.APPEND_FILE_EXTENSION, AppendFileExtension);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.DECRYPTION_SERVICES, DecryptionServices);
_unpackFileSystem.SetParameter(FileSystemParametersDefine.COPY_LOCAL_FILE_SERVICES, CopyLocalFileServices);
_unpackFileSystem.OnCreate(packageName, null);
_unpackFileSystem.OnCreate(packageName, UnpackFileSystemRoot);
}
public virtual void OnDestroy()
{

View File

@@ -158,6 +158,11 @@ namespace YooAsset
var operation = new ClearUnusedCacheBundleFilesOperation(this, manifest);
return operation;
}
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByLocations.ToString())
{
var operation = new ClearCacheBundleFilesByLocationsOperaiton(this, manifest, options.ClearParam);
return operation;
}
else if (options.ClearMode == EFileClearMode.ClearBundleFilesByTags.ToString())
{
var operation = new ClearCacheBundleFilesByTagsOperaiton(this, manifest, options.ClearParam);
@@ -464,7 +469,9 @@ namespace YooAsset
if (_records.TryGetValue(bundle.BundleGUID, out RecordFileElement element) == false)
return EFileVerifyResult.CacheNotFound;
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, element.DataFileSize, element.DataFileCRC, EFileVerifyLevel.High);
// 注意:使用清单里的权威校验值(与下载/解压时的校验基准一致),而不是缓存记录里来源于本地 .info 文件的自描述值,
// 否则数据文件与 .info 文件被一并篡改时仍会校验通过。
EFileVerifyResult result = FileVerifyHelper.FileVerify(element.DataFilePath, bundle.FileSize, bundle.FileCRC, EFileVerifyLevel.High);
return result;
}
public bool WriteCacheBundleFile(PackageBundle bundle, string copyPath)

View File

@@ -336,7 +336,17 @@ namespace YooAsset
}
else
{
_steps = ESteps.DownloadFile;
if (_fileSystem.DisableOnDemandDownload)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"The bundle not cached : {_bundle.BundleName}";
YooLogger.Warning(Error);
}
else
{
_steps = ESteps.DownloadFile;
}
}
}

View File

@@ -0,0 +1,142 @@
using System.Collections.Generic;
namespace YooAsset
{
internal class ClearCacheBundleFilesByLocationsOperaiton : FSClearCacheFilesOperation
{
private enum ESteps
{
None,
CheckManifest,
CheckArgs,
GetClearCacheFiles,
ClearFilterCacheFiles,
Done,
}
private readonly DefaultCacheFileSystem _fileSystem;
private readonly PackageManifest _manifest;
private readonly object _clearParam;
private string[] _locations;
private List<string> _clearBundleGUIDs;
private int _clearFileTotalCount = 0;
private ESteps _steps = ESteps.None;
internal ClearCacheBundleFilesByLocationsOperaiton(DefaultCacheFileSystem fileSystem, PackageManifest manifest, object clearParam)
{
_fileSystem = fileSystem;
_manifest = manifest;
_clearParam = clearParam;
}
internal override void InternalStart()
{
_steps = ESteps.CheckManifest;
}
internal override void InternalUpdate()
{
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
if (_steps == ESteps.CheckManifest)
{
if (_manifest == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Can not found active package manifest !";
}
else
{
_steps = ESteps.CheckArgs;
}
}
if (_steps == ESteps.CheckArgs)
{
if (_clearParam == null)
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = "Clear param is null !";
return;
}
if (_clearParam is string)
{
_locations = new string[] { _clearParam as string };
}
else if (_clearParam is List<string>)
{
var tempList = _clearParam as List<string>;
_locations = tempList.ToArray();
}
else if (_clearParam is string[])
{
_locations = _clearParam as string[];
}
else
{
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = $"Invalid clear param : {_clearParam.GetType().FullName}";
return;
}
_steps = ESteps.GetClearCacheFiles;
}
if (_steps == ESteps.GetClearCacheFiles)
{
_clearBundleGUIDs = GetBundleGUIDsByLocation();
_clearFileTotalCount = _clearBundleGUIDs.Count;
_steps = ESteps.ClearFilterCacheFiles;
}
if (_steps == ESteps.ClearFilterCacheFiles)
{
for (int i = _clearBundleGUIDs.Count - 1; i >= 0; i--)
{
string bundleGUID = _clearBundleGUIDs[i];
_fileSystem.DeleteCacheBundleFile(bundleGUID);
_clearBundleGUIDs.RemoveAt(i);
if (OperationSystem.IsBusy)
break;
}
if (_clearFileTotalCount == 0)
Progress = 1.0f;
else
Progress = 1.0f - (_clearBundleGUIDs.Count / _clearFileTotalCount);
if (_clearBundleGUIDs.Count == 0)
{
_steps = ESteps.Done;
Status = EOperationStatus.Succeed;
}
}
}
private List<string> GetBundleGUIDsByLocation()
{
List<string> result = new List<string>(_locations.Length);
foreach (var location in _locations)
{
string assetPath = _manifest.TryMappingToAssetPath(location);
if (_manifest.TryGetPackageAsset(assetPath, out PackageAsset packageAsset))
{
PackageBundle bundle = _manifest.GetMainPackageBundle(packageAsset.BundleID);
if (bundle != null)
{
result.Add(bundle.BundleGUID);
}
}
}
return result;
}
}
}

View File

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

View File

@@ -20,7 +20,7 @@ namespace YooAsset
private UnityDownloadFileOperation _unityDownloadFileOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected float _tryAgainTimer = 0;
protected int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -95,7 +95,8 @@ namespace YooAsset
}
else
{
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0)
// 注意:本地文件(解压/导入)校验失败属于确定性失败,重试只会重复读取同一文件,直接判定失败防止无限重试。
if (IsWaitForAsyncComplete == false && _failedTryAgain > 0 && _unityDownloadFileOp.VerifyFailed == false)
{
_steps = ESteps.TryAgain;
YooLogger.Warning($"Failed download : {_unityDownloadFileOp.URL} Try again !");

View File

@@ -27,6 +27,12 @@ namespace YooAsset
/// </summary>
public int RefCount { private set; get; }
/// <summary>
/// 文件校验是否失败
/// 注意:本地文件(解压/导入)校验失败属于确定性失败,重试无意义,上层不应重试。
/// </summary>
public bool VerifyFailed { protected set; get; } = false;
internal UnityDownloadFileOperation(DefaultCacheFileSystem fileSystem, PackageBundle bundle, string url) : base(url)
{
_fileSystem = fileSystem;

View File

@@ -133,6 +133,8 @@ namespace YooAsset
}
else
{
// 注意:本地内置文件被篡改或损坏时校验会失败,重试只会重复读取同一文件,因此标记为不可重试。
VerifyFailed = true;
_steps = ESteps.Done;
Status = EOperationStatus.Failed;
Error = _verifyOperation.Error;

View File

@@ -20,7 +20,7 @@ namespace YooAsset
protected UnityVirtualBundleRequestOperation _unityDownloadFileOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected float _tryAgainTimer = 0;
protected int _failedTryAgain;
private ESteps _steps = ESteps.None;

View File

@@ -16,6 +16,12 @@ namespace YooAsset
/// </summary>
ClearUnusedBundleFiles,
/// <summary>
/// 清理指定地址的文件
/// 说明需要指定参数可选string, string[], List<string>
/// </summary>
ClearBundleFilesByLocations,
/// <summary>
/// 清理指定标签的文件
/// 说明需要指定参数可选string, string[], List<string>

View File

@@ -26,5 +26,6 @@ namespace YooAsset
public const string COPY_BUILDIN_PACKAGE_MANIFEST = "COPY_BUILDIN_PACKAGE_MANIFEST";
public const string COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT = "COPY_BUILDIN_PACKAGE_MANIFEST_DEST_ROOT";
public const string COPY_LOCAL_FILE_SERVICES = "COPY_LOCAL_FILE_SERVICES";
public const string UNPACK_FILE_SYSTEM_ROOT = "UNPACK_FILE_SYSTEM_ROOT";
}
}

View File

@@ -18,15 +18,16 @@ namespace YooAsset
private readonly IWebDecryptionServices _decryptionServices;
private UnityWebDataRequestOperation _unityWebDataRequestOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected int _failedTryAgain;
private int _requestCount = 0;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
internal LoadWebEncryptAssetBundleOperation(PackageBundle bundle, DownloadFileOptions options, IWebDecryptionServices decryptionServices)
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
_decryptionServices = decryptionServices;
}
internal override void InternalStart()

View File

@@ -18,9 +18,9 @@ namespace YooAsset
private readonly bool _disableUnityWebCache;
private UnityAssetBundleRequestOperation _unityAssetBundleRequestOp;
protected int _requestCount = 0;
protected float _tryAgainTimer;
protected int _failedTryAgain;
private int _requestCount = 0;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -28,6 +28,7 @@ namespace YooAsset
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
_disableUnityWebCache = disableUnityWebCache;
}
internal override void InternalStart()

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
@@ -24,6 +25,7 @@ namespace YooAsset
CheckOptions,
ReleaseAll,
TryAbortLoader,
RequestForceDestroy,
CheckLoading,
DestroyAll,
Done,
@@ -72,7 +74,10 @@ namespace YooAsset
// 释放所有资源句柄
if (_options.ReleaseAllHandles)
{
foreach (var provider in _resManager.ProviderDic.Values)
// 注意创建快照因为释放句柄可能触发自动卸载逻辑AutoUnloadBundleWhenUnused
// 进而修改 ProviderDic 容器,导致遍历时抛出 InvalidOperationException。
var snapshot = new List<ProviderOperation>(_resManager.ProviderDic.Values);
foreach (var provider in snapshot)
{
provider.ReleaseAllHandles();
}
@@ -89,6 +94,17 @@ namespace YooAsset
{
loader.TryAbortLoader();
}
_steps = ESteps.RequestForceDestroy;
}
if (_steps == ESteps.RequestForceDestroy)
{
// 向所有资源提供者下发强制销毁请求
// 注意:防止零引用且尚未进入加载阶段的任务被无限挂起,从而导致 CheckLoading 死锁。
foreach (var provider in _resManager.ProviderDic.Values)
{
provider.RequestForceDestroy();
}
_steps = ESteps.CheckLoading;
}

View File

@@ -67,6 +67,11 @@ namespace YooAsset
/// </summary>
public bool IsDestroyed { private set; get; } = false;
/// <summary>
/// 是否已收到强制销毁请求
/// </summary>
public bool ForceDestroyRequested { private set; get; } = false;
/// <summary>
/// 加载任务是否进行中
/// </summary>
@@ -119,6 +124,18 @@ namespace YooAsset
if (_steps == ESteps.None || _steps == ESteps.Done)
return;
// 注意:收到强制销毁请求时,未在加载中的任务立即结束,防止零引用任务被无限挂起导致卸载流程死锁!
if (ForceDestroyRequested)
{
if (IsLoading == false)
{
InvokeCompletion("Provider force destroyed during unload all assets !", EOperationStatus.Failed);
return;
}
// 注意:已进入加载阶段则继续等待自然完成
}
// 注意:未在加载中的任务可以挂起!
if (IsLoading == false)
{
@@ -199,11 +216,24 @@ namespace YooAsset
}
protected abstract void ProcessBundleResult();
/// <summary>
/// 请求强制销毁
/// 注意:用于卸载流程,标记后未在加载中的任务会在下一次更新时立即结束。
/// </summary>
public void RequestForceDestroy()
{
ForceDestroyRequested = true;
}
/// <summary>
/// 销毁资源提供者
/// 注意:该方法是幂等的,重复调用不会重复释放资源。
/// </summary>
public void DestroyProvider()
{
if (IsDestroyed)
return;
IsDestroyed = true;
// 检测是否为正常销毁

View File

@@ -264,23 +264,27 @@ namespace YooAsset
manifest.AssetList.Add(packageAsset);
// 注意:我们不允许原始路径存在重名
// 说明:清单是构建期生成的可信数据,重名只会因构建错误产生,仅在开发期校验即可,发行版省去一次哈希查找。
string assetPath = packageAsset.AssetPath;
#if UNITY_EDITOR || DEBUG
if (manifest.AssetDic.ContainsKey(assetPath))
throw new System.Exception($"AssetPath have existed : {assetPath}");
else
manifest.AssetDic.Add(assetPath, packageAsset);
#endif
manifest.AssetDic.Add(assetPath, packageAsset);
// 填充AssetPathMapping1
{
string location = packageAsset.AssetPath;
// 添加原生路径的映射
#if UNITY_EDITOR || DEBUG
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
#endif
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
// 添加无后缀名路径的映射
// 注意:无后缀名重名属于合法运行时情况(仅警告并跳过),因此该校验必须在发行版也执行。
if (manifest.SupportExtensionless)
{
string locationWithoutExtension = Path.ChangeExtension(location, null);
@@ -297,10 +301,11 @@ namespace YooAsset
// 填充AssetPathMapping2
if (manifest.IncludeAssetGUID)
{
#if UNITY_EDITOR || DEBUG
if (manifest.AssetPathMapping2.ContainsKey(packageAsset.AssetGUID))
throw new System.Exception($"AssetGUID have existed : {packageAsset.AssetGUID}");
else
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
#endif
manifest.AssetPathMapping2.Add(packageAsset.AssetGUID, packageAsset.AssetPath);
}
// 添加可寻址地址
@@ -309,10 +314,11 @@ namespace YooAsset
string location = packageAsset.Address;
if (string.IsNullOrEmpty(location) == false)
{
#if UNITY_EDITOR || DEBUG
if (manifest.AssetPathMapping1.ContainsKey(location))
throw new System.Exception($"Location have existed : {location}");
else
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
#endif
manifest.AssetPathMapping1.Add(location, packageAsset.AssetPath);
}
}
}

View File

@@ -0,0 +1,62 @@
using System.IO;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;
namespace YooAsset.Editor
{
public class CreateEmptyCatalogWindow : EditorWindow
{
static CreateEmptyCatalogWindow _thisInstance;
[MenuItem("Tools/空清单生成工具Catalog", false, 102)]
static void ShowWindow()
{
if (_thisInstance == null)
{
_thisInstance = EditorWindow.GetWindow(typeof(CreateEmptyCatalogWindow), false, "空清单生成工具", true) as CreateEmptyCatalogWindow;
_thisInstance.minSize = new Vector2(800, 600);
}
_thisInstance.Show();
}
private string _packageName = string.Empty;
private void OnGUI()
{
GUILayout.Space(10);
EditorGUILayout.BeginHorizontal();
_packageName = EditorGUILayout.TextField("Package Name", _packageName);
EditorGUILayout.EndHorizontal();
if (string.IsNullOrEmpty(_packageName) == false)
{
if (GUILayout.Button("生成空的Catalog文件", GUILayout.MaxWidth(150)))
{
string outputPath = EditorTools.OpenFolderPanel("输出目录", "Assets/");
if (string.IsNullOrEmpty(outputPath) == false)
{
CreateEmptyCatalogFile(outputPath);
}
}
}
}
private void CreateEmptyCatalogFile(string outputPath)
{
try
{
bool result = CatalogTools.CreateEmptyCatalogFile(_packageName, string.Empty, outputPath);
if (result == false)
{
Debug.LogError($"Create package {_packageName} catalog file failed ! See the detail error in console !");
}
}
catch (System.Exception ex)
{
Debug.LogError($"Create package {_packageName} catalog file failed ! {ex.Message}");
}
}
}
}

View File

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

View File

@@ -10,7 +10,7 @@ namespace YooAsset.Editor
{
static PackageComparatorWindow _thisInstance;
[MenuItem("Tools/补丁包比对工具", false, 102)]
[MenuItem("Tools/补丁包比对工具", false, 103)]
static void ShowWindow()
{
if (_thisInstance == null)

View File

@@ -8,7 +8,7 @@ namespace YooAsset.Editor
{
static PackageImporterWindow _thisInstance;
[MenuItem("Tools/补丁包导入工具", false, 101)]
[MenuItem("Tools/补丁包导入工具", false, 104)]
static void ShowWindow()
{
if (_thisInstance == null)

View File

@@ -16,8 +16,9 @@ internal class APFSDownloadFileOperation : FSDownloadFileOperation
private readonly AlipayFileSystem _fileSystem;
private readonly DownloadFileOptions _options;
private UnityWebCacheRequestOperation _webCacheRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -25,6 +26,7 @@ internal class APFSDownloadFileOperation : FSDownloadFileOperation
{
_fileSystem = fileSystem;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -20,7 +20,7 @@ namespace YooAsset
private UnityAlipayAssetBundleRequestOperation _unityAssetBundleRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -29,6 +29,7 @@ namespace YooAsset
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -16,8 +16,9 @@ internal class TPFSDownloadFileOperation : FSDownloadFileOperation
private readonly TaptapFileSystem _fileSystem;
private readonly DownloadFileOptions _options;
private UnityWebCacheRequestOperation _webCacheRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -25,6 +26,7 @@ internal class TPFSDownloadFileOperation : FSDownloadFileOperation
{
_fileSystem = fileSystem;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -19,7 +19,7 @@ namespace YooAsset
private UnityTaptapAssetBundleRequestOperation _unityAssetBundleRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -28,6 +28,7 @@ namespace YooAsset
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -16,8 +16,9 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
private readonly TiktokFileSystem _fileSystem;
private readonly DownloadFileOptions _options;
private UnityWebCacheRequestOperation _webCacheRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -25,6 +26,7 @@ internal class TTFSDownloadFileOperation : FSDownloadFileOperation
{
_fileSystem = fileSystem;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -19,7 +19,7 @@ namespace YooAsset
private UnityTiktokAssetBundleRequestOperation _unityAssetBundleRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -28,6 +28,7 @@ namespace YooAsset
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -16,8 +16,9 @@ internal class WXFSDownloadFileOperation : FSDownloadFileOperation
private readonly WechatFileSystem _fileSystem;
private readonly DownloadFileOptions _options;
private UnityWebCacheRequestOperation _webCacheRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -25,6 +26,7 @@ internal class WXFSDownloadFileOperation : FSDownloadFileOperation
{
_fileSystem = fileSystem;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -19,7 +19,7 @@ namespace YooAsset
private UnityWechatAssetBundleRequestOperation _unityAssetBundleRequestOp;
private int _requestCount = 0;
private float _tryAgainTimer;
private float _tryAgainTimer = 0;
private int _failedTryAgain;
private ESteps _steps = ESteps.None;
@@ -28,6 +28,7 @@ namespace YooAsset
{
_bundle = bundle;
_options = options;
_failedTryAgain = options.FailedTryAgain;
}
internal override void InternalStart()
{

View File

@@ -94,19 +94,19 @@ namespace Cysharp.Threading.Tasks
switch (handle)
{
case AssetHandle asset_handle:
asset_handle.Completed += result.continuationAction;
asset_handle.Completed += result._continuationAction;
break;
case SceneHandle scene_handle:
scene_handle.Completed += result.continuationAction;
scene_handle.Completed += result._continuationAction;
break;
case SubAssetsHandle sub_asset_handle:
sub_asset_handle.Completed += result.continuationAction;
sub_asset_handle.Completed += result._continuationAction;
break;
case RawFileHandle raw_file_handle:
raw_file_handle.Completed += result.continuationAction;
raw_file_handle.Completed += result._continuationAction;
break;
case AllAssetsHandle all_assets_handle:
all_assets_handle.Completed += result.continuationAction;
all_assets_handle.Completed += result._continuationAction;
break;
}
#endif

View File

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

View File

@@ -187,7 +187,7 @@
identification within third-party archives.
Copyright 2018-2021 何冠峰
Copyright 2021-2025 TuYoo Games
Copyright 2021-2026 TuYoo Games
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.