Compare commits

...

60 Commits

Author SHA1 Message Date
hevinci
d8a8afba5e Update CHANGELOG.md 2023-12-27 19:54:07 +08:00
hevinci
6e6f425bdd Update package.json 2023-12-27 19:54:05 +08:00
hevinci
9ebe92f832 refactor : asset bundle reporter 2023-12-27 18:24:31 +08:00
hevinci
cbdb84a69f fix #212 2023-12-27 18:20:37 +08:00
hevinci
67b2b886a8 fix #220 2023-12-26 11:40:47 +08:00
hevinci
2838289650 feat : the build report file add independ asset info 2023-12-26 11:30:19 +08:00
hevinci
4b68362fb8 update samples 2023-12-25 14:20:02 +08:00
hevinci
e8e7696a4d refactor : editor code 2023-12-25 14:19:55 +08:00
hevinci
82b2a5cc20 fix #210 2023-12-22 10:24:41 +08:00
hevinci
2332765932 style : Code text indent format 2023-12-21 19:49:50 +08:00
hevinci
552d689317 style : Code text indent format 2023-12-21 19:44:14 +08:00
hevinci
5e2d82d071 style : Code text indent format 2023-12-21 19:40:13 +08:00
hevinci
727f356eea style : Code text indent format 2023-12-21 19:29:26 +08:00
hevinci
544832c46a style : Code text indent format 2023-12-21 19:10:46 +08:00
hevinci
5c1d316d67 feat #203 2023-12-21 17:45:51 +08:00
hevinci
267ec77c37 fix #198
禁用的分组不再检测合法性
2023-12-21 17:33:08 +08:00
hevinci
c2a7106221 fix #202 2023-12-21 16:18:36 +08:00
hevinci
0e29e9823d update query services interface
内置文件和分发文件查询方法参数里增加了文件哈希值
2023-12-21 16:10:54 +08:00
hevinci
47962424eb fix #201
修复断点续传失效的问题
2023-12-21 12:06:06 +08:00
hevinci
505d23ca07 update space shooter sample 2023-12-13 09:56:36 +08:00
hevinci
d4fcb868d8 update resource package
修复下载器合并后重新计算下载字节数不正确的问题。
2023-11-22 11:13:39 +08:00
hevinci
6dd1f43445 fix #205 2023-11-18 17:12:41 +08:00
hevinci
2626cb6750 fix #195 2023-11-01 16:30:58 +08:00
hevinci
81a98ded8a update sapce shooter 2023-11-01 11:03:40 +08:00
hevinci
930f02765d Update package.json
升级SBP依赖版本,解决图集内精灵图片冗余问题
2023-11-01 11:03:16 +08:00
hevinci
a4ffa580b7 update asset bundle builder
remove RemoveSpriteAtlasRedundancy task.
2023-11-01 11:02:46 +08:00
hevinci
506612527d Update CHANGELOG.md 2023-10-27 17:24:35 +08:00
hevinci
74f9f2b0e6 Update package.json 2023-10-27 17:24:17 +08:00
hevinci
4119f02c60 update resource manager 2023-10-27 16:24:33 +08:00
hevinci
bc9a4e07e2 update operation system
异步操作增加执行优先级
2023-10-27 16:08:38 +08:00
hevinci
9418544264 update resource manager
初始化参数增加AutoDestroyAssetProvider
2023-10-26 19:07:51 +08:00
hevinci
460ea091bd fix #185 2023-10-26 17:11:56 +08:00
hevinci
64681db027 update resource manager 2023-10-25 18:45:30 +08:00
hevinci
992957e1e9 Merge branch 'dev' of https://github.com/tuyoogame/YooAsset into dev 2023-10-25 18:28:57 +08:00
hevinci
ce62dbc27f update resource manager
所有异步加载方法增加权重参数。
2023-10-25 18:28:55 +08:00
何冠峰
e2df967aa9 Merge pull request #190 from zy020118/patch-1
Update DownloadManager.cs
2023-10-25 14:13:29 +08:00
hevinci
5b4a188c0b update space shooter 2023-10-24 18:41:58 +08:00
hevinci
e8b5a58a90 update resource manager 2023-10-24 18:38:31 +08:00
swift
c3d5c13a80 Update DownloadManager.cs
WebGL平台改名遗漏 DefaultBuildPipeline->EDefaultBuildPipeline
2023-10-24 14:26:00 +08:00
hevinci
d30a8aefa4 update resource manager
优化ForceUnloadAllAssets方法逻辑
2023-10-19 19:39:14 +08:00
hevinci
194afe435a update resource manager
增加卸载指定资源的方法。
2023-10-19 16:28:30 +08:00
hevinci
82ef993d83 fix #180 2023-10-18 12:14:24 +08:00
hevinci
6d7177a3b5 Update CHANGELOG.md 2023-10-17 19:28:28 +08:00
hevinci
205dd58afd Update package.json 2023-10-17 19:27:39 +08:00
hevinci
d5d5063453 update editor windows 2023-10-17 19:03:11 +08:00
hevinci
f63fcf1227 update editor window localization 2023-10-17 12:03:11 +08:00
hevinci
0c70f27560 update editor
1. 编辑器界面支持本地化配置。
2. 资源构建过程中的异常输出增加错误码提示。
3. 修复了资源构建界面乱码问题。
4. 修复了自动收集着色器对依赖资源无效的问题。
2023-10-13 12:06:20 +08:00
hevinci
db889366ac update samples 2023-10-11 14:36:18 +08:00
hevinci
9476bbe562 update resource package 2023-10-11 14:36:02 +08:00
hevinci
1313e05d5d Update CHANGELOG.md 2023-10-11 10:23:21 +08:00
hevinci
8817b35517 Update package.json 2023-10-11 10:23:12 +08:00
hevinci
cfe8a77dd5 fix #179 2023-10-10 16:19:53 +08:00
hevinci
a874d17798 update samples 2023-10-10 12:17:54 +08:00
hevinci
5d9ef12577 update operation system 2023-10-10 12:17:01 +08:00
hevinci
b3a135e1a2 fix #178 2023-10-10 11:59:56 +08:00
hevinci
a25d03f073 update resource package 2023-10-08 17:42:10 +08:00
hevinci
589c0d3ce5 update resource package
下载器增加合并方法
2023-10-08 17:41:07 +08:00
hevinci
8457705807 fix #177 2023-10-08 15:31:39 +08:00
hevinci
ce7aefb744 fix #175 2023-10-07 18:51:52 +08:00
hevinci
499d7766db update extension 2023-10-07 18:51:27 +08:00
349 changed files with 26412 additions and 25894 deletions

View File

@@ -2,6 +2,59 @@
All notable changes to this package will be documented in this file. All notable changes to this package will be documented in this file.
## [2.0.0-preview] - 2023-10-07 ## [2.1.0] - 2023-12-27
升级了 Scriptable build pipeline (SBP) 的版本,来解决图集引用的精灵图片冗余问题。
### Fixed
- (#195) 修复了在EditorPlayMode模式下AssetHandle.GetDownloadStatus()发生异常的问题。
- (#201) 修复了断点续传失效的问题。
- (#202) 修复了打包参数FileNameStyle设置为BundleName后IQueryServices会一直返回true的问题。
- (#205) 修复了HybridCLR插件里创建资源下载器触发的异常。
- (#210) 修复了DownloaderOperation在未开始下载前内部的PackageName为空的问题。
- (#220) 修复了资源收集界面关闭后,撤回操作还会生效的问题。
- 修复了下载器合并后重新计算下载字节数不正确的问题。
### Improvements
- (#198) 资源收集界面禁用的分组不再检测合法性。
- (#203) 资源构建类容许自定义打包的输出目录。
- 资源构建报告增加未依赖的资源信息列表。
### Changed
- IBuildinQueryServices和IDeliveryQueryServices查询方法变更。
```c#
public interface IBuildinQueryServices
{
/// <summary>
/// 查询是否为应用程序内置的资源文件
/// </summary>
/// <param name="packageName">包裹名称</param>
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
/// <param name="fileCRC">文件哈希值</param>
/// <returns>返回查询结果</returns>
bool Query(string packageName, string fileName, string fileCRC);
}
public interface IDeliveryQueryServices
{
/// <summary>
/// 查询是否为开发者分发的资源文件
/// </summary>
/// <param name="packageName">包裹名称</param>
/// <param name="fileName">文件名称(包含文件的后缀格式)</param>
/// <param name="fileCRC">文件哈希值</param>
/// <returns>返回查询结果</returns>
bool Query(string packageName, string fileName, string fileCRC);
}
```
### Removed
- (#212) 移除了构建报告里的资源冗余信息列表。
This is the preview version.

View File

@@ -41,12 +41,12 @@ namespace YooAsset.Editor
if (buildResult.Success) if (buildResult.Success)
{ {
buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory(); buildResult.OutputPackageDirectory = buildParametersContext.GetPackageOutputDirectory();
BuildLogger.Log($"{buildParameters.BuildMode} pipeline build succeed !"); BuildLogger.Log("Resource pipeline build success");
} }
else else
{ {
BuildLogger.Warning($"{buildParameters.BuildMode} pipeline build failed !"); BuildLogger.Error($"{buildParameters.BuildPipeline} build failed !");
BuildLogger.Error($"Build task failed : {buildResult.FailedTask}"); BuildLogger.Error($"An error occurred in build task {buildResult.FailedTask}");
BuildLogger.Error(buildResult.ErrorInfo); BuildLogger.Error(buildResult.ErrorInfo);
} }

View File

@@ -14,7 +14,7 @@ namespace YooAsset.Editor
[MenuItem("YooAsset/AssetBundle Builder", false, 102)] [MenuItem("YooAsset/AssetBundle Builder", false, 102)]
public static void OpenWindow() public static void OpenWindow()
{ {
AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("资源包构建工具", true, WindowsDefine.DockedWindowTypes); AssetBundleBuilderWindow window = GetWindow<AssetBundleBuilderWindow>("AssetBundle Builder", true, WindowsDefine.DockedWindowTypes);
window.minSize = new Vector2(800, 600); window.minSize = new Vector2(800, 600);
} }
@@ -47,7 +47,7 @@ namespace YooAsset.Editor
if (packageNames.Count == 0) if (packageNames.Count == 0)
{ {
var label = new Label(); var label = new Label();
label.text = "没有发现可构建的资源包"; label.text = "Not found any package";
label.style.width = 100; label.style.width = 100;
_toolbar.Add(label); _toolbar.Add(label);
return; return;

View File

@@ -26,19 +26,9 @@ namespace YooAsset.Editor
public string Address { private set; get; } public string Address { private set; get; }
/// <summary> /// <summary>
/// 资源路径 /// 资源信息
/// </summary> /// </summary>
public string AssetPath { private set; get; } public AssetInfo AssetInfo { private set; get; }
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID { private set; get; }
/// <summary>
/// 资源类型
/// </summary>
public System.Type AssetType { private set; get; }
/// <summary> /// <summary>
/// 资源的分类标签 /// 资源的分类标签
@@ -52,24 +42,19 @@ namespace YooAsset.Editor
public List<BuildAssetInfo> AllDependAssetInfos { private set; get; } public List<BuildAssetInfo> AllDependAssetInfos { private set; get; }
public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath) public BuildAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo)
{ {
CollectorType = collectorType; CollectorType = collectorType;
BundleName = bundleName; BundleName = bundleName;
Address = address; Address = address;
AssetPath = assetPath; AssetInfo = assetInfo;
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
} }
public BuildAssetInfo(string assetPath) public BuildAssetInfo(AssetInfo assetInfo)
{ {
CollectorType = ECollectorType.None; CollectorType = ECollectorType.None;
BundleName = string.Empty;
Address = string.Empty; Address = string.Empty;
AssetPath = assetPath; AssetInfo = assetInfo;
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(assetPath);
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(assetPath);
} }
@@ -84,6 +69,16 @@ namespace YooAsset.Editor
AllDependAssetInfos = dependAssetInfos; AllDependAssetInfos = dependAssetInfos;
} }
/// <summary>
/// 设置为统一的着色器包名
/// </summary>
public void SetShaderBundleName(string packageName, bool uniqueBundleName)
{
// 获取着色器打包规则结果
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
BundleName = shaderPackRuleResult.GetBundleName(packageName, uniqueBundleName);
}
/// <summary> /// <summary>
/// 添加资源的分类标签 /// 添加资源的分类标签
/// 说明:原始定义的资源分类标签 /// 说明:原始定义的资源分类标签
@@ -126,17 +121,6 @@ namespace YooAsset.Editor
return true; return true;
} }
/// <summary>
/// 判断是否为冗余资源
/// </summary>
public bool IsRedundancyAsset()
{
if (HasBundleName())
return false;
return _referenceBundleNames.Count > 1;
}
/// <summary> /// <summary>
/// 获取关联资源包的数量 /// 获取关联资源包的数量
/// </summary> /// </summary>

View File

@@ -82,12 +82,12 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 添加一个打包资源 /// 添加一个打包资源
/// </summary> /// </summary>
public void PackAsset(BuildAssetInfo assetInfo) public void PackAsset(BuildAssetInfo buildAsset)
{ {
if (IsContainsAsset(assetInfo.AssetPath)) if (IsContainsAsset(buildAsset.AssetInfo.AssetPath))
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}"); throw new System.Exception($"Should never get here ! Asset is existed : {buildAsset.AssetInfo.AssetPath}");
MainAssets.Add(assetInfo); MainAssets.Add(buildAsset);
} }
/// <summary> /// <summary>
@@ -95,9 +95,9 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool IsContainsAsset(string assetPath) public bool IsContainsAsset(string assetPath)
{ {
foreach (var assetInfo in MainAssets) foreach (var buildAsset in MainAssets)
{ {
if (assetInfo.AssetPath == assetPath) if (buildAsset.AssetInfo.AssetPath == assetPath)
{ {
return true; return true;
} }
@@ -110,7 +110,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string[] GetAllMainAssetPaths() public string[] GetAllMainAssetPaths()
{ {
return MainAssets.Select(t => t.AssetPath).ToArray(); return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
} }
/// <summary> /// <summary>
@@ -120,17 +120,17 @@ namespace YooAsset.Editor
{ {
var packAssets = GetAllMainAssetPaths(); var packAssets = GetAllMainAssetPaths();
List<string> result = new List<string>(packAssets); List<string> result = new List<string>(packAssets);
foreach (var assetInfo in MainAssets) foreach (var buildAsset in MainAssets)
{ {
if (assetInfo.AllDependAssetInfos == null) if (buildAsset.AllDependAssetInfos == null)
continue; continue;
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos) foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
{ {
// 注意:依赖资源里只添加零依赖资源和冗余资源 // 注意:依赖资源里只添加零依赖资源和冗余资源
if (dependAssetInfo.HasBundleName() == false) if (dependAssetInfo.HasBundleName() == false)
{ {
if (result.Contains(dependAssetInfo.AssetPath) == false) if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
result.Add(dependAssetInfo.AssetPath); result.Add(dependAssetInfo.AssetInfo.AssetPath);
} }
} }
} }
@@ -165,10 +165,10 @@ namespace YooAsset.Editor
{ {
PackageBundle packageBundle = new PackageBundle(); PackageBundle packageBundle = new PackageBundle();
packageBundle.BundleName = BundleName; packageBundle.BundleName = BundleName;
packageBundle.UnityCRC = PackageUnityCRC;
packageBundle.FileHash = PackageFileHash; packageBundle.FileHash = PackageFileHash;
packageBundle.FileCRC = PackageFileCRC; packageBundle.FileCRC = PackageFileCRC;
packageBundle.FileSize = PackageFileSize; packageBundle.FileSize = PackageFileSize;
packageBundle.UnityCRC = PackageUnityCRC;
packageBundle.Encrypted = Encrypted; packageBundle.Encrypted = Encrypted;
return packageBundle; return packageBundle;
} }

View File

@@ -14,10 +14,9 @@ namespace YooAsset.Editor
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000); private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
/// <summary> /// <summary>
/// 冗余的资源列表 /// 未被依赖的资源列表
/// </summary> /// </summary>
public readonly List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(1000); public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
/// <summary> /// <summary>
/// 参与构建的资源总数 /// 参与构建的资源总数
@@ -80,7 +79,7 @@ namespace YooAsset.Editor
{ {
return result; return result;
} }
throw new Exception($"Not found bundle : {bundleName}"); throw new Exception($"Should never get here ! Not found bundle : {bundleName}");
} }
/// <summary> /// <summary>

View File

@@ -73,7 +73,6 @@ namespace YooAsset.Editor
public IEncryptionServices EncryptionServices; public IEncryptionServices EncryptionServices;
private string _pipelineOutputDirectory = string.Empty; private string _pipelineOutputDirectory = string.Empty;
private string _packageOutputDirectory = string.Empty; private string _packageOutputDirectory = string.Empty;
private string _packageRootDirectory = string.Empty; private string _packageRootDirectory = string.Empty;
@@ -86,25 +85,46 @@ namespace YooAsset.Editor
{ {
// 检测当前是否正在构建资源包 // 检测当前是否正在构建资源包
if (UnityEditor.BuildPipeline.isBuildingPlayer) if (UnityEditor.BuildPipeline.isBuildingPlayer)
throw new Exception("当前正在构建资源包,请结束后再试"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.ThePipelineIsBuiding, "The pipeline is buiding, please try again after finish !");
// 检测构建参数合法性 throw new Exception(message);
if (BuildTarget == BuildTarget.NoTarget) }
throw new Exception("请选择目标平台!");
if (string.IsNullOrEmpty(PackageName))
throw new Exception("包裹名称不能为空!");
if (string.IsNullOrEmpty(PackageVersion))
throw new Exception("包裹版本不能为空!");
if (string.IsNullOrEmpty(BuildOutputRoot))
throw new Exception("构建输出的根目录为空!");
if (string.IsNullOrEmpty(BuildinFileRoot))
throw new Exception("内置资源根目录为空!");
// 检测是否有未保存场景 // 检测是否有未保存场景
if (BuildMode != EBuildMode.SimulateBuild) if (BuildMode != EBuildMode.SimulateBuild)
{ {
if (EditorTools.HasDirtyScenes()) if (EditorTools.HasDirtyScenes())
throw new Exception("检测到未保存的场景文件"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
throw new Exception(message);
}
}
// 检测构建参数合法性
if (BuildTarget == BuildTarget.NoTarget)
{
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
throw new Exception(message);
}
if (string.IsNullOrEmpty(PackageName))
{
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
throw new Exception(message);
}
if (string.IsNullOrEmpty(PackageVersion))
{
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
throw new Exception(message);
}
if (string.IsNullOrEmpty(BuildOutputRoot))
{
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
throw new Exception(message);
}
if (string.IsNullOrEmpty(BuildinFileRoot))
{
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
throw new Exception(message);
} }
// 强制构建删除包裹目录 // 强制构建删除包裹目录
@@ -113,7 +133,7 @@ namespace YooAsset.Editor
string packageRootDirectory = GetPackageRootDirectory(); string packageRootDirectory = GetPackageRootDirectory();
if (EditorTools.DeleteDirectory(packageRootDirectory)) if (EditorTools.DeleteDirectory(packageRootDirectory))
{ {
BuildLogger.Log($"删除包裹目录:{packageRootDirectory}"); BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
} }
} }
@@ -122,14 +142,17 @@ namespace YooAsset.Editor
{ {
string packageOutputDirectory = GetPackageOutputDirectory(); string packageOutputDirectory = GetPackageOutputDirectory();
if (Directory.Exists(packageOutputDirectory)) if (Directory.Exists(packageOutputDirectory))
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
throw new Exception(message);
}
} }
// 如果输出目录不存在 // 如果输出目录不存在
string pipelineOutputDirectory = GetPipelineOutputDirectory(); string pipelineOutputDirectory = GetPipelineOutputDirectory();
if (EditorTools.CreateDirectory(pipelineOutputDirectory)) if (EditorTools.CreateDirectory(pipelineOutputDirectory))
{ {
BuildLogger.Log($"创建输出目录:{pipelineOutputDirectory}"); BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
} }
} }
@@ -138,7 +161,7 @@ namespace YooAsset.Editor
/// 获取构建管线的输出目录 /// 获取构建管线的输出目录
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public string GetPipelineOutputDirectory() public virtual string GetPipelineOutputDirectory()
{ {
if (string.IsNullOrEmpty(_pipelineOutputDirectory)) if (string.IsNullOrEmpty(_pipelineOutputDirectory))
{ {
@@ -150,7 +173,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取本次构建的补丁输出目录 /// 获取本次构建的补丁输出目录
/// </summary> /// </summary>
public string GetPackageOutputDirectory() public virtual string GetPackageOutputDirectory()
{ {
if (string.IsNullOrEmpty(_packageOutputDirectory)) if (string.IsNullOrEmpty(_packageOutputDirectory))
{ {
@@ -162,7 +185,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取本次构建的补丁根目录 /// 获取本次构建的补丁根目录
/// </summary> /// </summary>
public string GetPackageRootDirectory() public virtual string GetPackageRootDirectory()
{ {
if (string.IsNullOrEmpty(_packageRootDirectory)) if (string.IsNullOrEmpty(_packageRootDirectory))
{ {
@@ -174,7 +197,7 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 获取内置资源的根目录 /// 获取内置资源的根目录
/// </summary> /// </summary>
public string GetBuildinRootDirectory() public virtual string GetBuildinRootDirectory()
{ {
if (string.IsNullOrEmpty(_buildinRootDirectory)) if (string.IsNullOrEmpty(_buildinRootDirectory))
{ {

View File

@@ -76,7 +76,7 @@ namespace YooAsset.Editor
// 刷新目录 // 刷新目录
AssetDatabase.Refresh(); AssetDatabase.Refresh();
BuildLogger.Log($"内置文件拷贝完成:{buildinRootDirectory}"); BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
} }
} }
} }

View File

@@ -3,9 +3,6 @@ using System.Linq;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using UnityEditor.Build.Pipeline;
using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
public class ManifestContext : IContextObject public class ManifestContext : IContextObject
@@ -16,6 +13,7 @@ namespace YooAsset.Editor
public abstract class TaskCreateManifest public abstract class TaskCreateManifest
{ {
private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000); private readonly Dictionary<string, int> _cachedBundleID = new Dictionary<string, int>(10000);
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
/// <summary> /// <summary>
/// 创建补丁清单文件到输出目录 /// 创建补丁清单文件到输出目录
@@ -54,7 +52,7 @@ namespace YooAsset.Editor
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string filePath = $"{packageOutputDirectory}/{fileName}"; string filePath = $"{packageOutputDirectory}/{fileName}";
ManifestTools.SerializeToJson(filePath, manifest); ManifestTools.SerializeToJson(filePath, manifest);
BuildLogger.Log($"创建补丁清单文件:{filePath}"); BuildLogger.Log($"Create package manifest file: {filePath}");
} }
// 创建补丁清单二进制文件 // 创建补丁清单二进制文件
@@ -64,7 +62,7 @@ namespace YooAsset.Editor
string filePath = $"{packageOutputDirectory}/{fileName}"; string filePath = $"{packageOutputDirectory}/{fileName}";
ManifestTools.SerializeToBinary(filePath, manifest); ManifestTools.SerializeToBinary(filePath, manifest);
packageHash = HashUtility.FileMD5(filePath); packageHash = HashUtility.FileMD5(filePath);
BuildLogger.Log($"创建补丁清单文件:{filePath}"); BuildLogger.Log($"Create package manifest file: {filePath}");
ManifestContext manifestContext = new ManifestContext(); ManifestContext manifestContext = new ManifestContext();
byte[] bytesData = FileUtility.ReadAllBytes(filePath); byte[] bytesData = FileUtility.ReadAllBytes(filePath);
@@ -77,7 +75,7 @@ namespace YooAsset.Editor
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string filePath = $"{packageOutputDirectory}/{fileName}"; string filePath = $"{packageOutputDirectory}/{fileName}";
FileUtility.WriteAllText(filePath, packageHash); FileUtility.WriteAllText(filePath, packageHash);
BuildLogger.Log($"创建补丁清单哈希文件:{filePath}"); BuildLogger.Log($"Create package manifest hash file: {filePath}");
} }
// 创建补丁清单版本文件 // 创建补丁清单版本文件
@@ -85,7 +83,7 @@ namespace YooAsset.Editor
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName); string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
string filePath = $"{packageOutputDirectory}/{fileName}"; string filePath = $"{packageOutputDirectory}/{fileName}";
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion); FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
BuildLogger.Log($"创建补丁清单版本文件:{filePath}"); BuildLogger.Log($"Create package manifest version file: {filePath}");
} }
} }
@@ -107,8 +105,8 @@ namespace YooAsset.Editor
{ {
PackageAsset packageAsset = new PackageAsset(); PackageAsset packageAsset = new PackageAsset();
packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty; packageAsset.Address = buildMapContext.Command.EnableAddressable ? assetInfo.Address : string.Empty;
packageAsset.AssetPath = assetInfo.AssetPath; packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetGUID : string.Empty; packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
packageAsset.AssetTags = assetInfo.AssetTags.ToArray(); packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName); packageAsset.BundleID = GetCachedBundleID(assetInfo.BundleName);
result.Add(packageAsset); result.Add(packageAsset);
@@ -165,36 +163,44 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
private void ProcessBundleTags(PackageManifest manifest) private void ProcessBundleTags(PackageManifest manifest)
{ {
Dictionary<int, HashSet<string>> cacheBundleTags = new Dictionary<int, HashSet<string>>(10000); // 将主资源的标签信息传染给其依赖的资源包集合
foreach (var packageAsset in manifest.AssetList) foreach (var packageAsset in manifest.AssetList)
{ {
// 主资源包 var assetTags = packageAsset.AssetTags;
int bundleID = packageAsset.BundleID; int bundleID = packageAsset.BundleID;
CacheBundleTags(cacheBundleTags, bundleID, packageAsset.AssetTags); CacheBundleTags(bundleID, assetTags);
// 依赖资源包
var packageBundle = manifest.BundleList[bundleID]; var packageBundle = manifest.BundleList[bundleID];
foreach (var dependBundleID in packageBundle.DependIDs) foreach (var dependBundleID in packageBundle.DependIDs)
{ {
CacheBundleTags(cacheBundleTags, dependBundleID, packageAsset.AssetTags); CacheBundleTags(dependBundleID, assetTags);
} }
} }
for (int index = 0; index < manifest.BundleList.Count; index++) for (int index = 0; index < manifest.BundleList.Count; index++)
{ {
manifest.BundleList[index].Tags = cacheBundleTags[index].ToArray(); var packageBundle = manifest.BundleList[index];
} if (_cacheBundleTags.ContainsKey(index))
}
private void CacheBundleTags(Dictionary<int, HashSet<string>> cacheBundleTags, int bundleID, string[] assetTags)
{ {
if (cacheBundleTags.ContainsKey(bundleID) == false) packageBundle.Tags = _cacheBundleTags[index].ToArray();
cacheBundleTags.Add(bundleID, new HashSet<string>()); }
else
{
// 注意SBP构建管线会自动剔除一些冗余资源的引用关系导致游离资源包没有被任何主资源包引用。
string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundStrayBundle, $"Found stray bundle ! Bundle ID : {index} Bundle name : {packageBundle.BundleName}");
BuildLogger.Warning(warning);
}
}
}
private void CacheBundleTags(int bundleID, string[] assetTags)
{
if (_cacheBundleTags.ContainsKey(bundleID) == false)
_cacheBundleTags.Add(bundleID, new HashSet<string>());
foreach (var assetTag in assetTags) foreach (var assetTag in assetTags)
{ {
if (cacheBundleTags[bundleID].Contains(assetTag) == false) if (_cacheBundleTags[bundleID].Contains(assetTag) == false)
cacheBundleTags[bundleID].Add(assetTag); _cacheBundleTags[bundleID].Add(assetTag);
} }
} }
@@ -205,7 +211,7 @@ namespace YooAsset.Editor
{ {
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false) if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
{ {
throw new Exception($"Not found cached bundle ID : {bundleName}"); throw new Exception($"Should never get here ! Not found bundle ID : {bundleName}");
} }
return value; return value;
} }

View File

@@ -31,11 +31,13 @@ namespace YooAsset.Editor
buildReport.Summary.BuildMode = buildParameters.BuildMode; buildReport.Summary.BuildMode = buildParameters.BuildMode;
buildReport.Summary.BuildPackageName = buildParameters.PackageName; buildReport.Summary.BuildPackageName = buildParameters.PackageName;
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion; buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable; buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower; buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID; buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName; buildReport.Summary.IgnoreDefaultType = buildMapContext.Command.IgnoreDefaultType;
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ?
"null" : buildParameters.EncryptionServices.GetType().FullName; "null" : buildParameters.EncryptionServices.GetType().FullName;
// 构建参数 // 构建参数
@@ -105,14 +107,14 @@ namespace YooAsset.Editor
buildReport.BundleInfos.Add(reportBundleInfo); buildReport.BundleInfos.Add(reportBundleInfo);
} }
// 冗余资源列表 // 其它资源列表
buildReport.RedundancyInfos = new List<ReportRedundancyInfo>(buildMapContext.RedundancyInfos); buildReport.IndependAssets = new List<ReportIndependAsset>(buildMapContext.IndependAssets);
// 序列化文件 // 序列化文件
string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion); string fileName = YooAssetSettingsData.GetReportFileName(buildParameters.PackageName, buildParameters.PackageVersion);
string filePath = $"{packageOutputDirectory}/{fileName}"; string filePath = $"{packageOutputDirectory}/{fileName}";
BuildReport.Serialize(filePath, buildReport); BuildReport.Serialize(filePath, buildReport);
BuildLogger.Log($"资源构建报告文件创建完成:{filePath}"); BuildLogger.Log($"Create build report file: {filePath}");
} }
/// <summary> /// <summary>
@@ -138,21 +140,21 @@ namespace YooAsset.Editor
var bundleInfo = buildMapContext.GetBundleInfo(bundleName); var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
{ {
BuildAssetInfo findAssetInfo = null; BuildAssetInfo findAssetInfo = null;
foreach (var assetInfo in bundleInfo.MainAssets) foreach (var buildAsset in bundleInfo.MainAssets)
{ {
if (assetInfo.AssetPath == assetPath) if (buildAsset.AssetInfo.AssetPath == assetPath)
{ {
findAssetInfo = assetInfo; findAssetInfo = buildAsset;
break; break;
} }
} }
if (findAssetInfo == null) if (findAssetInfo == null)
{ {
throw new Exception($"Not found asset {assetPath} in bunlde {bundleName}"); throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
} }
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos) foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
{ {
result.Add(dependAssetInfo.AssetPath); result.Add(dependAssetInfo.AssetInfo.AssetPath);
} }
} }
return result; return result;

View File

@@ -27,7 +27,6 @@ namespace YooAsset.Editor
EncryptFileInfo fileInfo = new EncryptFileInfo(); EncryptFileInfo fileInfo = new EncryptFileInfo();
fileInfo.BundleName = bundleInfo.BundleName; fileInfo.BundleName = bundleInfo.BundleName;
fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; fileInfo.FilePath = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
var encryptResult = encryptionServices.Encrypt(fileInfo); var encryptResult = encryptionServices.Encrypt(fileInfo);
if (encryptResult.Encrypted) if (encryptResult.Encrypted)
{ {
@@ -35,7 +34,7 @@ namespace YooAsset.Editor
FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData); FileUtility.WriteAllBytes(filePath, encryptResult.EncryptedData);
bundleInfo.EncryptedFilePath = filePath; bundleInfo.EncryptedFilePath = filePath;
bundleInfo.Encrypted = true; bundleInfo.Encrypted = true;
BuildLogger.Log($"Bundle文件加密完成:{filePath}"); BuildLogger.Log($"Bundle file encryption complete: {filePath}");
} }
else else
{ {
@@ -43,7 +42,7 @@ namespace YooAsset.Editor
} }
// 进度条 // 进度条
EditorTools.DisplayProgressBar("加密资源包", ++progressValue, buildMapContext.Collection.Count); EditorTools.DisplayProgressBar("Encrypting bundle", ++progressValue, buildMapContext.Collection.Count);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }

View File

@@ -14,6 +14,7 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public BuildMapContext CreateBuildMap(BuildParameters buildParameters) public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
{ {
BuildMapContext context = new BuildMapContext();
var buildMode = buildParameters.BuildMode; var buildMode = buildParameters.BuildMode;
var packageName = buildParameters.PackageName; var packageName = buildParameters.PackageName;
@@ -21,87 +22,85 @@ namespace YooAsset.Editor
// 1. 获取所有收集器收集的资源 // 1. 获取所有收集器收集的资源
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName); var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets; List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
// 2. 剔除未被引用的依赖项资源 // 2. 剔除未被引用的依赖项资源
RemoveZeroReferenceAssets(allCollectAssetInfos); RemoveZeroReferenceAssets(context, allCollectAssets);
// 3. 录入所有收集器收集的资源 // 3. 录入所有收集器主动收集的资源
foreach (var collectAssetInfo in allCollectAssetInfos) foreach (var collectAssetInfo in allCollectAssets)
{ {
if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetPath) == false) if (allBuildAssetInfos.ContainsKey(collectAssetInfo.AssetInfo.AssetPath))
{ {
throw new Exception($"Should never get here !");
}
if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector) if (collectAssetInfo.CollectorType != ECollectorType.MainAssetCollector)
{ {
if (collectAssetInfo.AssetTags.Count > 0) if (collectAssetInfo.AssetTags.Count > 0)
{ {
collectAssetInfo.AssetTags.Clear(); collectAssetInfo.AssetTags.Clear();
BuildLogger.Warning($"The tags has been cleared ! {collectAssetInfo.AssetPath} "); string warning = BuildLogger.GetErrorMessage(ErrorCode.RemoveInvalidTags, $"Remove asset tags that don't work, see the asset collector type : {collectAssetInfo.AssetInfo.AssetPath}");
BuildLogger.Warning(warning);
} }
} }
var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetPath); var buildAssetInfo = new BuildAssetInfo(collectAssetInfo.CollectorType, collectAssetInfo.BundleName, collectAssetInfo.Address, collectAssetInfo.AssetInfo);
buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags); buildAssetInfo.AddAssetTags(collectAssetInfo.AssetTags);
allBuildAssetInfos.Add(collectAssetInfo.AssetPath, buildAssetInfo); allBuildAssetInfos.Add(collectAssetInfo.AssetInfo.AssetPath, buildAssetInfo);
}
else
{
throw new Exception($"Should never get here !");
}
} }
// 4. 录入所有收集资源依赖资源 // 4. 录入所有收集资源依赖的其它资源
foreach (var collectAssetInfo in allCollectAssetInfos) foreach (var collectAssetInfo in allCollectAssets)
{ {
string bundleName = collectAssetInfo.BundleName; string bundleName = collectAssetInfo.BundleName;
foreach (var dependAssetPath in collectAssetInfo.DependAssets) foreach (var dependAsset in collectAssetInfo.DependAssets)
{ {
if (allBuildAssetInfos.ContainsKey(dependAssetPath)) if (allBuildAssetInfos.ContainsKey(dependAsset.AssetPath))
{ {
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName); allBuildAssetInfos[dependAsset.AssetPath].AddReferenceBundleName(bundleName);
} }
else else
{ {
var buildAssetInfo = new BuildAssetInfo(dependAssetPath); var buildAssetInfo = new BuildAssetInfo(dependAsset);
buildAssetInfo.AddReferenceBundleName(bundleName); buildAssetInfo.AddReferenceBundleName(bundleName);
allBuildAssetInfos.Add(dependAssetPath, buildAssetInfo); allBuildAssetInfos.Add(dependAsset.AssetPath, buildAssetInfo);
} }
} }
} }
// 5. 填充所有收集资源的依赖列表 // 5. 填充所有收集资源的依赖列表
foreach (var collectAssetInfo in allCollectAssetInfos) foreach (var collectAssetInfo in allCollectAssets)
{ {
var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count); var dependAssetInfos = new List<BuildAssetInfo>(collectAssetInfo.DependAssets.Count);
foreach (var dependAssetPath in collectAssetInfo.DependAssets) foreach (var dependAsset in collectAssetInfo.DependAssets)
{ {
if (allBuildAssetInfos.TryGetValue(dependAssetPath, out BuildAssetInfo value)) if (allBuildAssetInfos.TryGetValue(dependAsset.AssetPath, out BuildAssetInfo value))
dependAssetInfos.Add(value); dependAssetInfos.Add(value);
else else
throw new Exception("Should never get here !"); throw new Exception("Should never get here !");
} }
allBuildAssetInfos[collectAssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos); allBuildAssetInfos[collectAssetInfo.AssetInfo.AssetPath].SetDependAssetInfos(dependAssetInfos);
} }
// 6. 记录关键信息 // 6. 自动收集所有依赖的着色器
BuildMapContext context = new BuildMapContext(); if (collectResult.Command.AutoCollectShaders)
context.AssetFileCount = allBuildAssetInfos.Count; {
context.Command = collectResult.Command;
// 7. 记录冗余资源
foreach (var buildAssetInfo in allBuildAssetInfos.Values) foreach (var buildAssetInfo in allBuildAssetInfos.Values)
{ {
if (buildAssetInfo.IsRedundancyAsset()) if (buildAssetInfo.CollectorType == ECollectorType.None)
{ {
var redundancyInfo = new ReportRedundancyInfo(); if (buildAssetInfo.AssetInfo.IsShaderAsset())
redundancyInfo.AssetPath = buildAssetInfo.AssetPath; {
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name; buildAssetInfo.SetShaderBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
context.RedundancyInfos.Add(redundancyInfo);
} }
} }
}
}
// 7. 记录关键信息
context.AssetFileCount = allBuildAssetInfos.Count;
context.Command = collectResult.Command;
// 8. 移除不参与构建的资源 // 8. 移除不参与构建的资源
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>(); List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
@@ -112,13 +111,16 @@ namespace YooAsset.Editor
} }
foreach (var removeValue in removeBuildList) foreach (var removeValue in removeBuildList)
{ {
allBuildAssetInfos.Remove(removeValue.AssetPath); allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
} }
// 9. 构建资源列表 // 9. 构建资源列表
var allPackAssets = allBuildAssetInfos.Values.ToList(); var allPackAssets = allBuildAssetInfos.Values.ToList();
if (allPackAssets.Count == 0) if (allPackAssets.Count == 0)
throw new Exception("构建的资源列表不能为空"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.PackAssetListIsEmpty, "The pack asset info is empty !");
throw new Exception(message);
}
foreach (var assetInfo in allPackAssets) foreach (var assetInfo in allPackAssets)
{ {
context.PackAsset(assetInfo); context.PackAsset(assetInfo);
@@ -126,35 +128,35 @@ namespace YooAsset.Editor
return context; return context;
} }
private void RemoveZeroReferenceAssets(List<CollectAssetInfo> allCollectAssetInfos) private void RemoveZeroReferenceAssets(BuildMapContext context, List<CollectAssetInfo> allCollectAssets)
{ {
// 1. 检测是否任何存在依赖资源 // 1. 检测依赖资源收集器是否存在
if (allCollectAssetInfos.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false) if (allCollectAssets.Exists(x => x.CollectorType == ECollectorType.DependAssetCollector) == false)
return; return;
// 2. 获取所有主资源的依赖资源集合 // 2. 获取所有主资源的依赖资源集合
HashSet<string> allDependAsset = new HashSet<string>(); HashSet<string> allDependAsset = new HashSet<string>();
foreach (var collectAssetInfo in allCollectAssetInfos) foreach (var collectAsset in allCollectAssets)
{ {
var collectorType = collectAssetInfo.CollectorType; var collectorType = collectAsset.CollectorType;
if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector) if (collectorType == ECollectorType.MainAssetCollector || collectorType == ECollectorType.StaticAssetCollector)
{ {
foreach (var dependAsset in collectAssetInfo.DependAssets) foreach (var dependAsset in collectAsset.DependAssets)
{ {
if (allDependAsset.Contains(dependAsset) == false) if (allDependAsset.Contains(dependAsset.AssetPath) == false)
allDependAsset.Add(dependAsset); allDependAsset.Add(dependAsset.AssetPath);
} }
} }
} }
// 3. 找出所有零引用的依赖资源集合 // 3. 找出所有零引用的依赖资源集合
List<CollectAssetInfo> removeList = new List<CollectAssetInfo>(); List<CollectAssetInfo> removeList = new List<CollectAssetInfo>();
foreach (var collectAssetInfo in allCollectAssetInfos) foreach (var collectAssetInfo in allCollectAssets)
{ {
var collectorType = collectAssetInfo.CollectorType; var collectorType = collectAssetInfo.CollectorType;
if (collectorType == ECollectorType.DependAssetCollector) if (collectorType == ECollectorType.DependAssetCollector)
{ {
if (allDependAsset.Contains(collectAssetInfo.AssetPath) == false) if (allDependAsset.Contains(collectAssetInfo.AssetInfo.AssetPath) == false)
removeList.Add(collectAssetInfo); removeList.Add(collectAssetInfo);
} }
} }
@@ -162,8 +164,17 @@ namespace YooAsset.Editor
// 4. 移除所有零引用的依赖资源 // 4. 移除所有零引用的依赖资源
foreach (var removeValue in removeList) foreach (var removeValue in removeList)
{ {
BuildLogger.Log($"发现未被依赖的资源并自动移除 : {removeValue.AssetPath}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.FoundUndependedAsset, $"Found undepended asset and remove it : {removeValue.AssetInfo.AssetPath}");
allCollectAssetInfos.Remove(removeValue); BuildLogger.Warning(warning);
var independAsset = new ReportIndependAsset();
independAsset.AssetPath = removeValue.AssetInfo.AssetPath;
independAsset.AssetGUID = removeValue.AssetInfo.AssetGUID;
independAsset.AssetType = removeValue.AssetInfo.AssetType.ToString();
independAsset.FileSize = FileUtility.GetFileSize(removeValue.AssetInfo.AssetPath);
context.IndependAssets.Add(independAsset);
allCollectAssets.Remove(removeValue);
} }
} }
} }

View File

@@ -23,7 +23,10 @@ namespace YooAsset.Editor
// NOTE检测文件名长度不要超过260字符。 // NOTE检测文件名长度不要超过260字符。
string fileName = bundleInfo.BundleName; string fileName = bundleInfo.BundleName;
if (fileName.Length >= 260) if (fileName.Length >= 260)
throw new Exception($"The output bundle name is too long {fileName.Length} chars : {fileName}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.CharactersOverTheLimit, $"Bundle file name character count exceeds limit : {fileName}");
throw new Exception(message);
}
} }
// 2.更新构建输出的文件路径 // 2.更新构建输出的文件路径
@@ -41,9 +44,9 @@ namespace YooAsset.Editor
{ {
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context); bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context); bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo.PackageSourceFilePath, buildParametersContext); bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo.PackageSourceFilePath, buildParametersContext); bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo.PackageSourceFilePath, buildParametersContext); bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
} }
// 4.更新补丁包输出的文件路径 // 4.更新补丁包输出的文件路径
@@ -59,9 +62,9 @@ namespace YooAsset.Editor
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context); protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context); protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
protected abstract string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext); protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext); protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected abstract long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext); protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
protected string GetFilePathTempHash(string filePath) protected string GetFilePathTempHash(string filePath)
{ {
@@ -71,5 +74,23 @@ namespace YooAsset.Editor
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法 // 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}"; //return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
} }
protected long GetBundleTempSize(BuildBundleInfo bundleInfo)
{
long tempSize = 0;
var assetPaths = bundleInfo.GetAllMainAssetPaths();
foreach (var assetPath in assetPaths)
{
long size = FileUtility.GetFileSize(assetPath);
tempSize += size;
}
if (tempSize == 0)
{
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleTempSizeIsZero, $"Bundle temp size is zero, check bundle main asset list : {bundleInfo.BundleName}");
throw new Exception(message);
}
return tempSize;
}
} }
} }

View File

@@ -7,7 +7,6 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建内容打包")]
public class TaskBuilding_BBP : IBuildTask public class TaskBuilding_BBP : IBuildTask
{ {
public class BuildResultContext : IContextObject public class BuildResultContext : IContextObject
@@ -29,22 +28,26 @@ namespace YooAsset.Editor
// 开始构建 // 开始构建
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions(); BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
AssetBundleManifest buildResults = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget); AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
if (buildResults == null) if (unityManifest == null)
{ {
throw new Exception("构建过程中发生错误!"); string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
throw new Exception(message);
} }
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild) if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
{ {
string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}"; string unityOutputManifestFilePath = $"{pipelineOutputDirectory}/{YooAssetSettings.OutputFolderName}";
if (System.IO.File.Exists(unityOutputManifestFilePath) == false) if (System.IO.File.Exists(unityOutputManifestFilePath) == false)
throw new Exception("构建过程中发生严重错误!请查阅上下文日志!"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFatal, $"Not found output {nameof(AssetBundleManifest)} file : {unityOutputManifestFilePath}");
throw new Exception(message);
}
} }
BuildLogger.Log("Unity引擎打包成功!"); BuildLogger.Log("UnityEngine build success !");
BuildResultContext buildResultContext = new BuildResultContext(); BuildResultContext buildResultContext = new BuildResultContext();
buildResultContext.UnityManifest = buildResults; buildResultContext.UnityManifest = unityManifest;
context.SetContextObject(buildResultContext); context.SetContextObject(buildResultContext);
} }
} }

View File

@@ -6,7 +6,6 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("拷贝内置文件")]
public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask public class TaskCopyBuildinFiles_BBP : TaskCopyBuildinFiles, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -5,7 +5,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建清单文件")]
public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask public class TaskCreateManifest_BBP : TaskCreateManifest, IBuildTask
{ {
private TaskBuilding_BBP.BuildResultContext _buildResultContext = null; private TaskBuilding_BBP.BuildResultContext _buildResultContext = null;

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("制作包裹")]
public class TaskCreatePackage_BBP : IBuildTask public class TaskCreatePackage_BBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -13,18 +12,18 @@ namespace YooAsset.Editor
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild) if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
{ {
CopyPackageFiles(buildParameters, buildMapContext); CreatePackageCatalog(buildParameters, buildMapContext);
} }
} }
/// <summary> /// <summary>
/// 拷贝补丁文件到补丁包目录 /// 拷贝补丁文件到补丁包目录
/// </summary> /// </summary>
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext) private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
{ {
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}"); BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
// 拷贝UnityManifest序列化文件 // 拷贝UnityManifest序列化文件
{ {
@@ -46,7 +45,7 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true); EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount); EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建构建报告文件")]
public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask public class TaskCreateReport_BBP : TaskCreateReport, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源包加密")]
public class TaskEncryption_BBP : TaskEncryption, IBuildTask public class TaskEncryption_BBP : TaskEncryption, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -7,7 +7,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("获取资源构建内容")]
public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask public class TaskGetBuildMap_BBP : TaskGetBuildMap, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建准备工作")]
public class TaskPrepare_BBP : IBuildTask public class TaskPrepare_BBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -22,7 +21,8 @@ namespace YooAsset.Editor
#if UNITY_2021_3_OR_NEWER #if UNITY_2021_3_OR_NEWER
if (buildParameters.BuildMode != EBuildMode.SimulateBuild) if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
{ {
BuildLogger.Warning("Unity2021版本开始内置构建管线不再维护推荐使用可编程构建管线SBP"); string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
BuildLogger.Warning(warning);
} }
#endif #endif
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("更新资源包信息")]
public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask public class TaskUpdateBundleInfo_BBP : TaskUpdateBundleInfo, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -28,9 +27,14 @@ namespace YooAsset.Editor
var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>(); var buildResult = context.GetContextObject<TaskBuilding_BBP.BuildResultContext>();
var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName); var hash = buildResult.UnityManifest.GetAssetBundleHash(bundleInfo.BundleName);
if (hash.isValid) if (hash.isValid)
{
return hash.ToString(); return hash.ToString();
}
else else
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
throw new Exception(message);
}
} }
} }
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context) protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
@@ -46,32 +50,40 @@ namespace YooAsset.Editor
{ {
string filePath = bundleInfo.BuildOutputFilePath; string filePath = bundleInfo.BuildOutputFilePath;
if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc)) if (BuildPipeline.GetCRCForAssetBundle(filePath, out uint crc))
return crc;
else
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
}
}
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
{ {
return crc;
}
else
{
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
throw new Exception(message);
}
}
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
return GetFilePathTempHash(filePath); return GetFilePathTempHash(filePath);
else else
return HashUtility.FileMD5(filePath); return HashUtility.FileMD5(filePath);
} }
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext) protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
return "00000000"; //8位 return "00000000"; //8位
else else
return HashUtility.FileCRC32(filePath); return HashUtility.FileCRC32(filePath);
} }
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext) protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
return 0; return GetBundleTempSize(bundleInfo);
else else
return FileUtility.GetFileSize(filePath); return FileUtility.GetFileSize(filePath);
} }

View File

@@ -8,7 +8,6 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult_BBP : IBuildTask public class TaskVerifyBuildResult_BBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -46,9 +45,12 @@ namespace YooAsset.Editor
{ {
foreach (var exceptBundle in exceptBundleList1) foreach (var exceptBundle in exceptBundleList1)
{ {
BuildLogger.Warning($"差异资源包: {exceptBundle}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
BuildLogger.Warning(warning);
} }
throw new System.Exception("存在差异资源包!请查看警告信息!");
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
} }
// 3. 验证Bundle // 3. 验证Bundle
@@ -57,12 +59,15 @@ namespace YooAsset.Editor
{ {
foreach (var exceptBundle in exceptBundleList2) foreach (var exceptBundle in exceptBundleList2)
{ {
BuildLogger.Warning($"差异资源包: {exceptBundle}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
} BuildLogger.Warning(warning);
throw new System.Exception("存在差异资源包!请查看警告信息!");
} }
BuildLogger.Log("构建结果验证成功!"); string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
}
BuildLogger.Log("Build results verify success!");
} }
} }
} }

View File

@@ -1,9 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
@@ -22,15 +19,16 @@ namespace YooAsset.Editor
{ {
List<IBuildTask> pipeline = new List<IBuildTask> List<IBuildTask> pipeline = new List<IBuildTask>
{ {
new TaskPrepare_BBP(), //前期准备工作 new TaskPrepare_BBP(),
new TaskGetBuildMap_BBP(), //获取构建列表 new TaskGetBuildMap_BBP(),
new TaskBuilding_BBP(), //开始执行构建 new TaskBuilding_BBP(),
new TaskVerifyBuildResult_BBP(), //验证构建结果 new TaskVerifyBuildResult_BBP(),
new TaskUpdateBundleInfo_BBP(), //更新资源包信息 new TaskEncryption_BBP(),
new TaskCreateManifest_BBP(), //创建清单文件 new TaskUpdateBundleInfo_BBP(),
new TaskCreateReport_BBP(), //创建报告文件 new TaskCreateManifest_BBP(),
new TaskCreatePackage_BBP(), //制作包裹 new TaskCreateReport_BBP(),
new TaskCopyBuildinFiles_BBP(), //拷贝内置文件 new TaskCreatePackage_BBP(),
new TaskCopyBuildinFiles_BBP(),
}; };
return pipeline; return pipeline;
} }

View File

@@ -5,7 +5,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建内容打包")]
public class TaskBuilding_RFBP : IBuildTask public class TaskBuilding_RFBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -30,9 +29,9 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}"; string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
foreach (var assetInfo in bundleInfo.MainAssets) foreach (var buildAsset in bundleInfo.MainAssets)
{ {
EditorTools.CopyFile(assetInfo.AssetPath, dest, true); EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
} }
} }
} }

View File

@@ -6,7 +6,6 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("拷贝内置文件")]
public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask public class TaskCopyBuildinFiles_RFBP : TaskCopyBuildinFiles, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -5,7 +5,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建清单文件")]
public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask public class TaskCreateManifest_RFBP : TaskCreateManifest, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("制作包裹")]
public class TaskCreatePackage_RFBP : IBuildTask public class TaskCreatePackage_RFBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -13,19 +12,17 @@ namespace YooAsset.Editor
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode != EBuildMode.SimulateBuild) if (buildMode != EBuildMode.SimulateBuild)
{ {
CopyPackageFiles(buildParameters, buildMapContext); CreatePackageCatalog(buildParameters, buildMapContext);
} }
} }
/// <summary> /// <summary>
/// 拷贝补丁文件到补丁包目录 /// 拷贝补丁文件到补丁包目录
/// </summary> /// </summary>
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext) private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
{ {
var buildParameters = buildParametersContext.Parameters;
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}"); BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
// 拷贝所有补丁文件 // 拷贝所有补丁文件
int progressValue = 0; int progressValue = 0;
@@ -33,7 +30,7 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true); EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount); EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建构建报告文件")]
public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask public class TaskCreateReport_RFBP : TaskCreateReport, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -7,7 +7,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("获取资源构建内容")]
public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask public class TaskGetBuildMap_RFBP : TaskGetBuildMap, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -29,7 +28,10 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
if (bundleInfo.MainAssets.Count != 1) if (bundleInfo.MainAssets.Count != 1)
throw new Exception($"The bundle does not support multiple raw asset : {bundleInfo.BundleName}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
throw new Exception(message);
}
} }
} }
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建准备工作")]
public class TaskPrepare_RFBP : IBuildTask public class TaskPrepare_RFBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -19,9 +18,15 @@ namespace YooAsset.Editor
// 检测不被支持的构建模式 // 检测不被支持的构建模式
if (buildParameters.BuildMode == EBuildMode.DryRunBuild) if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
throw new Exception(message);
}
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild) if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.RawFileBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
throw new Exception(message);
}
} }
} }
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("更新资源包信息")]
public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask public class TaskUpdateBundleInfo_RFBP : TaskUpdateBundleInfo, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -33,27 +32,30 @@ namespace YooAsset.Editor
{ {
return 0; return 0;
} }
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext) protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return GetFilePathTempHash(filePath); return GetFilePathTempHash(filePath);
else else
return HashUtility.FileMD5(filePath); return HashUtility.FileMD5(filePath);
} }
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext) protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return "00000000"; //8位 return "00000000"; //8位
else else
return HashUtility.FileCRC32(filePath); return HashUtility.FileCRC32(filePath);
} }
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext) protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return 0; return GetBundleTempSize(bundleInfo);
else else
return FileUtility.GetFileSize(filePath); return FileUtility.GetFileSize(filePath);
} }

View File

@@ -22,14 +22,14 @@ namespace YooAsset.Editor
{ {
List<IBuildTask> pipeline = new List<IBuildTask> List<IBuildTask> pipeline = new List<IBuildTask>
{ {
new TaskPrepare_RFBP(), //前期准备工作 new TaskPrepare_RFBP(),
new TaskGetBuildMap_RFBP(), //获取构建列表 new TaskGetBuildMap_RFBP(),
new TaskBuilding_RFBP(), //开始执行构建 new TaskBuilding_RFBP(),
new TaskUpdateBundleInfo_RFBP(), //更新资源包信息 new TaskUpdateBundleInfo_RFBP(),
new TaskCreateManifest_RFBP(), //创建清单文件 new TaskCreateManifest_RFBP(),
new TaskCreateReport_RFBP(), //创建报告文件 new TaskCreateReport_RFBP(),
new TaskCreatePackage_RFBP(), //制作包裹 new TaskCreatePackage_RFBP(),
new TaskCopyBuildinFiles_RFBP(), //拷贝内置文件 new TaskCopyBuildinFiles_RFBP(),
}; };
return pipeline; return pipeline;
} }

View File

@@ -8,7 +8,6 @@ using UnityEditor.Build.Pipeline.Tasks;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建内容打包")]
public class TaskBuilding_SBP : IBuildTask public class TaskBuilding_SBP : IBuildTask
{ {
public class BuildResultContext : IContextObject public class BuildResultContext : IContextObject
@@ -37,7 +36,8 @@ namespace YooAsset.Editor
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList); ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
if (exitCode < 0) if (exitCode < 0)
{ {
throw new Exception($"构建过程中发生错误 : {exitCode}"); string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, $"UnityEngine build failed ! ReturnCode : {exitCode}");
throw new Exception(message);
} }
// 创建着色器信息 // 创建着色器信息
@@ -49,7 +49,7 @@ namespace YooAsset.Editor
buildMapContext.CreateShadersBundleInfo(shadersBundleName); buildMapContext.CreateShadersBundleInfo(shadersBundleName);
} }
BuildLogger.Log("Unity引擎打包成功!"); BuildLogger.Log("UnityEngine build success!");
BuildResultContext buildResultContext = new BuildResultContext(); BuildResultContext buildResultContext = new BuildResultContext();
buildResultContext.Results = buildResults; buildResultContext.Results = buildResults;
context.SetContextObject(buildResultContext); context.SetContextObject(buildResultContext);

View File

@@ -6,7 +6,6 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("拷贝内置文件")]
public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask public class TaskCopyBuildinFiles_SBP : TaskCopyBuildinFiles, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -7,7 +7,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建清单文件")]
public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask public class TaskCreateManifest_SBP : TaskCreateManifest, IBuildTask
{ {
private TaskBuilding_SBP.BuildResultContext _buildResultContext = null; private TaskBuilding_SBP.BuildResultContext _buildResultContext = null;
@@ -23,7 +22,10 @@ namespace YooAsset.Editor
_buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>(); _buildResultContext = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false) if (_buildResultContext.Results.BundleInfos.ContainsKey(bundleName) == false)
throw new Exception($"Not found bundle in SBP build results : {bundleName}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleInBuildResult, $"Not found bundle in engine build result : {bundleName}");
throw new Exception(message);
}
return _buildResultContext.Results.BundleInfos[bundleName].Dependencies; return _buildResultContext.Results.BundleInfos[bundleName].Dependencies;
} }
} }

View File

@@ -3,7 +3,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("制作包裹")]
public class TaskCreatePackage_SBP : IBuildTask public class TaskCreatePackage_SBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -13,19 +12,19 @@ namespace YooAsset.Editor
var buildMode = buildParameters.Parameters.BuildMode; var buildMode = buildParameters.Parameters.BuildMode;
if (buildMode != EBuildMode.SimulateBuild) if (buildMode != EBuildMode.SimulateBuild)
{ {
CopyPackageFiles(buildParameters, buildMapContext); CreatePackageCatalog(buildParameters, buildMapContext);
} }
} }
/// <summary> /// <summary>
/// 拷贝补丁文件到补丁包目录 /// 拷贝补丁文件到补丁包目录
/// </summary> /// </summary>
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext) private void CreatePackageCatalog(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
{ {
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters; var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory(); string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory(); string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
BuildLogger.Log($"开始拷贝补丁文件到补丁包目录:{packageOutputDirectory}"); BuildLogger.Log($"Start making patch package: {packageOutputDirectory}");
// 拷贝构建日志 // 拷贝构建日志
{ {
@@ -48,7 +47,7 @@ namespace YooAsset.Editor
foreach (var bundleInfo in buildMapContext.Collection) foreach (var bundleInfo in buildMapContext.Collection)
{ {
EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true); EditorTools.CopyFile(bundleInfo.PackageSourceFilePath, bundleInfo.PackageDestFilePath, true);
EditorTools.DisplayProgressBar("拷贝补丁文件", ++progressValue, fileTotalCount); EditorTools.DisplayProgressBar("Copy patch file", ++progressValue, fileTotalCount);
} }
EditorTools.ClearProgressBar(); EditorTools.ClearProgressBar();
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("创建构建报告文件")]
public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask public class TaskCreateReport_SBP : TaskCreateReport, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using System.Collections.Generic;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源包加密")]
public class TaskEncryption_SBP : TaskEncryption, IBuildTask public class TaskEncryption_SBP : TaskEncryption, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -7,7 +7,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("获取资源构建内容")]
public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask public class TaskGetBuildMap_SBP : TaskGetBuildMap, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("资源构建准备工作")]
public class TaskPrepare_SBP : IBuildTask public class TaskPrepare_SBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -19,9 +18,15 @@ namespace YooAsset.Editor
// 检测不被支持的构建模式 // 检测不被支持的构建模式
if (buildParameters.BuildMode == EBuildMode.DryRunBuild) if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
throw new Exception(message);
}
if (buildParameters.BuildMode == EBuildMode.ForceRebuild) if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildPipelineNotSupportBuildMode, $"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
throw new Exception(message);
}
} }
} }
} }

View File

@@ -6,7 +6,6 @@ using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("更新资源包信息")]
public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask public class TaskUpdateBundleInfo_SBP : TaskUpdateBundleInfo, IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -28,9 +27,14 @@ namespace YooAsset.Editor
// 注意当资源包的依赖列表发生变化的时候ContentHash也会发生变化 // 注意当资源包的依赖列表发生变化的时候ContentHash也会发生变化
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>(); var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value)) if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
{
return value.Hash.ToString(); return value.Hash.ToString();
}
else else
throw new Exception($"Not found bundle hash in build result : {bundleInfo.BundleName}"); {
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleHash, $"Not found unity bundle hash : {bundleInfo.BundleName}");
throw new Exception(message);
}
} }
} }
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context) protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
@@ -46,32 +50,40 @@ namespace YooAsset.Editor
{ {
var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>(); var buildResult = context.GetContextObject<TaskBuilding_SBP.BuildResultContext>();
if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value)) if (buildResult.Results.BundleInfos.TryGetValue(bundleInfo.BundleName, out var value))
return value.Crc;
else
throw new Exception($"Not found bundle crc in build result : {bundleInfo.BundleName}");
}
}
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
{ {
return value.Crc;
}
else
{
string message = BuildLogger.GetErrorMessage(ErrorCode.NotFoundUnityBundleCRC, $"Not found unity bundle crc : {bundleInfo.BundleName}");
throw new Exception(message);
}
}
}
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return GetFilePathTempHash(filePath); return GetFilePathTempHash(filePath);
else else
return HashUtility.FileMD5(filePath); return HashUtility.FileMD5(filePath);
} }
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext) protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return "00000000"; //8位 return "00000000"; //8位
else else
return HashUtility.FileCRC32(filePath); return HashUtility.FileCRC32(filePath);
} }
protected override long GetBundleFileSize(string filePath, BuildParametersContext buildParametersContext) protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
{ {
string filePath = bundleInfo.PackageSourceFilePath;
var buildMode = buildParametersContext.Parameters.BuildMode; var buildMode = buildParametersContext.Parameters.BuildMode;
if (buildMode == EBuildMode.SimulateBuild) if (buildMode == EBuildMode.SimulateBuild)
return 0; return GetBundleTempSize(bundleInfo);
else else
return FileUtility.GetFileSize(filePath); return FileUtility.GetFileSize(filePath);
} }

View File

@@ -9,7 +9,6 @@ using UnityEditor.Build.Pipeline.Interfaces;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
[TaskAttribute("验证构建结果")]
public class TaskVerifyBuildResult_SBP : IBuildTask public class TaskVerifyBuildResult_SBP : IBuildTask
{ {
void IBuildTask.Run(BuildContext context) void IBuildTask.Run(BuildContext context)
@@ -47,9 +46,12 @@ namespace YooAsset.Editor
{ {
foreach (var exceptBundle in exceptBundleList1) foreach (var exceptBundle in exceptBundleList1)
{ {
BuildLogger.Warning($"差异资源包: {exceptBundle}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
BuildLogger.Warning(warning);
} }
throw new System.Exception("存在差异资源包!请查看警告信息!");
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
} }
// 3. 验证Bundle // 3. 验证Bundle
@@ -58,12 +60,15 @@ namespace YooAsset.Editor
{ {
foreach (var exceptBundle in exceptBundleList2) foreach (var exceptBundle in exceptBundleList2)
{ {
BuildLogger.Warning($"差异资源包: {exceptBundle}"); string warning = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildBundle, $"Found unintended build bundle : {exceptBundle}");
} BuildLogger.Warning(warning);
throw new System.Exception("存在差异资源包!请查看警告信息!");
} }
BuildLogger.Log("构建结果验证成功!"); string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
throw new Exception(exception);
}
BuildLogger.Log("Build results verify success!");
} }
} }
} }

View File

@@ -1,70 +0,0 @@
using System.Collections.Generic;
using UnityEditor.Build.Content;
using UnityEngine.U2D;
using UnityEditor.Build.Pipeline.Injector;
using UnityEditor.Build.Pipeline.Interfaces;
using UnityEngine;
using System.Linq;
namespace UnityEditor.Build.Pipeline.Tasks
{
/// <summary>
/// Ref https://zhuanlan.zhihu.com/p/586918159
/// </summary>
public class RemoveSpriteAtlasRedundancy : IBuildTask
{
/// <inheritdoc />
public int Version => 1;
[InjectContext]
IBundleWriteData writeDataParam;
/// <inheritdoc />
public ReturnCode Run()
{
BundleWriteData writeData = (BundleWriteData)writeDataParam;
// 所有图集散图的 guid 集合
HashSet<GUID> spriteGuids = new HashSet<GUID>();
// 遍历资源包里的资源记录其中图集的散图 guid
foreach (var pair in writeData.FileToObjects)
{
foreach (ObjectIdentifier objectIdentifier in pair.Value)
{
string path = AssetDatabase.GUIDToAssetPath(objectIdentifier.guid);
Object asset = AssetDatabase.LoadAssetAtPath<Object>(path);
if (asset is SpriteAtlas)
{
List<string> spritePaths = AssetDatabase.GetDependencies(path, false).ToList();
foreach (string spritePath in spritePaths)
{
GUID spriteGuild = AssetDatabase.GUIDFromAssetPath(spritePath);
spriteGuids.Add(spriteGuild);
}
}
}
}
// 将 writeData.FileToObjects 包含的图集散图的 texture 删掉避免冗余
foreach (var pair in writeData.FileToObjects)
{
List<ObjectIdentifier> objectIdentifiers = pair.Value;
for (int i = objectIdentifiers.Count - 1; i >= 0; i--)
{
ObjectIdentifier objectIdentifier = objectIdentifiers[i];
if (spriteGuids.Contains(objectIdentifier.guid))
{
if (objectIdentifier.localIdentifierInFile == 2800000)
{
// 删除图集散图的冗余 texture
objectIdentifiers.RemoveAt(i);
}
}
}
}
return ReturnCode.Success;
}
}
}

View File

@@ -33,7 +33,6 @@ namespace UnityEditor.Build.Pipeline.Tasks
// Packing // Packing
buildTasks.Add(new GenerateBundlePacking()); buildTasks.Add(new GenerateBundlePacking());
buildTasks.Add(new RemoveSpriteAtlasRedundancy()); // Fix for SpriteAtlas Redundancy
buildTasks.Add(new UpdateBundleObjectLayout()); buildTasks.Add(new UpdateBundleObjectLayout());
buildTasks.Add(new GenerateBundleCommands()); buildTasks.Add(new GenerateBundleCommands());
buildTasks.Add(new GenerateSubAssetPathMaps()); buildTasks.Add(new GenerateSubAssetPathMaps());

View File

@@ -1,9 +1,6 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using UnityEditor;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
@@ -22,15 +19,16 @@ namespace YooAsset.Editor
{ {
List<IBuildTask> pipeline = new List<IBuildTask> List<IBuildTask> pipeline = new List<IBuildTask>
{ {
new TaskPrepare_SBP(), //前期准备工作 new TaskPrepare_SBP(),
new TaskGetBuildMap_SBP(), //获取构建列表 new TaskGetBuildMap_SBP(),
new TaskBuilding_SBP(), //开始执行构建 new TaskBuilding_SBP(),
new TaskVerifyBuildResult_SBP(), //验证构建结果 new TaskVerifyBuildResult_SBP(),
new TaskUpdateBundleInfo_SBP(), //更新补丁信息 new TaskEncryption_SBP(),
new TaskCreateManifest_SBP(), //创建清单文件 new TaskUpdateBundleInfo_SBP(),
new TaskCreateReport_SBP(), //创建报告文件 new TaskCreateManifest_SBP(),
new TaskCreatePackage_SBP(), //制作补丁包 new TaskCreateReport_SBP(),
new TaskCopyBuildinFiles_SBP(), //拷贝内置文件 new TaskCreatePackage_SBP(),
new TaskCopyBuildinFiles_SBP(),
}; };
return pipeline; return pipeline;
} }

View File

@@ -5,7 +5,7 @@ using UnityEngine;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
public static class BuildLogger internal static class BuildLogger
{ {
private static bool _enableLog = true; private static bool _enableLog = true;
@@ -29,5 +29,10 @@ namespace YooAsset.Editor
{ {
Debug.LogError(message); Debug.LogError(message);
} }
public static string GetErrorMessage(ErrorCode code, string message)
{
return $"[ErrorCode{(int)code}] {message}";
}
} }
} }

View File

@@ -36,17 +36,15 @@ namespace YooAsset.Editor
try try
{ {
_buildWatch = Stopwatch.StartNew(); _buildWatch = Stopwatch.StartNew();
var taskAttribute = task.GetType().GetCustomAttribute<TaskAttribute>(); string taskName = task.GetType().Name.Split('_')[0];
if (taskAttribute != null) BuildLogger.Log($"--------------------------------------------->{taskName}<--------------------------------------------");
BuildLogger.Log($"---------------------------------------->{taskAttribute.TaskDesc}<---------------------------------------");
task.Run(context); task.Run(context);
_buildWatch.Stop(); _buildWatch.Stop();
// 统计耗时 // 统计耗时
int seconds = GetBuildSeconds(); int seconds = GetBuildSeconds();
TotalSeconds += seconds; TotalSeconds += seconds;
if (taskAttribute != null) BuildLogger.Log($"{taskName} It takes {seconds} seconds in total");
BuildLogger.Log($"{taskAttribute.TaskDesc}耗时:{seconds}秒");
} }
catch (Exception e) catch (Exception e)
{ {
@@ -59,7 +57,7 @@ namespace YooAsset.Editor
} }
// 返回运行结果 // 返回运行结果
BuildLogger.Log($"构建过程总计耗时:{TotalSeconds}"); BuildLogger.Log($"Total build process time: {TotalSeconds} seconds");
return buildResult; return buildResult;
} }

View File

@@ -0,0 +1,42 @@

namespace YooAsset.Editor
{
internal enum ErrorCode
{
// TaskPrepare
ThePipelineIsBuiding = 100,
FoundUnsavedScene = 101,
NoBuildTarget = 110,
PackageNameIsNullOrEmpty = 111,
PackageVersionIsNullOrEmpty = 112,
BuildOutputRootIsNullOrEmpty = 113,
BuildinFileRootIsNullOrEmpty = 114,
PackageOutputDirectoryExists = 115,
RecommendScriptBuildPipeline = 130,
BuildPipelineNotSupportBuildMode = 140,
// TaskGetBuildMap
RemoveInvalidTags = 200,
FoundUndependedAsset = 201,
PackAssetListIsEmpty = 202,
NotSupportMultipleRawAsset = 210,
// TaskBuilding
UnityEngineBuildFailed = 300,
UnityEngineBuildFatal = 301,
// TaskUpdateBundleInfo
CharactersOverTheLimit = 400,
NotFoundUnityBundleHash = 401,
NotFoundUnityBundleCRC = 402,
BundleTempSizeIsZero = 403,
// TaskVerifyBuildResult
UnintendedBuildBundle = 500,
UnintendedBuildResult = 501,
// TaskCreateManifest
NotFoundUnityBundleInBuildResult = 600,
FoundStrayBundle = 601,
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 7fbb7b27f54d3b0439a951348fd9d785 guid: c3a10fd19801c0c428bac53081a96517
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -1,18 +0,0 @@
using System;
namespace YooAsset.Editor
{
[AttributeUsage(AttributeTargets.Class)]
public class TaskAttribute : Attribute
{
/// <summary>
/// 任务说明
/// </summary>
public string TaskDesc;
public TaskAttribute(string taskDesc)
{
TaskDesc = taskDesc;
}
}
}

View File

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

View File

@@ -39,7 +39,7 @@ namespace YooAsset.Editor
} }
private void CreateView(VisualElement parent) private void CreateView(VisualElement parent)
{ {
// <20><><EFBFBD>ز<EFBFBD><D8B2><EFBFBD><EFBFBD>ļ<EFBFBD> // 加载布局文件
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>(); var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
if (visualAsset == null) if (visualAsset == null)
return; return;
@@ -48,18 +48,18 @@ namespace YooAsset.Editor
Root.style.flexGrow = 1f; Root.style.flexGrow = 1f;
parent.Add(Root); parent.Add(Root);
// <20><><EFBFBD><EFBFBD>Ŀ¼ // 输出目录
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot(); string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
_buildOutputField = Root.Q<TextField>("BuildOutput"); _buildOutputField = Root.Q<TextField>("BuildOutput");
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot); _buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
_buildOutputField.SetEnabled(false); _buildOutputField.SetEnabled(false);
// <20><><EFBFBD><EFBFBD><EFBFBD> // 构建版本
_buildVersionField = Root.Q<TextField>("BuildVersion"); _buildVersionField = Root.Q<TextField>("BuildVersion");
_buildVersionField.style.width = StyleWidth; _buildVersionField.style.width = StyleWidth;
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion()); _buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
// <20><><EFBFBD><EFBFBD>ģʽ // 构建模式
{ {
var buildModeContainer = Root.Q("BuildModeContainer"); var buildModeContainer = Root.Q("BuildModeContainer");
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline); var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
@@ -75,7 +75,7 @@ namespace YooAsset.Editor
buildModeContainer.Add(_buildModeField); buildModeContainer.Add(_buildModeField);
} }
// <20><><EFBFBD>ܷ<EFBFBD><DCB7><EFBFBD> // 加密方法
{ {
var encryptionContainer = Root.Q("EncryptionContainer"); var encryptionContainer = Root.Q("EncryptionContainer");
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices)); var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
@@ -101,7 +101,7 @@ namespace YooAsset.Editor
} }
} }
// ѹ<><D1B9><EFBFBD><EFBFBD>ʽѡ<CABD><D1A1> // 压缩方式选项
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline); var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
_compressionField = Root.Q<EnumField>("Compression"); _compressionField = Root.Q<EnumField>("Compression");
_compressionField.Init(compressOption); _compressionField.Init(compressOption);
@@ -112,7 +112,7 @@ namespace YooAsset.Editor
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value); AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
}); });
// <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ // 输出文件名称样式
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline); var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle"); _outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
_outputNameStyleField.Init(fileNameStyle); _outputNameStyleField.Init(fileNameStyle);
@@ -123,7 +123,7 @@ namespace YooAsset.Editor
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value); AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
}); });
// <20>װ<EFBFBD><D7B0>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1> // 首包文件拷贝选项
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline); var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption"); _copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
_copyBuildinFileOptionField.Init(buildinFileCopyOption); _copyBuildinFileOptionField.Init(buildinFileCopyOption);
@@ -135,16 +135,16 @@ namespace YooAsset.Editor
RefreshView(); RefreshView();
}); });
// <20>װ<EFBFBD><D7B0>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> // 首包文件拷贝参数
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline); var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileTags"); _copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams); _copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt => _copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
{ {
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value); AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
}); });
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ť // 构建按钮
var buildButton = Root.Q<Button>("Build"); var buildButton = Root.Q<Button>("Build");
buildButton.clicked += BuildButton_clicked; buildButton.clicked += BuildButton_clicked;
} }
@@ -157,29 +157,29 @@ namespace YooAsset.Editor
private void BuildButton_clicked() private void BuildButton_clicked()
{ {
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline); var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
if (EditorUtility.DisplayDialog("<EFBFBD><EFBFBD>ʾ", $"ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<EFBFBD><EFBFBD>{buildMode}<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "Yes", "No")) if (EditorUtility.DisplayDialog("提示", $"通过构建模式【{buildMode}】来构建!", "Yes", "No"))
{ {
EditorTools.ClearUnityConsole(); EditorTools.ClearUnityConsole();
EditorApplication.delayCall += ExecuteBuild; EditorApplication.delayCall += ExecuteBuild;
} }
else else
{ {
Debug.LogWarning("[Build] <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>ȡ<EFBFBD><EFBFBD>"); Debug.LogWarning("[Build] 打包已经取消");
} }
} }
/// <summary> /// <summary>
/// ִ<>й<EFBFBD><D0B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> /// 执行构建任务
/// </summary> /// </summary>
protected abstract void ExecuteBuild(); protected abstract void ExecuteBuild();
/// <summary> /// <summary>
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֧<EFBFBD>ֵĹ<D6B5><C4B9><EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD> /// 获取构建管线支持的构建模式集合
/// </summary> /// </summary>
protected abstract List<Enum> GetSupportBuildModes(); protected abstract List<Enum> GetSupportBuildModes();
/// <summary> /// <summary>
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD> /// 获取构建版本
/// </summary> /// </summary>
protected string GetPackageVersion() protected string GetPackageVersion()
{ {
@@ -187,7 +187,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><CAB5> /// 创建加密类实例
/// </summary> /// </summary>
protected IEncryptionServices CreateEncryptionInstance() protected IEncryptionServices CreateEncryptionInstance()
{ {

View File

@@ -7,8 +7,8 @@
<uie:EnumField label="Compression" value="Center" name="Compression" /> <uie:EnumField label="Compression" value="Center" name="Compression" />
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" /> <uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" /> <uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Tags" name="CopyBuildinFileTags" /> <ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
<ui:VisualElement name="ExtensionContainer" /> <ui:VisualElement name="ExtensionContainer" />
<ui:Button text="构建" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" /> <ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -148,18 +148,29 @@ namespace YooAsset.Editor
Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000); Dictionary<string, CollectAssetInfo> result = new Dictionary<string, CollectAssetInfo>(1000);
// 收集打包资源 // 收集打包资源路径
List<string> findAssets =new List<string>();
if (AssetDatabase.IsValidFolder(CollectPath)) if (AssetDatabase.IsValidFolder(CollectPath))
{ {
string collectDirectory = CollectPath; string collectDirectory = CollectPath;
string[] findAssets = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory); string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
findAssets.AddRange(findResult);
}
else
{
string assetPath = CollectPath;
findAssets.Add(assetPath);
}
// 收集打包资源信息
foreach (string assetPath in findAssets) foreach (string assetPath in findAssets)
{ {
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath)) var assetInfo = new AssetInfo(assetPath);
if (IsValidateAsset(command, assetInfo) && IsCollectAsset(group, assetInfo))
{ {
if (result.ContainsKey(assetPath) == false) if (result.ContainsKey(assetPath) == false)
{ {
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath); var collectAssetInfo = CreateCollectAssetInfo(command, group, assetInfo);
result.Add(assetPath, collectAssetInfo); result.Add(assetPath, collectAssetInfo);
} }
else else
@@ -168,20 +179,6 @@ namespace YooAsset.Editor
} }
} }
} }
}
else
{
string assetPath = CollectPath;
if (IsValidateAsset(command, assetPath) && IsCollectAsset(group, assetPath))
{
var collectAssetInfo = CreateCollectAssetInfo(command, group, assetPath);
result.Add(assetPath, collectAssetInfo);
}
else
{
throw new Exception($"The collecting single asset file is invalid : {assetPath} in collector : {CollectPath}");
}
}
// 检测可寻址地址是否重复 // 检测可寻址地址是否重复
if (command.EnableAddressable) if (command.EnableAddressable)
@@ -192,7 +189,7 @@ namespace YooAsset.Editor
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector) if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{ {
string address = collectInfoPair.Value.Address; string address = collectInfoPair.Value.Address;
string assetPath = collectInfoPair.Value.AssetPath; string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address)) if (string.IsNullOrEmpty(address))
continue; continue;
@@ -211,61 +208,64 @@ namespace YooAsset.Editor
return result.Values.ToList(); return result.Values.ToList();
} }
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, string assetPath)
/// <summary>
/// 创建资源收集类
/// </summary>
private CollectAssetInfo CreateCollectAssetInfo(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{ {
string address = GetAddress(command, group, assetPath); string address = GetAddress(command, group, assetInfo);
string bundleName = GetBundleName(command, group, assetPath); string bundleName = GetBundleName(command, group, assetInfo);
List<string> assetTags = GetAssetTags(group); List<string> assetTags = GetAssetTags(group);
CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetPath, assetTags); CollectAssetInfo collectAssetInfo = new CollectAssetInfo(CollectorType, bundleName, address, assetInfo, assetTags);
// 注意:模拟构建模式下不需要收集依赖资源 // 注意:模拟构建模式下不需要收集依赖资源
if (command.BuildMode == EBuildMode.SimulateBuild) if (command.BuildMode == EBuildMode.SimulateBuild)
collectAssetInfo.DependAssets = new List<string>(); collectAssetInfo.DependAssets = new List<AssetInfo>();
else else
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath); collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
return collectAssetInfo; return collectAssetInfo;
} }
private bool IsValidateAsset(CollectCommand command, string assetPath)
private bool IsValidateAsset(CollectCommand command, AssetInfo assetInfo)
{ {
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false) if (assetInfo.AssetPath.StartsWith("Assets/") == false && assetInfo.AssetPath.StartsWith("Packages/") == false)
{ {
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}"); UnityEngine.Debug.LogError($"Invalid asset path : {assetInfo.AssetPath}");
return false; return false;
} }
// 忽略文件夹 // 忽略文件夹
if (AssetDatabase.IsValidFolder(assetPath)) if (AssetDatabase.IsValidFolder(assetInfo.AssetPath))
return false; return false;
// 忽略编辑器下的类型资源 // 忽略编辑器下的类型资源
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); if (assetInfo.AssetType == typeof(LightingDataAsset))
if (assetType == typeof(LightingDataAsset))
return false; return false;
// 忽略Unity引擎无法识别的文件 // 忽略Unity引擎无法识别的文件
if (command.IgnoreDefaultType) if (command.IgnoreDefaultType)
{ {
if (assetType == typeof(UnityEditor.DefaultAsset)) if (assetInfo.AssetType == typeof(UnityEditor.DefaultAsset))
{ {
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}"); UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetInfo.AssetPath}");
return false; return false;
} }
} }
string fileExtension = System.IO.Path.GetExtension(assetPath); if (DefaultFilterRule.IsIgnoreFile(assetInfo.FileExtension))
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
return false; return false;
return true; return true;
} }
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath) private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
{ {
// 根据规则设置过滤资源文件 // 根据规则设置过滤资源文件
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName); IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetPath, CollectPath, group.GroupName, UserData)); return filterRuleInstance.IsCollectAsset(new FilterRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
} }
private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, string assetPath) private string GetAddress(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{ {
if (command.EnableAddressable == false) if (command.EnableAddressable == false)
return string.Empty; return string.Empty;
@@ -274,15 +274,14 @@ namespace YooAsset.Editor
return string.Empty; return string.Empty;
IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName); IAddressRule addressRuleInstance = AssetBundleCollectorSettingData.GetAddressRuleInstance(AddressRuleName);
string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetPath, CollectPath, group.GroupName, UserData)); string adressValue = addressRuleInstance.GetAssetAddress(new AddressRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
return adressValue; return adressValue;
} }
private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, string assetPath) private string GetBundleName(CollectCommand command, AssetBundleCollectorGroup group, AssetInfo assetInfo)
{ {
if (command.AutoCollectShaders) if (command.AutoCollectShaders)
{ {
System.Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath); if (assetInfo.IsShaderAsset())
if (assetType == typeof(UnityEngine.Shader) || assetType == typeof(UnityEngine.ShaderVariantCollection))
{ {
// 获取着色器打包规则结果 // 获取着色器打包规则结果
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult(); PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
@@ -292,7 +291,7 @@ namespace YooAsset.Editor
// 获取其它资源打包规则结果 // 获取其它资源打包规则结果
IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName); IPackRule packRuleInstance = AssetBundleCollectorSettingData.GetPackRuleInstance(PackRuleName);
PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetPath, CollectPath, group.GroupName, UserData)); PackRuleResult defaultPackRuleResult = packRuleInstance.GetPackRuleResult(new PackRuleData(assetInfo.AssetPath, CollectPath, group.GroupName, UserData));
return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName); return defaultPackRuleResult.GetBundleName(command.PackageName, command.UniqueBundleName);
} }
private List<string> GetAssetTags(AssetBundleCollectorGroup group) private List<string> GetAssetTags(AssetBundleCollectorGroup group)
@@ -302,18 +301,19 @@ namespace YooAsset.Editor
tags.AddRange(temper); tags.AddRange(temper);
return tags; return tags;
} }
private List<string> GetAllDependencies(CollectCommand command, string mainAssetPath) private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
{ {
string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true); string[] depends = AssetDatabase.GetDependencies(mainAssetPath, true);
List<string> result = new List<string>(depends.Length); List<AssetInfo> result = new List<AssetInfo>(depends.Length);
foreach (string assetPath in depends) foreach (string assetPath in depends)
{ {
// 注意:排除主资源对象 // 注意:排除主资源对象
if (assetPath == mainAssetPath) if (assetPath == mainAssetPath)
continue; continue;
if (IsValidateAsset(command, assetPath)) AssetInfo assetInfo = new AssetInfo(assetPath);
result.Add(assetPath); if (IsValidateAsset(command, assetInfo))
result.Add(assetInfo);
} }
return result; return result;
} }

View File

@@ -174,7 +174,7 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName; AssetBundleCollectorSettingData.Setting.UniqueBundleName = uniqueBundleName;
AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages); AssetBundleCollectorSettingData.Setting.Packages.AddRange(packages);
AssetBundleCollectorSettingData.SaveFile(); AssetBundleCollectorSettingData.SaveFile();
Debug.Log($"导入配置完毕"); Debug.Log($"Asset bundle collector config import complete");
} }
/// <summary> /// <summary>
@@ -245,7 +245,7 @@ namespace YooAsset.Editor
// 生成配置文件 // 生成配置文件
xmlDoc.Save(savePath); xmlDoc.Save(savePath);
Debug.Log($"导出配置完毕"); Debug.Log($"Asset bundle collector config export complete");
} }
/// <summary> /// <summary>

View File

@@ -44,6 +44,11 @@ namespace YooAsset.Editor
if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false) if (AssetBundleCollectorSettingData.HasActiveRuleName(ActiveRuleName) == false)
throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}"); throw new Exception($"Invalid {nameof(IActiveRule)} class type : {ActiveRuleName} in group : {GroupName}");
// 检测分组是否激活
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
if (activeRule.IsActiveGroup() == false)
return;
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
collector.CheckConfigError(); collector.CheckConfigError();
@@ -84,12 +89,12 @@ namespace YooAsset.Editor
foreach (var collector in Collectors) foreach (var collector in Collectors)
{ {
var temper = collector.GetAllCollectAssets(command, this); var temper = collector.GetAllCollectAssets(command, this);
foreach (var assetInfo in temper) foreach (var collectAsset in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
result.Add(assetInfo.AssetPath, assetInfo); result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
else else
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath} in group : {GroupName}"); throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath} in group : {GroupName}");
} }
} }
@@ -97,12 +102,12 @@ namespace YooAsset.Editor
if (command.EnableAddressable) if (command.EnableAddressable)
{ {
var addressTemper = new Dictionary<string, string>(); var addressTemper = new Dictionary<string, string>();
foreach (var collectInfoPair in result) foreach (var collectAssetPair in result)
{ {
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector) if (collectAssetPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{ {
string address = collectInfoPair.Value.Address; string address = collectAssetPair.Value.Address;
string assetPath = collectInfoPair.Value.AssetPath; string assetPath = collectAssetPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address)) if (string.IsNullOrEmpty(address))
continue; continue;

View File

@@ -89,12 +89,12 @@ namespace YooAsset.Editor
foreach (var group in Groups) foreach (var group in Groups)
{ {
var temper = group.GetAllCollectAssets(command); var temper = group.GetAllCollectAssets(command);
foreach (var assetInfo in temper) foreach (var collectAsset in temper)
{ {
if (result.ContainsKey(assetInfo.AssetPath) == false) if (result.ContainsKey(collectAsset.AssetInfo.AssetPath) == false)
result.Add(assetInfo.AssetPath, assetInfo); result.Add(collectAsset.AssetInfo.AssetPath, collectAsset);
else else
throw new Exception($"The collecting asset file is existed : {assetInfo.AssetPath}"); throw new Exception($"The collecting asset file is existed : {collectAsset.AssetInfo.AssetPath}");
} }
} }
@@ -107,7 +107,7 @@ namespace YooAsset.Editor
if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector) if (collectInfoPair.Value.CollectorType == ECollectorType.MainAssetCollector)
{ {
string address = collectInfoPair.Value.Address; string address = collectInfoPair.Value.Address;
string assetPath = collectInfoPair.Value.AssetPath; string assetPath = collectInfoPair.Value.AssetInfo.AssetPath;
if (string.IsNullOrEmpty(address)) if (string.IsNullOrEmpty(address))
continue; continue;

View File

@@ -92,7 +92,6 @@ namespace YooAsset.Editor
List<Type> types = new List<Type>(100) List<Type> types = new List<Type>(100)
{ {
typeof(AddressByFileName), typeof(AddressByFileName),
typeof(AddressByFilePath),
typeof(AddressByFolderAndFileName), typeof(AddressByFolderAndFileName),
typeof(AddressByGroupAndFileName), typeof(AddressByGroupAndFileName),
typeof(AddressDisable) typeof(AddressDisable)
@@ -266,7 +265,7 @@ namespace YooAsset.Editor
} }
else else
{ {
throw new Exception($"{nameof(IActiveRule)}类型无效{ruleName}"); throw new Exception($"{nameof(IActiveRule)} is invalid{ruleName}");
} }
} }
public static IAddressRule GetAddressRuleInstance(string ruleName) public static IAddressRule GetAddressRuleInstance(string ruleName)
@@ -283,7 +282,7 @@ namespace YooAsset.Editor
} }
else else
{ {
throw new Exception($"{nameof(IAddressRule)}类型无效{ruleName}"); throw new Exception($"{nameof(IAddressRule)} is invalid{ruleName}");
} }
} }
public static IPackRule GetPackRuleInstance(string ruleName) public static IPackRule GetPackRuleInstance(string ruleName)
@@ -300,7 +299,7 @@ namespace YooAsset.Editor
} }
else else
{ {
throw new Exception($"{nameof(IPackRule)}类型无效{ruleName}"); throw new Exception($"{nameof(IPackRule)} is invalid{ruleName}");
} }
} }
public static IFilterRule GetFilterRuleInstance(string ruleName) public static IFilterRule GetFilterRuleInstance(string ruleName)
@@ -317,7 +316,7 @@ namespace YooAsset.Editor
} }
else else
{ {
throw new Exception($"{nameof(IFilterRule)}类型无效{ruleName}"); throw new Exception($"{nameof(IFilterRule)} is invalid{ruleName}");
} }
} }

View File

@@ -14,7 +14,7 @@ namespace YooAsset.Editor
[MenuItem("YooAsset/AssetBundle Collector", false, 101)] [MenuItem("YooAsset/AssetBundle Collector", false, 101)]
public static void OpenWindow() public static void OpenWindow()
{ {
AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("资源包收集工具", true, WindowsDefine.DockedWindowTypes); AssetBundleCollectorWindow window = GetWindow<AssetBundleCollectorWindow>("AssetBundle Collector", true, WindowsDefine.DockedWindowTypes);
window.minSize = new Vector2(800, 600); window.minSize = new Vector2(800, 600);
} }
@@ -51,7 +51,7 @@ namespace YooAsset.Editor
private ListView _groupListView; private ListView _groupListView;
private TextField _groupNameTxt; private TextField _groupNameTxt;
private TextField _groupDescTxt; private TextField _groupDescTxt;
private TextField _groupAssetTagsTxt; private TextField _groupTagsTxt;
private VisualElement _collectorContainer; private VisualElement _collectorContainer;
private ScrollView _collectorScrollView; private ScrollView _collectorScrollView;
@@ -65,9 +65,6 @@ namespace YooAsset.Editor
public void CreateGUI() public void CreateGUI()
{ {
Undo.undoRedoPerformed -= RefreshWindow;
Undo.undoRedoPerformed += RefreshWindow;
try try
{ {
_collectorTypeList = new List<string>() _collectorTypeList = new List<string>()
@@ -106,7 +103,7 @@ namespace YooAsset.Editor
AssetBundleCollectorSettingData.ModifyShowPackageView(evt.newValue); AssetBundleCollectorSettingData.ModifyShowPackageView(evt.newValue);
RefreshWindow(); RefreshWindow();
}); });
_showEditorAliasToggle = root.Q<Toggle>("ShowEditorAlias"); _showEditorAliasToggle = root.Q<Toggle>("ShowRuleAlias");
_showEditorAliasToggle.RegisterValueChangedCallback(evt => _showEditorAliasToggle.RegisterValueChangedCallback(evt =>
{ {
AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue); AssetBundleCollectorSettingData.ModifyShowEditorAlias(evt.newValue);
@@ -290,8 +287,8 @@ namespace YooAsset.Editor
}); });
// 分组的资源标签 // 分组的资源标签
_groupAssetTagsTxt = root.Q<TextField>("GroupAssetTags"); _groupTagsTxt = root.Q<TextField>("GroupTags");
_groupAssetTagsTxt.RegisterValueChangedCallback(evt => _groupTagsTxt.RegisterValueChangedCallback(evt =>
{ {
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage; var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup; var selectGroup = _groupListView.selectedItem as AssetBundleCollectorGroup;
@@ -320,7 +317,7 @@ namespace YooAsset.Editor
// 分组激活规则 // 分组激活规则
var activeRuleContainer = root.Q("ActiveRuleContainer"); var activeRuleContainer = root.Q("ActiveRuleContainer");
{ {
_activeRulePopupField = new PopupField<RuleDisplayName>("Active Rule", _activeRuleList, 0); _activeRulePopupField = new PopupField<RuleDisplayName>("Group Active", _activeRuleList, 0);
_activeRulePopupField.name = "ActiveRuleMaskField"; _activeRulePopupField.name = "ActiveRuleMaskField";
_activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft; _activeRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
_activeRulePopupField.formatListItemCallback = FormatListItemCallback; _activeRulePopupField.formatListItemCallback = FormatListItemCallback;
@@ -347,6 +344,15 @@ namespace YooAsset.Editor
Debug.LogError(e.ToString()); Debug.LogError(e.ToString());
} }
} }
public void OnEnable()
{
Undo.undoRedoPerformed += RefreshWindow;
}
public void OnDisable()
{
if (Undo.undoRedoPerformed != null)
Undo.undoRedoPerformed -= RefreshWindow;
}
public void OnDestroy() public void OnDestroy()
{ {
// 注意:清空所有撤销操作 // 注意:清空所有撤销操作
@@ -463,8 +469,9 @@ namespace YooAsset.Editor
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage; var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
if (selectPackage != null) if (selectPackage != null)
{ {
string packageSettingName = "Package Settings";
_packageSettingsButton.SetEnabled(true); _packageSettingsButton.SetEnabled(true);
_packageSettingsButton.text = $"Package Setting ({selectPackage.PackageName})"; _packageSettingsButton.text = $"{packageSettingName} ({selectPackage.PackageName})";
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable); _enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower); _locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID); _includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
@@ -496,13 +503,15 @@ namespace YooAsset.Editor
if (_enableAddressableToogle.value && _locationToLowerToogle.value) if (_enableAddressableToogle.value && _locationToLowerToogle.value)
{ {
var helpBox = new HelpBox("无法同时开启[Enable Addressable]选项和[Location To Lower]选项", HelpBoxMessageType.Error); string tips = "The [Enable Addressable] option and [Location To Lower] option cannot be enabled at the same time.";
var helpBox = new HelpBox(tips, HelpBoxMessageType.Error);
_helpBoxContainer.Add(helpBox); _helpBoxContainer.Add(helpBox);
} }
if (AssetBundleCollectorSettingData.Setting.Packages.Count > 1 && _uniqueBundleNameToogle.value == false) if (AssetBundleCollectorSettingData.Setting.Packages.Count > 1 && _uniqueBundleNameToogle.value == false)
{ {
var helpBox = new HelpBox("检测到当前配置存在多个Package建议开启[Unique Bundle Name]选项", HelpBoxMessageType.Warning); string tips = "There are multiple Packages in the current config, Recommended to enable the [Unique Bundle Name] option.";
var helpBox = new HelpBox(tips, HelpBoxMessageType.Warning);
_helpBoxContainer.Add(helpBox); _helpBoxContainer.Add(helpBox);
} }
@@ -654,7 +663,7 @@ namespace YooAsset.Editor
_activeRulePopupField.SetValueWithoutNotify(GetActiveRuleIndex(selectGroup.ActiveRuleName)); _activeRulePopupField.SetValueWithoutNotify(GetActiveRuleIndex(selectGroup.ActiveRuleName));
_groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName); _groupNameTxt.SetValueWithoutNotify(selectGroup.GroupName);
_groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc); _groupDescTxt.SetValueWithoutNotify(selectGroup.GroupDesc);
_groupAssetTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags); _groupTagsTxt.SetValueWithoutNotify(selectGroup.AssetTags);
FillCollectorViewData(); FillCollectorViewData();
} }
@@ -787,7 +796,7 @@ namespace YooAsset.Editor
{ {
var textField = new TextField(); var textField = new TextField();
textField.name = "TextField1"; textField.name = "TextField1";
textField.label = "Tags"; textField.label = "Asset Tags";
textField.style.width = 100; textField.style.width = 100;
textField.style.marginLeft = 20; textField.style.marginLeft = 20;
textField.style.flexGrow = 1; textField.style.flexGrow = 1;
@@ -988,15 +997,15 @@ namespace YooAsset.Editor
if (collectAssetInfos != null) if (collectAssetInfos != null)
{ {
foreach (var collectAssetInfo in collectAssetInfos) foreach (var collectAsset in collectAssetInfos)
{ {
VisualElement elementRow = new VisualElement(); VisualElement elementRow = new VisualElement();
elementRow.style.flexDirection = FlexDirection.Row; elementRow.style.flexDirection = FlexDirection.Row;
foldout.Add(elementRow); foldout.Add(elementRow);
string showInfo = collectAssetInfo.AssetPath; string showInfo = collectAsset.AssetInfo.AssetPath;
if (_enableAddressableToogle.value) if (_enableAddressableToogle.value)
showInfo = $"[{collectAssetInfo.Address}] {collectAssetInfo.AssetPath}"; showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
var label = new Label(); var label = new Label();
label.text = showInfo; label.text = showInfo;

View File

@@ -1,23 +1,23 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;"> <uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row-reverse;">
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
<ui:Button text="修复" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Fix" display-tooltip-when-elided="true" name="FixButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar> </uie:Toolbar>
<ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); flex-direction: column; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;"> <ui:VisualElement name="PublicContainer" style="background-color: rgb(79, 79, 79); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
<ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" /> <ui:VisualElement name="HelpBoxContainer" style="flex-grow: 1;" />
<ui:VisualElement name="GlobalSettingsContainer"> <ui:VisualElement name="GlobalSettingsContainer">
<ui:Button text="Global Settings" name="GlobalSettingsButton" /> <ui:Button text="Global Settings" name="GlobalSettingsButton" />
<ui:VisualElement name="PublicContainer1" style="flex-direction: row; flex-wrap: nowrap; height: 28px;"> <ui:VisualElement name="PublicContainer1">
<ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Show Packages" name="ShowPackages" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Show Editor Alias" name="ShowEditorAlias" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Show Rule Alias" name="ShowRuleAlias" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Unique Bundle Name" name="UniqueBundleName" style="width: 196px; -unity-text-align: middle-left;" />
</ui:VisualElement> </ui:VisualElement>
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="PackageSettingsContainer"> <ui:VisualElement name="PackageSettingsContainer">
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" /> <ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
<ui:VisualElement name="PublicContainer2" style="flex-direction: row; flex-wrap: nowrap; height: 28px;"> <ui:VisualElement name="PublicContainer2">
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" /> <ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
@@ -50,7 +50,7 @@
<ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" /> <ui:VisualElement name="ActiveRuleContainer" style="height: 20px;" />
<ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" /> <ui:TextField picking-mode="Ignore" label="Group Name" name="GroupName" />
<ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" /> <ui:TextField picking-mode="Ignore" label="Group Desc" name="GroupDesc" />
<ui:TextField picking-mode="Ignore" label="Group Asset Tags" name="GroupAssetTags" /> <ui:TextField picking-mode="Ignore" label="Asset Tags" name="GroupTags" />
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;"> <ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" /> <ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
</ui:VisualElement> </ui:VisualElement>

View File

@@ -21,9 +21,9 @@ namespace YooAsset.Editor
public string Address { private set; get; } public string Address { private set; get; }
/// <summary> /// <summary>
/// 资源路径 /// 资源信息
/// </summary> /// </summary>
public string AssetPath { private set; get; } public AssetInfo AssetInfo { private set; get; }
/// <summary> /// <summary>
/// 资源分类标签 /// 资源分类标签
@@ -33,15 +33,15 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// 依赖的资源列表 /// 依赖的资源列表
/// </summary> /// </summary>
public List<string> DependAssets = new List<string>(); public List<AssetInfo> DependAssets = new List<AssetInfo>();
public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, string assetPath, List<string> assetTags) public CollectAssetInfo(ECollectorType collectorType, string bundleName, string address, AssetInfo assetInfo, List<string> assetTags)
{ {
CollectorType = collectorType; CollectorType = collectorType;
BundleName = bundleName; BundleName = bundleName;
Address = address; Address = address;
AssetPath = assetPath; AssetInfo = assetInfo;
AssetTags = assetTags; AssetTags = assetTags;
} }
} }

View File

@@ -20,15 +20,6 @@ namespace YooAsset.Editor
} }
} }
[DisplayName("定位地址: 文件路径")]
public class AddressByFilePath : IAddressRule
{
string IAddressRule.GetAssetAddress(AddressRuleData data)
{
throw new System.Exception("可寻址模式下已经默认支持通过资源路径加载!");
}
}
[DisplayName("定位地址: 分组名_文件名")] [DisplayName("定位地址: 分组名_文件名")]
public class AddressByGroupAndFileName : IAddressRule public class AddressByGroupAndFileName : IAddressRule
{ {

View File

@@ -15,7 +15,7 @@ namespace YooAsset.Editor
[MenuItem("YooAsset/AssetBundle Debugger", false, 104)] [MenuItem("YooAsset/AssetBundle Debugger", false, 104)]
public static void OpenWindow() public static void OpenWindow()
{ {
AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("资源包调试工具", true, WindowsDefine.DockedWindowTypes); AssetBundleDebuggerWindow wnd = GetWindow<AssetBundleDebuggerWindow>("AssetBundle Debugger", true, WindowsDefine.DockedWindowTypes);
wnd.minSize = new Vector2(800, 600); wnd.minSize = new Vector2(800, 600);
} }

View File

@@ -1,10 +1,10 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<uie:Toolbar name="TopToolbar" style="display: flex;"> <uie:Toolbar name="TopToolbar" style="display: flex;">
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: middle-left; padding-left: 5px;" /> <ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: lower-left; padding-left: 5px;" />
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" /> <uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" /> <uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
<uie:ToolbarButton text="刷新" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" /> <uie:ToolbarButton text="Refresh" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
<uie:ToolbarButton text="导出" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" /> <uie:ToolbarButton text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
</uie:Toolbar> </uie:Toolbar>
<uie:Toolbar name="FrameToolbar"> <uie:Toolbar name="FrameToolbar">
<ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" /> <ui:SliderInt picking-mode="Ignore" label="Frame:" value="42" high-value="100" name="FrameSlider" style="flex-grow: 1;" />

View File

@@ -224,7 +224,7 @@ namespace YooAsset.Editor
// Status // Status
StyleColor textColor; StyleColor textColor;
if (providerInfo.Status == ProviderBase.EStatus.Failed.ToString()) if (providerInfo.Status == EOperationStatus.Failed.ToString())
textColor = new StyleColor(Color.yellow); textColor = new StyleColor(Color.yellow);
else else
textColor = label1.style.color; textColor = label1.style.color;

View File

@@ -12,7 +12,7 @@ namespace YooAsset.Editor
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)] [MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
public static void OpenWindow() public static void OpenWindow()
{ {
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("资源包报告工具", true, WindowsDefine.DockedWindowTypes); AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
window.minSize = new Vector2(800, 600); window.minSize = new Vector2(800, 600);
} }
@@ -35,18 +35,12 @@ namespace YooAsset.Editor
/// 资源包视图 /// 资源包视图
/// </summary> /// </summary>
BundleView, BundleView,
/// <summary>
/// 冗余资源试图
/// </summary>
Redundancy,
} }
private ToolbarMenu _viewModeMenu; private ToolbarMenu _viewModeMenu;
private ReporterSummaryViewer _summaryViewer; private ReporterSummaryViewer _summaryViewer;
private ReporterAssetListViewer _assetListViewer; private ReporterAssetListViewer _assetListViewer;
private ReporterBundleListViewer _bundleListViewer; private ReporterBundleListViewer _bundleListViewer;
private ReporterRedundancyListViewer _redundancyListViewer;
private EViewMode _viewMode; private EViewMode _viewMode;
private BuildReport _buildReport; private BuildReport _buildReport;
@@ -76,7 +70,6 @@ namespace YooAsset.Editor
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0); _viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1); _viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2); _viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
_viewModeMenu.menu.AppendAction(EViewMode.Redundancy.ToString(), ViewModeMenuAction3, ViewModeMenuFun3);
// 搜索栏 // 搜索栏
var searchField = root.Q<ToolbarSearchField>("SearchField"); var searchField = root.Q<ToolbarSearchField>("SearchField");
@@ -94,10 +87,6 @@ namespace YooAsset.Editor
_bundleListViewer = new ReporterBundleListViewer(); _bundleListViewer = new ReporterBundleListViewer();
_bundleListViewer.InitViewer(); _bundleListViewer.InitViewer();
// 加载试图
_redundancyListViewer = new ReporterRedundancyListViewer();
_redundancyListViewer.InitViewer();
// 显示视图 // 显示视图
_viewMode = EViewMode.Summary; _viewMode = EViewMode.Summary;
_viewModeMenu.text = EViewMode.Summary.ToString(); _viewModeMenu.text = EViewMode.Summary.ToString();
@@ -125,7 +114,6 @@ namespace YooAsset.Editor
_summaryViewer.FillViewData(_buildReport); _summaryViewer.FillViewData(_buildReport);
_assetListViewer.FillViewData(_buildReport, _searchKeyWord); _assetListViewer.FillViewData(_buildReport, _searchKeyWord);
_bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord); _bundleListViewer.FillViewData(_buildReport, _reportFilePath, _searchKeyWord);
_redundancyListViewer.FillViewData(_buildReport, _searchKeyWord);
} }
private void OnSearchKeyWordChange(ChangeEvent<string> e) private void OnSearchKeyWordChange(ChangeEvent<string> e)
{ {
@@ -146,7 +134,6 @@ namespace YooAsset.Editor
_summaryViewer.AttachParent(root); _summaryViewer.AttachParent(root);
_assetListViewer.DetachParent(); _assetListViewer.DetachParent();
_bundleListViewer.DetachParent(); _bundleListViewer.DetachParent();
_redundancyListViewer.DetachParent();
} }
} }
private void ViewModeMenuAction1(DropdownMenuAction action) private void ViewModeMenuAction1(DropdownMenuAction action)
@@ -159,7 +146,6 @@ namespace YooAsset.Editor
_summaryViewer.DetachParent(); _summaryViewer.DetachParent();
_assetListViewer.AttachParent(root); _assetListViewer.AttachParent(root);
_bundleListViewer.DetachParent(); _bundleListViewer.DetachParent();
_redundancyListViewer.DetachParent();
} }
} }
private void ViewModeMenuAction2(DropdownMenuAction action) private void ViewModeMenuAction2(DropdownMenuAction action)
@@ -172,20 +158,6 @@ namespace YooAsset.Editor
_summaryViewer.DetachParent(); _summaryViewer.DetachParent();
_assetListViewer.DetachParent(); _assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root); _bundleListViewer.AttachParent(root);
_redundancyListViewer.DetachParent();
}
}
private void ViewModeMenuAction3(DropdownMenuAction action)
{
if (_viewMode != EViewMode.Redundancy)
{
_viewMode = EViewMode.Redundancy;
VisualElement root = this.rootVisualElement;
_viewModeMenu.text = EViewMode.Redundancy.ToString();
_summaryViewer.DetachParent();
_assetListViewer.DetachParent();
_bundleListViewer.DetachParent();
_redundancyListViewer.AttachParent(root);
} }
} }
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action) private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
@@ -209,13 +181,6 @@ namespace YooAsset.Editor
else else
return DropdownMenuAction.Status.Normal; return DropdownMenuAction.Status.Normal;
} }
private DropdownMenuAction.Status ViewModeMenuFun3(DropdownMenuAction action)
{
if (_viewMode == EViewMode.Redundancy)
return DropdownMenuAction.Status.Checked;
else
return DropdownMenuAction.Status.Normal;
}
} }
} }
#endif #endif

View File

@@ -2,6 +2,6 @@
<uie:Toolbar name="Toolbar" style="display: flex;"> <uie:Toolbar name="Toolbar" style="display: flex;">
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" /> <uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
<uie:ToolbarSearchField focusable="true" name="SearchField" style="width: 300px; flex-grow: 1;" /> <uie:ToolbarSearchField focusable="true" name="SearchField" style="width: 300px; flex-grow: 1;" />
<ui:Button text="导入" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" /> <ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar> </uie:Toolbar>
</ui:UXML> </ui:UXML>

View File

@@ -28,10 +28,9 @@ namespace YooAsset.Editor
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>(); public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
/// <summary> /// <summary>
/// 冗余的资源列表 /// 未被依赖的资源列表
/// </summary> /// </summary>
public List<ReportRedundancyInfo> RedundancyInfos = new List<ReportRedundancyInfo>(); public List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>();
/// <summary> /// <summary>
/// 获取资源包信息类 /// 获取资源包信息类

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportIndependAsset
{
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary>
/// 资源文件大小
/// </summary>
public long FileSize;
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: f01d5c82be95c8f4b93aeefc0454ae5c guid: 6f187b12ce298c0429119fcf194f2621
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -1,36 +0,0 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportRedundancyInfo
{
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary>
/// 资源GUID
/// 说明Meta文件记录的GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源文件大小
/// </summary>
public long FileSize;
/// <summary>
/// 冗余的资源包数量
/// </summary>
public int Number;
}
}

View File

@@ -53,32 +53,16 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public string BuildPackageVersion; public string BuildPackageVersion;
/// <summary> // 收集器配置
/// 启用可寻址资源定位
/// </summary>
public bool EnableAddressable;
/// <summary>
/// 资源定位地址大小写不敏感
/// </summary>
public bool LocationToLower;
/// <summary>
/// 包含资源GUID数据
/// </summary>
public bool IncludeAssetGUID;
/// <summary>
/// 资源包名唯一化
/// </summary>
public bool UniqueBundleName; public bool UniqueBundleName;
public bool EnableAddressable;
/// <summary> public bool LocationToLower;
/// 加密服务类名称 public bool IncludeAssetGUID;
/// </summary> public bool IgnoreDefaultType;
public string EncryptionServicesClassName; public bool AutoCollectShaders;
// 构建参数 // 构建参数
public string EncryptionClassName;
public EFileNameStyle FileNameStyle; public EFileNameStyle FileNameStyle;
public ECompressOption CompressOption; public ECompressOption CompressOption;
public bool DisableWriteTypeTree; public bool DisableWriteTypeTree;

View File

@@ -1,4 +1,4 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
@@ -9,8 +9,8 @@
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" /> <uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" /> <uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 280px; -unity-text-align: middle-left;" />
</uie:Toolbar> </uie:Toolbar>
<ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" /> <ui:ListView focusable="true" name="BottomListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
</ui:VisualElement> </ui:VisualElement>

View File

@@ -2,8 +2,8 @@
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" /> <uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" /> <uie:ToolbarButton text="File Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 280px; -unity-text-align: middle-left;" />
<uie:ToolbarButton text="Encrypted" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" /> <uie:ToolbarButton text="Encrypted" display-tooltip-when-elided="true" name="TopBar4" style="width: 150px; -unity-text-align: middle-left; flex-grow: 0;" />
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
</uie:Toolbar> </uie:Toolbar>

View File

@@ -1,317 +0,0 @@
#if UNITY_2019_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
internal class ReporterRedundancyListViewer
{
private enum ESortMode
{
AssetPath,
AssetType,
FileSize,
Number,
}
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private ToolbarButton _topBar1;
private ToolbarButton _topBar2;
private ToolbarButton _topBar3;
private ToolbarButton _topBar4;
private ListView _assetListView;
private BuildReport _buildReport;
private string _searchKeyWord;
private ESortMode _sortMode = ESortMode.AssetPath;
private bool _descendingSort = false;
/// <summary>
/// 初始化页面
/// </summary>
public void InitViewer()
{
// 加载布局文件
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterRedundancyListViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 顶部按钮栏
_topBar1 = _root.Q<ToolbarButton>("TopBar1");
_topBar2 = _root.Q<ToolbarButton>("TopBar2");
_topBar3 = _root.Q<ToolbarButton>("TopBar3");
_topBar4 = _root.Q<ToolbarButton>("TopBar4");
_topBar1.clicked += TopBar1_clicked;
_topBar2.clicked += TopBar2_clicked;
_topBar3.clicked += TopBar3_clicked;
_topBar4.clicked += TopBar4_clicked;
// 资源列表
_assetListView = _root.Q<ListView>("TopListView");
_assetListView.makeItem = MakeAssetListViewItem;
_assetListView.bindItem = BindAssetListViewItem;
}
/// <summary>
/// 填充页面数据
/// </summary>
public void FillViewData(BuildReport buildReport, string searchKeyWord)
{
_buildReport = buildReport;
_searchKeyWord = searchKeyWord;
RefreshView();
}
private void RefreshView()
{
_assetListView.Clear();
_assetListView.ClearSelection();
_assetListView.itemsSource = FilterAndSortViewItems();
_assetListView.Rebuild();
RefreshSortingSymbol();
}
private List<ReportRedundancyInfo> FilterAndSortViewItems()
{
List<ReportRedundancyInfo> result = new List<ReportRedundancyInfo>(_buildReport.RedundancyInfos.Count);
// 过滤列表
foreach (var redundancyInfo in _buildReport.RedundancyInfos)
{
if (string.IsNullOrEmpty(_searchKeyWord) == false)
{
if (redundancyInfo.AssetPath.Contains(_searchKeyWord) == false)
continue;
}
result.Add(redundancyInfo);
}
// 排序列表
if (_sortMode == ESortMode.AssetPath)
{
if (_descendingSort)
return result.OrderByDescending(a => a.AssetPath).ToList();
else
return result.OrderBy(a => a.AssetPath).ToList();
}
else if(_sortMode == ESortMode.AssetType)
{
if (_descendingSort)
return result.OrderByDescending(a => a.AssetType).ToList();
else
return result.OrderBy(a => a.AssetType).ToList();
}
else if (_sortMode == ESortMode.FileSize)
{
if (_descendingSort)
return result.OrderByDescending(a => a.FileSize).ToList();
else
return result.OrderBy(a => a.FileSize).ToList();
}
else if (_sortMode == ESortMode.Number)
{
if (_descendingSort)
return result.OrderByDescending(a => a.Number).ToList();
else
return result.OrderBy(a => a.Number).ToList();
}
else
{
throw new System.NotImplementedException();
}
}
private void RefreshSortingSymbol()
{
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count})";
_topBar2.text = "Asset Type";
_topBar3.text = "File Size";
_topBar4.text = "Redundancy Num";
if (_sortMode == ESortMode.AssetPath)
{
if (_descendingSort)
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↓";
else
_topBar1.text = $"Asset Path ({_assetListView.itemsSource.Count}) ↑";
}
else if(_sortMode == ESortMode.AssetType)
{
if (_descendingSort)
_topBar2.text = "Asset Type ↓";
else
_topBar2.text = "Asset Type ↑";
}
else if (_sortMode == ESortMode.FileSize)
{
if (_descendingSort)
_topBar3.text = "File Size ↓";
else
_topBar3.text = "File Size ↑";
}
else if (_sortMode == ESortMode.Number)
{
if (_descendingSort)
_topBar4.text = "Redundancy Num ↓";
else
_topBar4.text = "Redundancy Num ↑";
}
else
{
throw new System.NotImplementedException();
}
}
/// <summary>
/// 挂接到父类页面上
/// </summary>
public void AttachParent(VisualElement parent)
{
parent.Add(_root);
}
/// <summary>
/// 从父类页面脱离开
/// </summary>
public void DetachParent()
{
_root.RemoveFromHierarchy();
}
// 资源列表相关
private VisualElement MakeAssetListViewItem()
{
VisualElement element = new VisualElement();
element.style.flexDirection = FlexDirection.Row;
{
var label = new Label();
label.name = "Label1";
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = 1f;
label.style.width = 280;
element.Add(label);
}
{
var label = new Label();
label.name = "Label2";
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = 0;
label.style.width = 125;
element.Add(label);
}
{
var label = new Label();
label.name = "Label3";
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = 0;
label.style.width = 125;
element.Add(label);
}
{
var label = new Label();
label.name = "Label4";
label.style.unityTextAlign = TextAnchor.MiddleLeft;
label.style.marginLeft = 3f;
label.style.flexGrow = 0;
label.style.width = 125;
element.Add(label);
}
return element;
}
private void BindAssetListViewItem(VisualElement element, int index)
{
var sourceData = _assetListView.itemsSource as List<ReportRedundancyInfo>;
var redundancyInfo = sourceData[index];
// Asset Path
var label1 = element.Q<Label>("Label1");
label1.text = redundancyInfo.AssetPath;
// Asset Type
var label2 = element.Q<Label>("Label2");
label2.text = redundancyInfo.AssetType;
// File Size
var label3 = element.Q<Label>("Label3");
label3.text = EditorUtility.FormatBytes(redundancyInfo.FileSize);
// Number
var label4 = element.Q<Label>("Label4");
label4.text = redundancyInfo.Number.ToString();
}
private void TopBar1_clicked()
{
if (_sortMode != ESortMode.AssetPath)
{
_sortMode = ESortMode.AssetPath;
_descendingSort = false;
RefreshView();
}
else
{
_descendingSort = !_descendingSort;
RefreshView();
}
}
private void TopBar2_clicked()
{
if (_sortMode != ESortMode.AssetType)
{
_sortMode = ESortMode.AssetType;
_descendingSort = false;
RefreshView();
}
else
{
_descendingSort = !_descendingSort;
RefreshView();
}
}
private void TopBar3_clicked()
{
if (_sortMode != ESortMode.FileSize)
{
_sortMode = ESortMode.FileSize;
_descendingSort = false;
RefreshView();
}
else
{
_descendingSort = !_descendingSort;
RefreshView();
}
}
private void TopBar4_clicked()
{
if (_sortMode != ESortMode.Number)
{
_sortMode = ESortMode.Number;
_descendingSort = false;
RefreshView();
}
else
{
_descendingSort = !_descendingSort;
RefreshView();
}
}
}
}
#endif

View File

@@ -1,11 +0,0 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
<uie:ToolbarButton text="Asset Type" display-tooltip-when-elided="true" name="TopBar2" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
<uie:ToolbarButton text="File Size" display-tooltip-when-elided="true" name="TopBar3" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
<uie:ToolbarButton text="Redundancy Num" display-tooltip-when-elided="true" name="TopBar4" style="width: 125px; -unity-text-align: middle-left; flex-grow: 0; flex-shrink: 1;" />
</uie:Toolbar>
<ui:ListView focusable="true" name="TopListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1; flex-basis: 60px;" />
</ui:VisualElement>
</ui:UXML>

View File

@@ -1,10 +0,0 @@
fileFormatVersion: 2
guid: a5296d9c037ce3944b5c197cbdd78a8b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -56,38 +56,41 @@ namespace YooAsset.Editor
{ {
_items.Clear(); _items.Clear();
_items.Add(new ItemWrapper("YooAsset版本", buildReport.Summary.YooVersion)); _items.Add(new ItemWrapper("YooAsset Version", buildReport.Summary.YooVersion));
_items.Add(new ItemWrapper("引擎版本", buildReport.Summary.UnityVersion)); _items.Add(new ItemWrapper("UnityEngine Version", buildReport.Summary.UnityVersion));
_items.Add(new ItemWrapper("构建时间", buildReport.Summary.BuildDate)); _items.Add(new ItemWrapper("Build Date", buildReport.Summary.BuildDate));
_items.Add(new ItemWrapper("构建耗时", ConvertTime(buildReport.Summary.BuildSeconds))); _items.Add(new ItemWrapper("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds)));
_items.Add(new ItemWrapper("构建平台", $"{buildReport.Summary.BuildTarget}")); _items.Add(new ItemWrapper("Build Target", $"{buildReport.Summary.BuildTarget}"));
_items.Add(new ItemWrapper("构建管线", $"{buildReport.Summary.BuildPipeline}")); _items.Add(new ItemWrapper("Build Pipeline", $"{buildReport.Summary.BuildPipeline}"));
_items.Add(new ItemWrapper("构建模式", $"{buildReport.Summary.BuildMode}")); _items.Add(new ItemWrapper("Build Mode", $"{buildReport.Summary.BuildMode}"));
_items.Add(new ItemWrapper("包裹名称", buildReport.Summary.BuildPackageName)); _items.Add(new ItemWrapper("Package Name", buildReport.Summary.BuildPackageName));
_items.Add(new ItemWrapper("包裹版本", buildReport.Summary.BuildPackageVersion)); _items.Add(new ItemWrapper("Package Version", buildReport.Summary.BuildPackageVersion));
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("启用可寻址资源定位", $"{buildReport.Summary.EnableAddressable}")); _items.Add(new ItemWrapper("Settings", string.Empty));
_items.Add(new ItemWrapper("资源定位地址大小写不敏感", $"{buildReport.Summary.LocationToLower}")); _items.Add(new ItemWrapper("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}"));
_items.Add(new ItemWrapper("包含资源GUID数据", $"{buildReport.Summary.IncludeAssetGUID}")); _items.Add(new ItemWrapper("Enable Addressable", $"{buildReport.Summary.EnableAddressable}"));
_items.Add(new ItemWrapper("资源包名唯一化", $"{buildReport.Summary.UniqueBundleName}")); _items.Add(new ItemWrapper("Location To Lower", $"{buildReport.Summary.LocationToLower}"));
_items.Add(new ItemWrapper("资源加密服务类", buildReport.Summary.EncryptionServicesClassName)); _items.Add(new ItemWrapper("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}"));
_items.Add(new ItemWrapper("Ignore Default Type", $"{buildReport.Summary.IgnoreDefaultType}"));
_items.Add(new ItemWrapper("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}"));
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("构建参数", string.Empty)); _items.Add(new ItemWrapper("Build Params", string.Empty));
_items.Add(new ItemWrapper("Encryption Class Name", buildReport.Summary.EncryptionClassName));
_items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}")); _items.Add(new ItemWrapper("FileNameStyle", $"{buildReport.Summary.FileNameStyle}"));
_items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}")); _items.Add(new ItemWrapper("CompressOption", $"{buildReport.Summary.CompressOption}"));
_items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}")); _items.Add(new ItemWrapper("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}"));
_items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}")); _items.Add(new ItemWrapper("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}"));
_items.Add(new ItemWrapper(string.Empty, string.Empty)); _items.Add(new ItemWrapper(string.Empty, string.Empty));
_items.Add(new ItemWrapper("构建结果", string.Empty)); _items.Add(new ItemWrapper("Build Results", string.Empty));
_items.Add(new ItemWrapper("构建文件总数", $"{buildReport.Summary.AssetFileTotalCount}")); _items.Add(new ItemWrapper("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}"));
_items.Add(new ItemWrapper("主资源总数", $"{buildReport.Summary.MainAssetTotalCount}")); _items.Add(new ItemWrapper("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}"));
_items.Add(new ItemWrapper("资源包总数", $"{buildReport.Summary.AllBundleTotalCount}")); _items.Add(new ItemWrapper("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}"));
_items.Add(new ItemWrapper("资源包总大小", ConvertSize(buildReport.Summary.AllBundleTotalSize))); _items.Add(new ItemWrapper("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize)));
_items.Add(new ItemWrapper("加密资源包总数", $"{buildReport.Summary.EncryptedBundleTotalCount}")); _items.Add(new ItemWrapper("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}"));
_items.Add(new ItemWrapper("加密资源包总大小", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize))); _items.Add(new ItemWrapper("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize)));
_listView.Clear(); _listView.Clear();
_listView.ClearSelection(); _listView.ClearSelection();

View File

@@ -1,8 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;"> <uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
<uie:ToolbarButton text="概览" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" /> <uie:ToolbarButton text="Info" display-tooltip-when-elided="true" name="TopBar1" style="width: 200px; -unity-text-align: middle-left; flex-grow: 0;" />
<uie:ToolbarButton text="参数" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" /> <uie:ToolbarButton text="Param" display-tooltip-when-elided="true" name="TopBar2" style="width: 150px; -unity-text-align: middle-left; flex-grow: 1;" />
</uie:Toolbar> </uie:Toolbar>
<ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" /> <ui:ListView focusable="true" name="ListView" item-height="18" virtualization-method="DynamicHeight" style="flex-grow: 1;" />
</ui:VisualElement> </ui:VisualElement>

View File

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

View File

@@ -0,0 +1,58 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class AssetInfo
{
private string _fileExtension = null;
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源类型
/// </summary>
public System.Type AssetType;
/// <summary>
/// 文件格式
/// </summary>
public string FileExtension
{
get
{
if (string.IsNullOrEmpty(_fileExtension))
_fileExtension = System.IO.Path.GetExtension(AssetPath);
return _fileExtension;
}
}
public AssetInfo(string assetPath)
{
AssetPath = assetPath;
AssetGUID = UnityEditor.AssetDatabase.AssetPathToGUID(AssetPath);
AssetType = UnityEditor.AssetDatabase.GetMainAssetTypeAtPath(AssetPath);
}
/// <summary>
/// 是否为着色器资源
/// </summary>
public bool IsShaderAsset()
{
if (AssetType == typeof(UnityEngine.Shader) || AssetType == typeof(UnityEngine.ShaderVariantCollection))
return true;
else
return false;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: a72c4edf1a81c9942a9d43e9d2a77b53 guid: 4a2e0565919d49348b8deeb14258a985
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -496,6 +496,14 @@ namespace YooAsset.Editor
return fileInfo.Length; return fileInfo.Length;
} }
/// <summary>
/// 获取文件的哈希值
/// </summary>
public static string GetFileCRC32(string filePath)
{
return HashUtility.FileCRC32(filePath);
}
/// <summary> /// <summary>
/// 读取文件的所有文本内容 /// 读取文件的所有文本内容
/// </summary> /// </summary>

View File

@@ -1,5 +1,4 @@
#if UNITY_2019_4_OR_NEWER using System;
using System;
using UnityEditor; using UnityEditor;
using UnityEngine; using UnityEngine;
@@ -14,4 +13,3 @@ namespace YooAsset.Editor
} }
} }
} }
#endif

View File

@@ -26,11 +26,11 @@ namespace YooAsset
{ {
_cache = cache; _cache = cache;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.GetAllCacheFiles; _steps = ESteps.GetAllCacheFiles;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -28,11 +28,11 @@ namespace YooAsset
_package = package; _package = package;
_cache = cache; _cache = cache;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.GetUnusedCacheFiles; _steps = ESteps.GetUnusedCacheFiles;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -31,12 +31,12 @@ namespace YooAsset
_persistent = persistent; _persistent = persistent;
_cache = cache; _cache = cache;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.Prepare; _steps = ESteps.Prepare;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup; _verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -90,12 +90,19 @@ namespace YooAsset
string fileRootPath = chidDirectory.FullName; string fileRootPath = chidDirectory.FullName;
string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}"; string dataFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleDataFileName}";
string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}"; string infoFilePath = $"{fileRootPath}/{ YooAssetSettings.CacheBundleInfoFileName}";
string dataFileExtension = FindDataFileExtension(chidDirectory);
// 跳过断点续传的临时文件
if (dataFileExtension == ".temp")
continue;
// 注意:根据配置需求数据文件会带文件格式
if (_persistent.AppendFileExtension) if (_persistent.AppendFileExtension)
{ {
string fileExtension = FindFileExtension(chidDirectory); if (string.IsNullOrEmpty(dataFileExtension) == false)
if (string.IsNullOrEmpty(fileExtension) == false) dataFilePath += dataFileExtension;
dataFilePath += fileExtension;
} }
VerifyCacheFileElement element = new VerifyCacheFileElement(_cache.PackageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath); VerifyCacheFileElement element = new VerifyCacheFileElement(_cache.PackageName, cacheGUID, fileRootPath, dataFilePath, infoFilePath);
VerifyElements.Add(element); VerifyElements.Add(element);
} }
@@ -106,14 +113,12 @@ namespace YooAsset
return isFindItem; return isFindItem;
} }
private string FindFileExtension(DirectoryInfo directoryInfo) private string FindDataFileExtension(DirectoryInfo directoryInfo)
{ {
string dataFileExtension = string.Empty; string dataFileExtension = string.Empty;
var fileInfos = directoryInfo.GetFiles(); var fileInfos = directoryInfo.GetFiles();
foreach (var fileInfo in fileInfos) foreach (var fileInfo in fileInfos)
{ {
if (fileInfo.Extension == ".temp")
continue;
if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName)) if (fileInfo.Name.StartsWith(YooAssetSettings.CacheBundleDataFileName))
{ {
dataFileExtension = fileInfo.Extension; dataFileExtension = fileInfo.Extension;

View File

@@ -48,12 +48,12 @@ namespace YooAsset
_cache = cache; _cache = cache;
_waitingList = elements; _waitingList = elements;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.InitVerify; _steps = ESteps.InitVerify;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup; _verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -175,12 +175,12 @@ namespace YooAsset
_cache = cache; _cache = cache;
_waitingList = elements; _waitingList = elements;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.InitVerify; _steps = ESteps.InitVerify;
_verifyStartTime = UnityEngine.Time.realtimeSinceStartup; _verifyStartTime = UnityEngine.Time.realtimeSinceStartup;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -41,11 +41,11 @@ namespace YooAsset
{ {
_element = element; _element = element;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.VerifyFile; _steps = ESteps.VerifyFile;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;
@@ -110,11 +110,11 @@ namespace YooAsset
{ {
_element = element; _element = element;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.VerifyFile; _steps = ESteps.VerifyFile;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -26,11 +26,11 @@ namespace YooAsset
_persistent = persistent; _persistent = persistent;
_cache = cache; _cache = cache;
} }
internal override void Start() internal override void InternalOnStart()
{ {
_steps = ESteps.FindCacheFiles; _steps = ESteps.FindCacheFiles;
} }
internal override void Update() internal override void InternalOnUpdate()
{ {
if (_steps == ESteps.None || _steps == ESteps.Done) if (_steps == ESteps.None || _steps == ESteps.Done)
return; return;

View File

@@ -10,13 +10,17 @@ namespace YooAsset
{ {
#if UNITY_EDITOR #if UNITY_EDITOR
return StringUtility.Format("file:///{0}", path); return StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL
return path;
#elif UNITY_IPHONE #elif UNITY_IPHONE
return StringUtility.Format("file://{0}", path); return StringUtility.Format("file://{0}", path);
#elif UNITY_ANDROID #elif UNITY_ANDROID
return path; return path;
#elif UNITY_STANDALONE_OSX
return new System.Uri(path).ToString();
#elif UNITY_STANDALONE #elif UNITY_STANDALONE
return StringUtility.Format("file:///{0}", path); return StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL #else
return path; return path;
#endif #endif
} }

View File

@@ -1,6 +1,5 @@
using System; using System;
using System.Text; using System.Text;
using UnityEngine;
namespace YooAsset namespace YooAsset
{ {

View File

@@ -100,7 +100,7 @@ namespace YooAsset
DownloaderBase newDownloader = null; DownloaderBase newDownloader = null;
YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}"); YooLogger.Log($"Beginning to download bundle : {bundleInfo.Bundle.BundleName} URL : {bundleInfo.RemoteMainURL}");
#if UNITY_WEBGL #if UNITY_WEBGL
if (bundleInfo.Bundle.Buildpipeline == DefaultBuildPipeline.RawFileBuildPipelineName) if (bundleInfo.Bundle.Buildpipeline == EDefaultBuildPipeline.RawFileBuildPipeline.ToString())
{ {
FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath); FileUtility.CreateFileDirectory(bundleInfo.CachedDataFilePath);
System.Type requesterType = typeof(FileGeneralRequest); System.Type requesterType = typeof(FileGeneralRequest);

View File

@@ -1,5 +1,4 @@
 using UnityEngine;
using UnityEngine;
namespace YooAsset namespace YooAsset
{ {

View File

@@ -112,7 +112,7 @@ namespace YooAsset
if (_steps == ESteps.WaitingVerifyTempFile) if (_steps == ESteps.WaitingVerifyTempFile)
{ {
if (WaitForAsyncComplete) if (WaitForAsyncComplete)
_verifyFileOp.Update(); _verifyFileOp.InternalOnUpdate();
if (_verifyFileOp.IsDone == false) if (_verifyFileOp.IsDone == false)
return; return;

View File

@@ -17,6 +17,7 @@ namespace YooAsset
public string RequestNetError { private set; get; } public string RequestNetError { private set; get; }
public long RequestHttpCode { private set; get; } public long RequestHttpCode { private set; get; }
public AssetBundleWebRequest() { }
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args) public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
{ {
if (Status != ERequestStatus.None) if (Status != ERequestStatus.None)

View File

@@ -13,6 +13,7 @@ namespace YooAsset
public string RequestNetError { private set; get; } public string RequestNetError { private set; get; }
public long RequestHttpCode { private set; get; } public long RequestHttpCode { private set; get; }
public FileGeneralRequest() { }
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args) public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
{ {
if (Status != ERequestStatus.None) if (Status != ERequestStatus.None)

View File

@@ -8,7 +8,7 @@ namespace YooAsset
private string _tempFilePath; private string _tempFilePath;
private UnityWebRequest _webRequest; private UnityWebRequest _webRequest;
private DownloadHandlerFileRange _downloadHandle; private DownloadHandlerFileRange _downloadHandle;
private ulong _fileOriginLength; private ulong _fileOriginLength = 0;
public ERequestStatus Status { private set; get; } = ERequestStatus.None; public ERequestStatus Status { private set; get; } = ERequestStatus.None;
public float DownloadProgress { private set; get; } public float DownloadProgress { private set; get; }
@@ -16,6 +16,7 @@ namespace YooAsset
public string RequestNetError { private set; get; } public string RequestNetError { private set; get; }
public long RequestHttpCode { private set; get; } public long RequestHttpCode { private set; get; }
public FileResumeRequest() { }
public void Create(string requestURL, BundleInfo bundleInfo, params object[] args) public void Create(string requestURL, BundleInfo bundleInfo, params object[] args)
{ {
if (Status != ERequestStatus.None) if (Status != ERequestStatus.None)

View File

@@ -4,11 +4,22 @@ namespace YooAsset
/// <summary> /// <summary>
/// 默认的构建管线 /// 默认的构建管线
/// </summary> /// </summary>
public class DefaultBuildPipeline public enum EDefaultBuildPipeline
{ {
public const string BuiltinBuildPipelineName = "BuiltinBuildPipeline"; /// <summary>
public const string ScriptableBuildPipelineName = "ScriptableBuildPipeline"; /// 内置构建管线
public const string RawFileBuildPipelineName = "RawFileBuildPipeline"; /// </summary>
BuiltinBuildPipeline,
/// <summary>
/// 可编程构建管线
/// </summary>
ScriptableBuildPipeline,
/// <summary>
/// 原生文件构建管线
/// </summary>
RawFileBuildPipeline,
} }
/// <summary> /// <summary>
@@ -65,10 +76,9 @@ namespace YooAsset
public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle; public EVerifyLevel CacheBootVerifyLevel = EVerifyLevel.Middle;
/// <summary> /// <summary>
/// 资源加载每帧处理的最大时间片段 /// 自动销毁不再使用的资源提供者
/// 注意默认值为MaxValue
/// </summary> /// </summary>
public long LoadingMaxTimeSlice = long.MaxValue; public bool AutoDestroyAssetProvider = false;
/// <summary> /// <summary>
/// 启用断点续传参数 /// 启用断点续传参数

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