mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 16:50:18 +00:00
Compare commits
292 Commits
2.0.0-prev
...
2.2.7-prev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
748e74e515 | ||
|
|
d1d3ad9869 | ||
|
|
f9b72a22ae | ||
|
|
766cf90a19 | ||
|
|
8a2dc86cf7 | ||
|
|
5ca54b88fa | ||
|
|
7257c8778d | ||
|
|
dc21696ae1 | ||
|
|
7f566e5388 | ||
|
|
fe352ceb84 | ||
|
|
10750a0123 | ||
|
|
f2e6da649b | ||
|
|
9737cd06dd | ||
|
|
df8cf4d9ca | ||
|
|
36b4cbb8c2 | ||
|
|
bae84f65da | ||
|
|
313ec2d100 | ||
|
|
bfda5ec952 | ||
|
|
248bdba839 | ||
|
|
75dd3d0e5e | ||
|
|
8944ec0e02 | ||
|
|
25c5683a09 | ||
|
|
069e29ac07 | ||
|
|
942e4bf672 | ||
|
|
dca37a3794 | ||
|
|
f84419b7a6 | ||
|
|
aa3a049985 | ||
|
|
3f8c7bd91f | ||
|
|
11984d6972 | ||
|
|
31b0a3fb54 | ||
|
|
666d0b53a6 | ||
|
|
df77df4854 | ||
|
|
4f75248f5b | ||
|
|
2b56f4469d | ||
|
|
8d1f0d2010 | ||
|
|
16117b67f1 | ||
|
|
4fc0d06908 | ||
|
|
6254d00bb5 | ||
|
|
6d6fd3af2c | ||
|
|
16344393a1 | ||
|
|
36f561a595 | ||
|
|
f5f024b1d6 | ||
|
|
429f68ff64 | ||
|
|
f9074518dd | ||
|
|
bda803761b | ||
|
|
d3c1c5acb0 | ||
|
|
dcaafedabb | ||
|
|
985c76d8ce | ||
|
|
8c532798cb | ||
|
|
17aed56270 | ||
|
|
1f07411dde | ||
|
|
906e0e3554 | ||
|
|
22958923ad | ||
|
|
a5f94198c0 | ||
|
|
8a2bac8770 | ||
|
|
3fd24f6f19 | ||
|
|
c30292013b | ||
|
|
edd6db731f | ||
|
|
19e0c7b01a | ||
|
|
58fc76b8d2 | ||
|
|
1638bb301d | ||
|
|
f0ed677d86 | ||
|
|
4b0c52d2dd | ||
|
|
5f4e1d0b2f | ||
|
|
a98a48a58d | ||
|
|
763054884b | ||
|
|
376088e63c | ||
|
|
c614ba4705 | ||
|
|
14ea408fec | ||
|
|
038a52f7fc | ||
|
|
341bd5947f | ||
|
|
b5d857d2f1 | ||
|
|
97f9a3d4b1 | ||
|
|
9607d7135b | ||
|
|
b1338a9ffd | ||
|
|
bf1e3da298 | ||
|
|
a91cbee50c | ||
|
|
15fbbf3873 | ||
|
|
f73abba79f | ||
|
|
5fa9ebee80 | ||
|
|
d890ccd5e6 | ||
|
|
e76a782a80 | ||
|
|
0f7c5b2564 | ||
|
|
fcf0f34d5a | ||
|
|
acf2301028 | ||
|
|
9bc0577423 | ||
|
|
d037ce5b86 | ||
|
|
02250c3352 | ||
|
|
cdaa45e163 | ||
|
|
2b9014f4d8 | ||
|
|
75a013d961 | ||
|
|
27563fa58e | ||
|
|
55f958266c | ||
|
|
d980b55997 | ||
|
|
7232caa5c0 | ||
|
|
c0df366676 | ||
|
|
8e7a43275f | ||
|
|
d3567d8dd5 | ||
|
|
e9539636ac | ||
|
|
093dd25e0f | ||
|
|
e0427d3062 | ||
|
|
9e2030c83d | ||
|
|
0627641845 | ||
|
|
4bbcc3c73d | ||
|
|
945842c0e7 | ||
|
|
02ba98f120 | ||
|
|
688f8ec26c | ||
|
|
7652de0129 | ||
|
|
3f027e5456 | ||
|
|
6a17335231 | ||
|
|
ebf0dd9e46 | ||
|
|
04bd352a05 | ||
|
|
fa4ebfe3be | ||
|
|
87421bb391 | ||
|
|
c35e22fbd7 | ||
|
|
94623d8dc0 | ||
|
|
50eed2be10 | ||
|
|
e9b7336146 | ||
|
|
fbec06fa81 | ||
|
|
9fe8dad72d | ||
|
|
3046bbe697 | ||
|
|
7089952895 | ||
|
|
737d2a796b | ||
|
|
e25fd14675 | ||
|
|
c55dc713f4 | ||
|
|
40ef17edcd | ||
|
|
418536ded1 | ||
|
|
c156b5c0a7 | ||
|
|
ae454b72dc | ||
|
|
d34d1117a0 | ||
|
|
a5f3767cbc | ||
|
|
3bdb339f54 | ||
|
|
22cb3c3942 | ||
|
|
e5f5241879 | ||
|
|
79ac231df2 | ||
|
|
b7b375092f | ||
|
|
f86ea04521 | ||
|
|
738c02f58f | ||
|
|
d017688416 | ||
|
|
6b56275f87 | ||
|
|
b89f00130e | ||
|
|
4f58c54eff | ||
|
|
9001be21ac | ||
|
|
be3fa0b688 | ||
|
|
b421e7d2f8 | ||
|
|
0e7c14abde | ||
|
|
caf072ed9b | ||
|
|
51f2709956 | ||
|
|
0d5558f29f | ||
|
|
c6377ce544 | ||
|
|
07d34891ef | ||
|
|
ddce031ee5 | ||
|
|
6680a6450b | ||
|
|
dc119b26c7 | ||
|
|
2cbfca4f3b | ||
|
|
7d8fce6f46 | ||
|
|
13ad50aef5 | ||
|
|
30245b3668 | ||
|
|
589eea7cf3 | ||
|
|
24c5108ce1 | ||
|
|
21fbb01ce4 | ||
|
|
e664f20d34 | ||
|
|
b0ce14dc0e | ||
|
|
d2b38cbc1b | ||
|
|
a6d978090c | ||
|
|
f9d40987eb | ||
|
|
cab710493e | ||
|
|
9970cf704b | ||
|
|
260867b588 | ||
|
|
25231ecd32 | ||
|
|
b282515c39 | ||
|
|
bafd15571a | ||
|
|
481711fd75 | ||
|
|
d09b52301a | ||
|
|
0c77ef628f | ||
|
|
54f585c67a | ||
|
|
a9e5e7fdd3 | ||
|
|
b151f968d7 | ||
|
|
86ef93caa3 | ||
|
|
75511397d6 | ||
|
|
db8d09d0d6 | ||
|
|
02d70a476d | ||
|
|
9420f8561f | ||
|
|
d43eb821b9 | ||
|
|
b82ede8bde | ||
|
|
ff02da5c54 | ||
|
|
2987d356b6 | ||
|
|
dc5f0b151b | ||
|
|
dd5bcc3d9d | ||
|
|
80188ae6e6 | ||
|
|
05e77dc166 | ||
|
|
b9b8f8e170 | ||
|
|
c9cc09cbed | ||
|
|
bef90bf3b8 | ||
|
|
a369efa429 | ||
|
|
370329b07d | ||
|
|
e743a15fbc | ||
|
|
10c8b52092 | ||
|
|
1461b91a94 | ||
|
|
b5ffd5005a | ||
|
|
f06bd83dc3 | ||
|
|
a1450ee78a | ||
|
|
4c619778c3 | ||
|
|
4e8840cd93 | ||
|
|
0a709f741a | ||
|
|
ef8229981e | ||
|
|
2a5a2626a4 | ||
|
|
f4ddaedbf4 | ||
|
|
42104eb944 | ||
|
|
fadc8e6fd6 | ||
|
|
81747462b1 | ||
|
|
c01adad2a0 | ||
|
|
e598d60439 | ||
|
|
929cd23f35 | ||
|
|
d1aca5b675 | ||
|
|
b67868868d | ||
|
|
af3bf8448c | ||
|
|
4170c60f0c | ||
|
|
0a7a883aae | ||
|
|
88a1184877 | ||
|
|
c7329fcab5 | ||
|
|
6eb9a90a03 | ||
|
|
7586882a97 | ||
|
|
6f13c021b9 | ||
|
|
5f30c92d44 | ||
|
|
3e6c55d981 | ||
|
|
de36f984d7 | ||
|
|
95328fe1a6 | ||
|
|
1fb78185ff | ||
|
|
58f9aea979 | ||
|
|
4d4bb1e34f | ||
|
|
6e1978ec10 | ||
|
|
d8a8afba5e | ||
|
|
6e6f425bdd | ||
|
|
9ebe92f832 | ||
|
|
cbdb84a69f | ||
|
|
67b2b886a8 | ||
|
|
2838289650 | ||
|
|
4b68362fb8 | ||
|
|
e8e7696a4d | ||
|
|
82b2a5cc20 | ||
|
|
2332765932 | ||
|
|
552d689317 | ||
|
|
5e2d82d071 | ||
|
|
727f356eea | ||
|
|
544832c46a | ||
|
|
5c1d316d67 | ||
|
|
267ec77c37 | ||
|
|
c2a7106221 | ||
|
|
0e29e9823d | ||
|
|
47962424eb | ||
|
|
505d23ca07 | ||
|
|
d4fcb868d8 | ||
|
|
6dd1f43445 | ||
|
|
2626cb6750 | ||
|
|
81a98ded8a | ||
|
|
930f02765d | ||
|
|
a4ffa580b7 | ||
|
|
506612527d | ||
|
|
74f9f2b0e6 | ||
|
|
4119f02c60 | ||
|
|
bc9a4e07e2 | ||
|
|
9418544264 | ||
|
|
460ea091bd | ||
|
|
64681db027 | ||
|
|
992957e1e9 | ||
|
|
ce62dbc27f | ||
|
|
e2df967aa9 | ||
|
|
5b4a188c0b | ||
|
|
e8b5a58a90 | ||
|
|
c3d5c13a80 | ||
|
|
d30a8aefa4 | ||
|
|
194afe435a | ||
|
|
82ef993d83 | ||
|
|
6d7177a3b5 | ||
|
|
205dd58afd | ||
|
|
d5d5063453 | ||
|
|
f63fcf1227 | ||
|
|
0c70f27560 | ||
|
|
db889366ac | ||
|
|
9476bbe562 | ||
|
|
1313e05d5d | ||
|
|
8817b35517 | ||
|
|
cfe8a77dd5 | ||
|
|
a874d17798 | ||
|
|
5d9ef12577 | ||
|
|
b3a135e1a2 | ||
|
|
a25d03f073 | ||
|
|
589c0d3ce5 | ||
|
|
8457705807 | ||
|
|
ce7aefb744 | ||
|
|
499d7766db |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -20,7 +20,6 @@
|
|||||||
/Assets/StreamingAssets.meta
|
/Assets/StreamingAssets.meta
|
||||||
/Assets/Samples
|
/Assets/Samples
|
||||||
/Assets/Samples.meta
|
/Assets/Samples.meta
|
||||||
/Packages
|
|
||||||
/UserSettings
|
/UserSettings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,483 @@
|
|||||||
|
|
||||||
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.2.7-preview] - 2024-12-30
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 重构了下载器的委托方法。
|
||||||
|
|
||||||
|
- YooAssetSettings配置文件新增Package Manifest Prefix参数。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单前缀名称(默认为空)
|
||||||
|
/// </summary>
|
||||||
|
public string PackageManifestPrefix = string.Empty;
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#422) 修复了同步加载场景的NotImplementedException异常报错。
|
||||||
|
- (#418) 修复了web远程文件系统初始化不正确的问题
|
||||||
|
- (#392) 修复了引擎版本代码兼容相关的警告。
|
||||||
|
- (#332) 修复了当用户的设备中有特殊字符时,URL路径无法被正确识别的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增代码字段:AsyncOperationBase.PackageName
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 重命名DownloaderOperation.OnDownloadOver()方法为DownloaderFinish()
|
||||||
|
- 重命名DownloaderOperation.OnDownloadProgress()方法为DownloadUpdate()
|
||||||
|
- 重命名DownloaderOperation.OnDownloadError()方法为DownloadError()
|
||||||
|
- 重命名DownloaderOperation.OnStartDownloadFile()方法为DownloadFileBegin()
|
||||||
|
|
||||||
|
## [2.2.6-preview] - 2024-12-27
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 增强了对Steam平台DLC拓展包的支持。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// 新增参数关闭Catalog目录查询内置文件的功能
|
||||||
|
var fileSystemParams = CreateDefaultBuildinFileSystemParameters();
|
||||||
|
fileSystemParams .AddParameter(FileSystemParametersDefine.DISABLE_CATALOG_FILE, true);
|
||||||
|
```
|
||||||
|
|
||||||
|
- 资源句柄基类提供了统一的Release方法。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public abstract class HandleBase : IEnumerator, IDisposable
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 释放资源句柄
|
||||||
|
/// </summary>
|
||||||
|
public void Release();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 释放资源句柄
|
||||||
|
/// </summary>
|
||||||
|
public void Dispose();
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 优化了场景卸载逻辑。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
//框架内不在区分主场景和附加场景。
|
||||||
|
//场景卸载后自动释放资源句柄。
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了Unity2020版本提示的脚本编译错误。
|
||||||
|
- (#417) 修复了DefaultWebServerFileSystem文件系统内Catalog未起效的问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增示例文件 GetCacheBundleSizeOperation.cs
|
||||||
|
|
||||||
|
可以获取指定Package的缓存资源总大小。
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 移除了SceneHandle.IsMainScene()方法。
|
||||||
|
|
||||||
|
## [2.2.5-preview] - 2024-12-25
|
||||||
|
|
||||||
|
依赖的ScriptableBuildPipeline (SBP) 插件库版本切换为1.21.25版本!
|
||||||
|
|
||||||
|
重构了ResourceManager相关的核心代码,方便借助文件系统扩展和支持更复杂的需求!
|
||||||
|
|
||||||
|
### Editor
|
||||||
|
|
||||||
|
- 新增了编辑器模拟构建管线 EditorSimulateBuildPipeline
|
||||||
|
- 移除了EBuildMode枚举类型,构建界面有变动。
|
||||||
|
- IActiveRule分组激活接口新增GroupData类。
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 增加抖音小游戏文件系统,见扩展示例代码。
|
||||||
|
|
||||||
|
- 微信小游戏文件系统支持删除无用缓存文件和全部缓存文件。
|
||||||
|
|
||||||
|
- 资源构建管线现在默认剔除了Gizmos和编辑器资源。
|
||||||
|
|
||||||
|
- 优化了资源构建管线里资源收集速度。
|
||||||
|
|
||||||
|
资源收集速度提升100倍!
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
class BuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 使用资源依赖缓存数据库
|
||||||
|
/// 说明:开启此项可以极大提高资源收集速度
|
||||||
|
/// </summary>
|
||||||
|
public bool UseAssetDependencyDB = false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- WebPlayMode支持跨域加载。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
// 创建默认的WebServer文件系统参数
|
||||||
|
public static FileSystemParameters CreateDefaultWebServerFileSystemParameters(bool disableUnityWebCache = false)
|
||||||
|
|
||||||
|
// 创建默认的WebRemote文件系统参数(支持跨域加载)
|
||||||
|
public static FileSystemParameters CreateDefaultWebRemoteFileSystemParameters(IRemoteServices remoteServices, bool disableUnityWebCache = false)
|
||||||
|
```
|
||||||
|
|
||||||
|
- 编辑器模拟文件系统新增初始化参数:支持异步模拟加载帧数。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 异步模拟加载最小帧数
|
||||||
|
/// </summary>
|
||||||
|
FileSystemParametersDefine.ASYNC_SIMULATE_MIN_FRAME
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步模拟加载最大帧数
|
||||||
|
/// </summary>
|
||||||
|
FileSystemParametersDefine.ASYNC_SIMULATE_MAX_FRAME
|
||||||
|
```
|
||||||
|
|
||||||
|
- 缓存文件系统新增初始化参数:支持设置下载器最大并发连接数和单帧最大请求数
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var fileSystremParams = FileSystemParameters.CreateDefaultCacheFileSystemParameters();
|
||||||
|
fileSystremParams .AddParameter(FileSystemParametersDefine.DOWNLOAD_MAX_CONCURRENCY, 99);
|
||||||
|
fileSystremParams .AddParameter(FileSystemParametersDefine.DOWNLOAD_MAX_REQUEST_PER_FRAME, 10);
|
||||||
|
```
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#349) 修复了在加载清单的时候,即使本地存在缓存文件还会去远端下载。
|
||||||
|
- (#361) 修复了协程里等待的asset handle被release,会无限等待并输出警告信息。
|
||||||
|
- (#359) 修复了SubAssetsHandle.GetSubAssetObject会获取到同名的主资源。
|
||||||
|
- (#387) 修复了加密后文件哈希冲突的时候没有抛出异常错误。
|
||||||
|
- (#404) 修复了Unity2022.3.8版本提示编译错误:Cannot resolve symbol 'AsyncInstantiateOperation'
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增示例文件 CopyBuildinManifestOperation.cs
|
||||||
|
|
||||||
|
- 新增示例文件 LoadGameObjectOperation.cs
|
||||||
|
|
||||||
|
- 新增了获取配置清单详情的方法
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
class ResourcePackage
|
||||||
|
{
|
||||||
|
public PackageDetails GetPackageDetails()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增了获取所有资源信息的方法
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
class ResourcePackage
|
||||||
|
{
|
||||||
|
public AssetInfo[] GetAllAssetInfos()
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 新增了清理缓存文件的通用方法
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 文件清理方式
|
||||||
|
/// </summary>
|
||||||
|
public enum EFileClearMode
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有文件
|
||||||
|
/// </summary>
|
||||||
|
ClearAllBundleFiles = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 清理未在使用的文件
|
||||||
|
/// </summary>
|
||||||
|
ClearUnusedBundleFiles = 2,
|
||||||
|
/// <summary>
|
||||||
|
/// 清理指定标签的文件
|
||||||
|
/// 说明:需要指定参数,可选:string, string[], List<string>
|
||||||
|
/// </summary>
|
||||||
|
ClearBundleFilesByTags = 3,
|
||||||
|
}
|
||||||
|
class ResourcePackage
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 清理缓存文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="clearMode">清理方式</param>
|
||||||
|
/// <param name="clearParam">执行参数</param>
|
||||||
|
public ClearCacheBundleFilesOperation ClearCacheBundleFilesAsync(EFileClearMode clearMode, object clearParam = null)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 修改了EditorSimulateModeHelper.SimulateBuild()方法
|
||||||
|
|
||||||
|
- 重命名ResourcePackage.GetAssetsInfoByTags()方法为GetAssetInfosByTags()
|
||||||
|
|
||||||
|
- 实例化对象方法增加激活参数。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public InstantiateOperation InstantiateAsync(bool actived = true)
|
||||||
|
```
|
||||||
|
|
||||||
|
- 清单文件的版本提升到2.2.5版本
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 资源包裹的备注信息
|
||||||
|
/// </summary>
|
||||||
|
public string PackageNote;
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 移除了HostPlayModeParameters.DeliveryFileSystemParameters字段
|
||||||
|
- 移除了ResourcePackage.ClearAllBundleFilesAsync()方法
|
||||||
|
- 移除了ResourcePackage.ClearUnusedBundleFilesAsync()方法
|
||||||
|
- 移除了FileSystemParameters.CreateDefaultBuildinRawFileSystemParameters()方法
|
||||||
|
- 移除了FileSystemParameters.CreateDefaultCacheRawFileSystemParameters()方法
|
||||||
|
- 移除了枚举类型:EDefaultBuildPipeline
|
||||||
|
- 移除了配置参数:YooAssetSettings.ManifestFileName
|
||||||
|
|
||||||
|
## [2.2.4-preview] - 2024-08-15
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- 修复了HostPlayMode初始化卡死的问题。
|
||||||
|
|
||||||
|
## [2.2.3-preview] - 2024-08-13
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#311) 修复了断点续传下载器极小概率报错 : “416 Range Not Satisfiable”
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 原生文件构建管线支持原生文件加密。
|
||||||
|
|
||||||
|
- HostPlayMode模式下内置文件系统初始化参数可以为空。
|
||||||
|
|
||||||
|
- 场景加载增加了LocalPhysicsMode参数来控制物理运行模式。
|
||||||
|
|
||||||
|
- 默认的内置文件系统和缓存文件系统增加解密方法。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
/// <summary>
|
||||||
|
/// 创建默认的内置文件系统参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
|
/// <param name="rootDirectory">内置文件的根路径</param>
|
||||||
|
public static FileSystemParameters CreateDefaultBuildinFileSystemParameters(IDecryptionServices decryptionServices, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建默认的缓存文件系统参数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteServices">远端资源地址查询服务类</param>
|
||||||
|
/// <param name="decryptionServices">加密文件解密服务类</param>
|
||||||
|
/// <param name="verifyLevel">缓存文件的校验等级</param>
|
||||||
|
/// <param name="rootDirectory">文件系统的根目录</param>
|
||||||
|
public static FileSystemParameters CreateDefaultCacheFileSystemParameters(IRemoteServices remoteServices, IDecryptionServices decryptionServices, EFileVerifyLevel verifyLevel, string rootDirectory);
|
||||||
|
```
|
||||||
|
|
||||||
|
## [2.2.2-preview] - 2024-07-31
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#321) 修复了在Unity2022里编辑器下离线模式运行失败的问题。
|
||||||
|
- (#325) 修复了在Unity2019里编译报错问题。
|
||||||
|
|
||||||
|
## [2.2.1-preview] - 2024-07-10
|
||||||
|
|
||||||
|
统一了所有PlayMode的初始化逻辑,EditorSimulateMode和OfflinePlayMode初始化不再主动加载资源清单!
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了IFileSystem.ReadFileData方法,支持原生文件自定义获取文本和二进制数据。
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 优化了DefaultWebFileSystem和DefaultBuildFileSystem文件系统的内部初始化逻辑。
|
||||||
|
|
||||||
|
## [2.2.0-preview] - 2024-07-07
|
||||||
|
|
||||||
|
重构了运行时代码,新增了文件系统接口(IFileSystem)方便开发者扩展特殊需求。
|
||||||
|
|
||||||
|
新增微信小游戏文件系统示例代码,详细见Extension Sample/Runtime/WechatFileSystem
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增了ResourcePackage.DestroyAsync方法
|
||||||
|
|
||||||
|
- 新增了FileSystemParameters类帮助初始化文件系统
|
||||||
|
|
||||||
|
内置了编辑器文件系统参数,内置文件系统参数,缓存文件系统参数,Web文件系统参数。
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
public class FileSystemParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 文件系统类
|
||||||
|
/// </summary>
|
||||||
|
public string FileSystemClass { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文件系统的根目录
|
||||||
|
/// </summary>
|
||||||
|
public string RootDirectory { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加自定义参数
|
||||||
|
/// </summary>
|
||||||
|
public void AddParameter(string name, object value)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 重构了InitializeParameters初始化参数
|
||||||
|
- 重命名YooAssets.DestroyPackage方法为RemovePackage
|
||||||
|
- 重命名ResourcePackage.UpdatePackageVersionAsync方法为RequestPackageVersionAsync
|
||||||
|
- 重命名ResourcePackage.UnloadUnusedAssets方法为UnloadUnusedAssetsAsync
|
||||||
|
- 重命名ResourcePackage.ForceUnloadAllAssets方法为UnloadAllAssetsAsync
|
||||||
|
- 重命名ResourcePackage.ClearUnusedCacheFilesAsync方法为ClearUnusedBundleFilesAsync
|
||||||
|
- 重命名ResourcePackage.ClearAllCacheFilesAsync方法为ClearAllBundleFilesAsync
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
|
||||||
|
- 移除了YooAssets.Destroy方法
|
||||||
|
- 移除了YooAssets.SetDownloadSystemClearFileResponseCode方法
|
||||||
|
- 移除了YooAssets.SetCacheSystemDisableCacheOnWebGL方法
|
||||||
|
- 移除了ResourcePackage.GetPackageBuildinRootDirectory方法
|
||||||
|
- 移除了ResourcePackage.GetPackageSandboxRootDirectory方法
|
||||||
|
- 移除了ResourcePackage.ClearPackageSandbox方法
|
||||||
|
- 移除了IBuildinQueryServices接口
|
||||||
|
- 移除了IDeliveryLoadServices接口
|
||||||
|
- 移除了IDeliveryQueryServices接口
|
||||||
|
|
||||||
|
|
||||||
|
## [2.1.2] - 2024-05-16
|
||||||
|
|
||||||
|
SBP库依赖版本升级至2.1.3
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#236) 修复了资源配置界面AutoCollectShader复选框没有刷新的问题。
|
||||||
|
- (#244) 修复了导入器在安卓平台导入本地下载的资源失败的问题。
|
||||||
|
- (#268) 修复了挂起场景未解除状态前无法卸载的问题。
|
||||||
|
- (#269) 优化场景挂起流程,支持中途取消挂起操作。
|
||||||
|
- (#276) 修复了HostPlayMode模式下,如果内置清单是最新版本,每次运行都会触发拷贝行为。
|
||||||
|
- (#289) 修复了Unity2019版本脚本IWebRequester编译报错。
|
||||||
|
- (#295) 解决了在安卓移动平台,华为和三星真机上有极小概率加载资源包失败 : Unable to open archive file
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 新增GetAllCacheFileInfosOperation()获取缓存文件信息的方法。
|
||||||
|
|
||||||
|
- 新增LoadSceneSync()同步加载场景的方法。
|
||||||
|
|
||||||
|
- 新增IIgnoreRule接口,资源收集流程可以自定义。
|
||||||
|
|
||||||
|
- 新增IWechatQueryServices接口,用于微信平台本地文件查询。
|
||||||
|
|
||||||
|
后续将会通过虚拟文件系统来支持!
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- 调整了UnloadSceneOperation代码里场景的卸载顺序。
|
||||||
|
|
||||||
|
### Improvements
|
||||||
|
|
||||||
|
- 优化了资源清单的解析过程。
|
||||||
|
- 移除资源包名里的空格字符。
|
||||||
|
- 支持华为鸿蒙系统。
|
||||||
|
|
||||||
|
## [2.1.1] - 2024-01-17
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- (#224) 修复了编辑器模式打包时 SimulateBuild 报错的问题。
|
||||||
|
- (#223) 修复了资源构建界面读取配置导致的报错问题。
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- 支持共享资源打包规则,可以定制化独立的构建规则。
|
||||||
|
|
||||||
|
```c#
|
||||||
|
public class BuildParameters
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用共享资源打包
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSharePackRule = false;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- 微信小游戏平台,资源下载器支持底层缓存查询。
|
||||||
|
|
||||||
|
## [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.
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
|||||||
public static class AssetBundleBuilderHelper
|
public static class AssetBundleBuilderHelper
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的输出根路录
|
/// 获取默认的输出根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetDefaultBuildOutputRoot()
|
public static string GetDefaultBuildOutputRoot()
|
||||||
{
|
{
|
||||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static string GetStreamingAssetsRoot()
|
public static string GetStreamingAssetsRoot()
|
||||||
{
|
{
|
||||||
return $"{Application.dataPath}/StreamingAssets/{YooAssetSettingsData.Setting.DefaultYooFolderName}/";
|
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,18 +18,6 @@ namespace YooAsset.Editor
|
|||||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EBuildMode
|
|
||||||
public static EBuildMode GetPackageBuildMode(string packageName, EBuildPipeline buildPipeline)
|
|
||||||
{
|
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
|
||||||
return (EBuildMode)EditorPrefs.GetInt(key, (int)EBuildMode.ForceRebuild);
|
|
||||||
}
|
|
||||||
public static void SetPackageBuildMode(string packageName, EBuildPipeline buildPipeline, EBuildMode buildMode)
|
|
||||||
{
|
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildMode)}";
|
|
||||||
EditorPrefs.SetInt(key, (int)buildMode);
|
|
||||||
}
|
|
||||||
|
|
||||||
// ECompressOption
|
// ECompressOption
|
||||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||||
{
|
{
|
||||||
@@ -89,5 +77,29 @@ namespace YooAsset.Editor
|
|||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||||
EditorPrefs.SetString(key, encyptionClassName);
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ClearBuildCache
|
||||||
|
public static bool GetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
|
return EditorPrefs.GetInt(key, 0) > 0;
|
||||||
|
}
|
||||||
|
public static void SetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline, bool clearBuildCache)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
|
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// UseAssetDependencyDB
|
||||||
|
public static bool GetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
|
return EditorPrefs.GetInt(key, 0) > 0;
|
||||||
|
}
|
||||||
|
public static void SetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline, bool useAssetDependencyDB)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
|
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
@@ -69,6 +69,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_pipelineMenu = new ToolbarMenu();
|
_pipelineMenu = new ToolbarMenu();
|
||||||
_pipelineMenu.style.width = 200;
|
_pipelineMenu.style.width = 200;
|
||||||
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.EditorSimulateBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.EditorSimulateBuildPipeline);
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||||
@@ -93,7 +94,11 @@ namespace YooAsset.Editor
|
|||||||
_pipelineMenu.text = _buildPipeline.ToString();
|
_pipelineMenu.text = _buildPipeline.ToString();
|
||||||
|
|
||||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
||||||
|
{
|
||||||
|
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||||
|
}
|
||||||
|
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||||
{
|
{
|
||||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,87 +8,37 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 模拟构建
|
/// 模拟构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static string SimulateBuild(string buildPipelineName, string packageName)
|
public static EditorSimulateBuildResult SimulateBuild(EditorSimulateBuildParam buildParam)
|
||||||
{
|
{
|
||||||
if (buildPipelineName == EBuildPipeline.BuiltinBuildPipeline.ToString())
|
string packageName = buildParam.PackageName;
|
||||||
|
string buildPipelineName = buildParam.BuildPipelineName;
|
||||||
|
|
||||||
|
if (buildPipelineName == "EditorSimulateBuildPipeline")
|
||||||
{
|
{
|
||||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
var buildParameters = new EditorSimulateBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
buildParameters.BuildPipeline = EBuildPipeline.EditorSimulateBuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
|
||||||
buildParameters.PackageName = packageName;
|
buildParameters.PackageName = packageName;
|
||||||
buildParameters.PackageVersion = "Simulate";
|
buildParameters.PackageVersion = "Simulate";
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
|
||||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
var pipeline = new EditorSimulateBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
{
|
{
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
var reulst = new EditorSimulateBuildResult();
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
reulst.PackageRootDirectory = buildResult.OutputPackageDirectory;
|
||||||
return manifestFilePath;
|
return reulst;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return null;
|
Debug.LogError(buildResult.ErrorInfo);
|
||||||
}
|
throw new System.Exception($"{nameof(EditorSimulateBuildPipeline)} build failed !");
|
||||||
}
|
|
||||||
else if (buildPipelineName == EBuildPipeline.ScriptableBuildPipeline.ToString())
|
|
||||||
{
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
|
||||||
buildParameters.PackageName = packageName;
|
|
||||||
buildParameters.PackageVersion = "Simulate";
|
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
|
||||||
if (buildResult.Success)
|
|
||||||
{
|
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
|
||||||
return manifestFilePath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (buildPipelineName == EBuildPipeline.RawFileBuildPipeline.ToString())
|
|
||||||
{
|
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
|
||||||
buildParameters.BuildPipeline = buildPipelineName;
|
|
||||||
buildParameters.BuildTarget = EditorUserBuildSettings.activeBuildTarget;
|
|
||||||
buildParameters.BuildMode = EBuildMode.SimulateBuild;
|
|
||||||
buildParameters.PackageName = packageName;
|
|
||||||
buildParameters.PackageVersion = "Simulate";
|
|
||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
|
||||||
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
|
||||||
if (buildResult.Success)
|
|
||||||
{
|
|
||||||
string manifestFileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
|
||||||
string manifestFilePath = $"{buildResult.OutputPackageDirectory}/{manifestFileName}";
|
|
||||||
return manifestFilePath;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -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,17 @@ namespace YooAsset.Editor
|
|||||||
AllDependAssetInfos = dependAssetInfos;
|
AllDependAssetInfos = dependAssetInfos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置资源包名称
|
||||||
|
/// </summary>
|
||||||
|
public void SetBundleName(string bundleName)
|
||||||
|
{
|
||||||
|
if (HasBundleName())
|
||||||
|
throw new System.Exception("Should never get here !");
|
||||||
|
|
||||||
|
BundleName = bundleName;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加资源的分类标签
|
/// 添加资源的分类标签
|
||||||
/// 说明:原始定义的资源分类标签
|
/// 说明:原始定义的资源分类标签
|
||||||
@@ -126,17 +122,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>
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ namespace YooAsset.Editor
|
|||||||
public string EncryptedFilePath { set; get; }
|
public string EncryptedFilePath { set; get; }
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 参与构建的资源列表
|
/// 参与构建的资源列表
|
||||||
@@ -82,12 +83,14 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 添加一个打包资源
|
/// 添加一个打包资源
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void PackAsset(BuildAssetInfo assetInfo)
|
public void PackAsset(BuildAssetInfo buildAsset)
|
||||||
{
|
{
|
||||||
if (IsContainsAsset(assetInfo.AssetPath))
|
string assetPath = buildAsset.AssetInfo.AssetPath;
|
||||||
throw new System.Exception($"Asset is existed : {assetInfo.AssetPath}");
|
if (_assetPaths.Contains(assetPath))
|
||||||
|
throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}");
|
||||||
|
|
||||||
MainAssets.Add(assetInfo);
|
_assetPaths.Add(assetPath);
|
||||||
|
MainAssets.Add(buildAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -95,14 +98,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsContainsAsset(string assetPath)
|
public bool IsContainsAsset(string assetPath)
|
||||||
{
|
{
|
||||||
foreach (var assetInfo in MainAssets)
|
return _assetPaths.Contains(assetPath);
|
||||||
{
|
|
||||||
if (assetInfo.AssetPath == assetPath)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -110,7 +106,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 +116,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -142,7 +138,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||||
{
|
{
|
||||||
// 注意:我们不在支持AssetBundle的变种机制
|
// 注意:我们不再支持AssetBundle的变种机制
|
||||||
AssetBundleBuild build = new AssetBundleBuild();
|
AssetBundleBuild build = new AssetBundleBuild();
|
||||||
build.assetBundleName = BundleName;
|
build.assetBundleName = BundleName;
|
||||||
build.assetBundleVariant = string.Empty;
|
build.assetBundleVariant = string.Empty;
|
||||||
@@ -165,10 +161,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -22,20 +22,20 @@ namespace YooAsset.Editor
|
|||||||
public string BuildinFileRoot;
|
public string BuildinFileRoot;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建管线
|
/// 构建管线名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string BuildPipeline;
|
public string BuildPipeline;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建资源包类型
|
||||||
|
/// </summary>
|
||||||
|
public int BuildBundleType;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的平台
|
/// 构建的平台
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildTarget BuildTarget;
|
public BuildTarget BuildTarget;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 构建模式
|
|
||||||
/// </summary>
|
|
||||||
public EBuildMode BuildMode;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建的包裹名称
|
/// 构建的包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -46,6 +46,26 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageVersion;
|
public string PackageVersion;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 构建的包裹备注
|
||||||
|
/// </summary>
|
||||||
|
public string PackageNote;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空构建缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public bool ClearBuildCacheFiles = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用资源依赖缓存数据库
|
||||||
|
/// 说明:开启此项可以极大提高资源收集速度
|
||||||
|
/// </summary>
|
||||||
|
public bool UseAssetDependencyDB = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用共享资源打包
|
||||||
|
/// </summary>
|
||||||
|
public bool EnableSharePackRule = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 验证构建结果
|
/// 验证构建结果
|
||||||
@@ -73,7 +93,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,50 +105,42 @@ 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)
|
if (BuildTarget == BuildTarget.NoTarget)
|
||||||
throw new Exception("请选择目标平台!");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.NoBuildTarget, "Please select the build target platform !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(PackageName))
|
if (string.IsNullOrEmpty(PackageName))
|
||||||
throw new Exception("包裹名称不能为空!");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageNameIsNullOrEmpty, "Package name is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(PackageVersion))
|
if (string.IsNullOrEmpty(PackageVersion))
|
||||||
throw new Exception("包裹版本不能为空!");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageVersionIsNullOrEmpty, "Package version is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(BuildOutputRoot))
|
if (string.IsNullOrEmpty(BuildOutputRoot))
|
||||||
throw new Exception("构建输出的根目录为空!");
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildOutputRootIsNullOrEmpty, "Build output root is null or empty !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
if (string.IsNullOrEmpty(BuildinFileRoot))
|
if (string.IsNullOrEmpty(BuildinFileRoot))
|
||||||
throw new Exception("内置资源根目录为空!");
|
|
||||||
|
|
||||||
// 检测是否有未保存场景
|
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
{
|
||||||
if (EditorTools.HasDirtyScenes())
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BuildinFileRootIsNullOrEmpty, "Buildin file root is null or empty !");
|
||||||
throw new Exception("检测到未保存的场景文件");
|
throw new Exception(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 强制构建删除包裹目录
|
// 设置默认备注信息
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
if (string.IsNullOrEmpty(PackageNote))
|
||||||
{
|
{
|
||||||
string packageRootDirectory = GetPackageRootDirectory();
|
PackageNote = DateTime.Now.ToString();
|
||||||
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
|
||||||
{
|
|
||||||
BuildLogger.Log($"删除包裹目录:{packageRootDirectory}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检测包裹输出目录是否存在
|
|
||||||
if (BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
string packageOutputDirectory = GetPackageOutputDirectory();
|
|
||||||
if (Directory.Exists(packageOutputDirectory))
|
|
||||||
throw new Exception($"本次构建的补丁目录已经存在:{packageOutputDirectory}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 如果输出目录不存在
|
|
||||||
string pipelineOutputDirectory = GetPipelineOutputDirectory();
|
|
||||||
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
|
||||||
{
|
|
||||||
BuildLogger.Log($"创建输出目录:{pipelineOutputDirectory}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,7 +149,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 +161,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 +173,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 +185,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取内置资源的根目录
|
/// 获取内置资源的根目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBuildinRootDirectory()
|
public virtual string GetBuildinRootDirectory()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
if (string.IsNullOrEmpty(_buildinRootDirectory))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 刷新目录
|
// 刷新目录
|
||||||
AssetDatabase.Refresh();
|
AssetDatabase.Refresh();
|
||||||
BuildLogger.Log($"内置文件拷贝完成:{buildinRootDirectory}");
|
BuildLogger.Log($"Buildin files copy complete: {buildinRootDirectory}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -15,18 +12,22 @@ 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> _cachedBundleIndexIDs = new Dictionary<string, int>(10000);
|
||||||
|
private readonly Dictionary<int, HashSet<string>> _cacheBundleTags = new Dictionary<int, HashSet<string>>(10000);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 创建补丁清单文件到输出目录
|
/// 创建补丁清单文件到输出目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void CreateManifestFile(BuildContext context)
|
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
|
||||||
{
|
{
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
string packageOutputDirectory = buildParametersContext.GetPackageOutputDirectory();
|
||||||
|
|
||||||
|
// 检测资源包哈希冲突
|
||||||
|
CheckBundleHashConflict(buildMapContext);
|
||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||||
@@ -34,27 +35,31 @@ namespace YooAsset.Editor
|
|||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||||
|
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
manifest.PackageName = buildParameters.PackageName;
|
manifest.PackageName = buildParameters.PackageName;
|
||||||
manifest.PackageVersion = buildParameters.PackageVersion;
|
manifest.PackageVersion = buildParameters.PackageVersion;
|
||||||
manifest.BundleList = GetAllPackageBundle(buildMapContext);
|
manifest.PackageNote = buildParameters.PackageNote;
|
||||||
manifest.AssetList = GetAllPackageAsset(buildMapContext);
|
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||||
|
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||||
|
|
||||||
|
// 处理资源清单的ID数据
|
||||||
|
ProcessPacakgeIDs(manifest);
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
// 处理资源包的依赖列表
|
// 处理资源包的依赖列表
|
||||||
|
if (processBundleDepends)
|
||||||
ProcessBundleDepends(context, manifest);
|
ProcessBundleDepends(context, manifest);
|
||||||
|
|
||||||
// 处理资源包的标签集合
|
// 处理资源包的标签集合
|
||||||
|
if (processBundleTags)
|
||||||
ProcessBundleTags(manifest);
|
ProcessBundleTags(manifest);
|
||||||
}
|
|
||||||
|
|
||||||
// 创建补丁清单文本文件
|
// 创建补丁清单文本文件
|
||||||
{
|
{
|
||||||
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 +69,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 +82,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 +90,29 @@ 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}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测资源包哈希冲突
|
||||||
|
/// </summary>
|
||||||
|
private void CheckBundleHashConflict(BuildMapContext buildMapContext)
|
||||||
|
{
|
||||||
|
// 说明:在特殊情况下,例如某些文件加密算法会导致加密后的文件哈希值冲突!
|
||||||
|
// 说明:二进制完全相同的原生文件也会冲突!
|
||||||
|
HashSet<string> guids = new HashSet<string>();
|
||||||
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
|
{
|
||||||
|
if (guids.Contains(bundleInfo.PackageFileHash))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.BundleHashConflict, $"Bundle hash conflict : {bundleInfo.BundleName}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
guids.Add(bundleInfo.PackageFileHash);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,9 +122,9 @@ namespace YooAsset.Editor
|
|||||||
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
protected abstract string[] GetBundleDepends(BuildContext context, string bundleName);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取主资源对象列表
|
/// 创建资源对象列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageAsset> GetAllPackageAsset(BuildMapContext buildMapContext)
|
private List<PackageAsset> CreatePackageAssetList(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageAsset> result = new List<PackageAsset>(1000);
|
List<PackageAsset> result = new List<PackageAsset>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
@@ -107,20 +134,23 @@ 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.BundleNameInEditor = assetInfo.BundleName;
|
||||||
result.Add(packageAsset);
|
result.Add(packageAsset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按照AssetPath排序
|
||||||
|
result.Sort((a, b) => a.AssetPath.CompareTo(b.AssetPath));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包列表
|
/// 创建资源包列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private List<PackageBundle> GetAllPackageBundle(BuildMapContext buildMapContext)
|
private List<PackageBundle> CreatePackageBundleList(BuildMapContext buildMapContext)
|
||||||
{
|
{
|
||||||
List<PackageBundle> result = new List<PackageBundle>(1000);
|
List<PackageBundle> result = new List<PackageBundle>(1000);
|
||||||
foreach (var bundleInfo in buildMapContext.Collection)
|
foreach (var bundleInfo in buildMapContext.Collection)
|
||||||
@@ -129,14 +159,28 @@ namespace YooAsset.Editor
|
|||||||
result.Add(packageBundle);
|
result.Add(packageBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 注意:缓存资源包索引
|
// 按照BundleName排序
|
||||||
for (int index = 0; index < result.Count; index++)
|
result.Sort((a, b) => a.BundleName.CompareTo(b.BundleName));
|
||||||
{
|
return result;
|
||||||
string bundleName = result[index].BundleName;
|
|
||||||
_cachedBundleID.Add(bundleName, index);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
/// <summary>
|
||||||
|
/// 处理资源清单的ID数据
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessPacakgeIDs(PackageManifest manifest)
|
||||||
|
{
|
||||||
|
// 注意:优先缓存资源包索引
|
||||||
|
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||||
|
{
|
||||||
|
string bundleName = manifest.BundleList[index].BundleName;
|
||||||
|
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var packageAsset in manifest.AssetList)
|
||||||
|
{
|
||||||
|
string bundleName = packageAsset.BundleNameInEditor;
|
||||||
|
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -147,12 +191,12 @@ namespace YooAsset.Editor
|
|||||||
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
// 查询引擎生成的资源包依赖关系,然后记录到清单
|
||||||
foreach (var packageBundle in manifest.BundleList)
|
foreach (var packageBundle in manifest.BundleList)
|
||||||
{
|
{
|
||||||
int mainBundleID = GetCachedBundleID(packageBundle.BundleName);
|
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||||
List<int> dependIDs = new List<int>(depends.Length);
|
List<int> dependIDs = new List<int>(depends.Length);
|
||||||
foreach (var dependBundleName in depends)
|
foreach (var dependBundleName in depends)
|
||||||
{
|
{
|
||||||
int bundleID = GetCachedBundleID(dependBundleName);
|
int bundleID = GetCachedBundleIndexID(dependBundleName);
|
||||||
if (bundleID != mainBundleID)
|
if (bundleID != mainBundleID)
|
||||||
dependIDs.Add(bundleID);
|
dependIDs.Add(bundleID);
|
||||||
}
|
}
|
||||||
@@ -165,47 +209,58 @@ 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];
|
||||||
|
if (packageBundle.DependIDs != null)
|
||||||
|
{
|
||||||
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.TryGetValue(index, out var value))
|
||||||
}
|
|
||||||
private void CacheBundleTags(Dictionary<int, HashSet<string>> cacheBundleTags, int bundleID, string[] assetTags)
|
|
||||||
{
|
{
|
||||||
if (cacheBundleTags.ContainsKey(bundleID) == false)
|
packageBundle.Tags = value.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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包的索引ID
|
/// 获取缓存的资源包的索引ID
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private int GetCachedBundleID(string bundleName)
|
private int GetCachedBundleIndexID(string bundleName)
|
||||||
{
|
{
|
||||||
if (_cachedBundleID.TryGetValue(bundleName, out int value) == false)
|
if (_cachedBundleIndexIDs.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 index ID : {bundleName}");
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,17 +28,24 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||||
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
buildReport.Summary.BuildTarget = buildParameters.BuildTarget;
|
||||||
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
buildReport.Summary.BuildPipeline = buildParameters.BuildPipeline;
|
||||||
buildReport.Summary.BuildMode = buildParameters.BuildMode;
|
buildReport.Summary.BuildBundleType = buildParameters.BuildBundleType;
|
||||||
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
buildReport.Summary.BuildPackageName = buildParameters.PackageName;
|
||||||
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
buildReport.Summary.BuildPackageVersion = buildParameters.PackageVersion;
|
||||||
|
buildReport.Summary.BuildPackageNote = buildParameters.PackageNote;
|
||||||
|
|
||||||
|
// 收集器配置
|
||||||
|
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.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ?
|
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||||
"null" : buildParameters.EncryptionServices.GetType().FullName;
|
|
||||||
|
|
||||||
// 构建参数
|
// 构建参数
|
||||||
|
buildReport.Summary.ClearBuildCacheFiles = buildParameters.ClearBuildCacheFiles;
|
||||||
|
buildReport.Summary.UseAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||||
|
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||||
|
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||||
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
if (buildParameters.BuildPipeline == nameof(BuiltinBuildPipeline))
|
||||||
{
|
{
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
@@ -105,14 +112,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.GetBuildReportFileName(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>
|
||||||
@@ -126,6 +133,7 @@ namespace YooAsset.Editor
|
|||||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||||
dependBundles.Add(dependBundleName);
|
dependBundles.Add(dependBundleName);
|
||||||
}
|
}
|
||||||
|
dependBundles.Sort();
|
||||||
return dependBundles;
|
return dependBundles;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,23 +146,24 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
result.Sort();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +173,9 @@ namespace YooAsset.Editor
|
|||||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||||
{
|
{
|
||||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||||
return bundleInfo.GetAllBuiltinAssetPaths();
|
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||||
|
result.Sort();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetMainAssetCount(PackageManifest manifest)
|
private int GetMainAssetCount(PackageManifest manifest)
|
||||||
|
|||||||
@@ -26,8 +26,7 @@ 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.FileLoadPath = $"{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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,98 +12,119 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 生成资源构建上下文
|
/// 生成资源构建上下文
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public BuildMapContext CreateBuildMap(BuildParameters buildParameters)
|
public BuildMapContext CreateBuildMap(bool simulateBuild, BuildParameters buildParameters)
|
||||||
{
|
{
|
||||||
var buildMode = buildParameters.BuildMode;
|
BuildMapContext context = new BuildMapContext();
|
||||||
var packageName = buildParameters.PackageName;
|
var packageName = buildParameters.PackageName;
|
||||||
|
|
||||||
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
Dictionary<string, BuildAssetInfo> allBuildAssetInfos = new Dictionary<string, BuildAssetInfo>(1000);
|
||||||
|
|
||||||
// 1. 获取所有收集器收集的资源
|
// 1. 获取所有收集器收集的资源
|
||||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(buildMode, packageName);
|
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||||
List<CollectAssetInfo> allCollectAssetInfos = collectResult.CollectAssets;
|
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, useAssetDependencyDB, packageName);
|
||||||
|
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.TryGetValue(dependAsset.AssetPath, out var value))
|
||||||
{
|
{
|
||||||
allBuildAssetInfos[dependAssetPath].AddReferenceBundleName(bundleName);
|
value.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)
|
||||||
|
{
|
||||||
|
// 获取着色器打包规则结果
|
||||||
|
PackRuleResult shaderPackRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
|
string shaderBundleName = shaderPackRuleResult.GetBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.CollectorType == ECollectorType.None)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.AssetInfo.IsShaderAsset())
|
||||||
|
{
|
||||||
|
buildAssetInfo.SetBundleName(shaderBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 7. 计算共享资源的包名
|
||||||
|
if (buildParameters.EnableSharePackRule)
|
||||||
|
{
|
||||||
|
PreProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||||
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
|
{
|
||||||
|
if (buildAssetInfo.HasBundleName() == false)
|
||||||
|
{
|
||||||
|
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||||
|
if (packRuleResult.IsValid())
|
||||||
|
{
|
||||||
|
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||||
|
buildAssetInfo.SetBundleName(shareBundleName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PostProcessPackShareBundle();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 8. 记录关键信息
|
||||||
context.AssetFileCount = allBuildAssetInfos.Count;
|
context.AssetFileCount = allBuildAssetInfos.Count;
|
||||||
context.Command = collectResult.Command;
|
context.Command = collectResult.Command;
|
||||||
|
|
||||||
// 7. 记录冗余资源
|
// 9. 移除不参与构建的资源
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
|
||||||
{
|
|
||||||
if (buildAssetInfo.IsRedundancyAsset())
|
|
||||||
{
|
|
||||||
var redundancyInfo = new ReportRedundancyInfo();
|
|
||||||
redundancyInfo.AssetPath = buildAssetInfo.AssetPath;
|
|
||||||
redundancyInfo.AssetType = buildAssetInfo.AssetType.Name;
|
|
||||||
redundancyInfo.AssetGUID = buildAssetInfo.AssetGUID;
|
|
||||||
redundancyInfo.FileSize = FileUtility.GetFileSize(buildAssetInfo.AssetPath);
|
|
||||||
redundancyInfo.Number = buildAssetInfo.GetReferenceBundleCount();
|
|
||||||
context.RedundancyInfos.Add(redundancyInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 8. 移除不参与构建的资源
|
|
||||||
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
List<BuildAssetInfo> removeBuildList = new List<BuildAssetInfo>();
|
||||||
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
foreach (var buildAssetInfo in allBuildAssetInfos.Values)
|
||||||
{
|
{
|
||||||
@@ -112,13 +133,16 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
foreach (var removeValue in removeBuildList)
|
foreach (var removeValue in removeBuildList)
|
||||||
{
|
{
|
||||||
allBuildAssetInfos.Remove(removeValue.AssetPath);
|
allBuildAssetInfos.Remove(removeValue.AssetInfo.AssetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 9. 构建资源列表
|
// 10. 构建资源列表
|
||||||
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 +150,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,9 +186,44 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region 共享资源打包规则
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包前置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PreProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 共享资源打包后置处理
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void PostProcessPackShareBundle()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取共享资源包名称
|
||||||
|
/// </summary>
|
||||||
|
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||||
|
{
|
||||||
|
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||||
|
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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,17 +62,8 @@ 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)
|
|
||||||
{
|
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
|
||||||
return HashUtility.BytesMD5(bytes);
|
|
||||||
|
|
||||||
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
|
||||||
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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
|
||||||
@@ -21,30 +20,27 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 开始构建
|
// 开始构建
|
||||||
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)
|
// 检测输出目录
|
||||||
{
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,22 +6,16 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,14 +5,13 @@ 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;
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(true, true, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
|||||||
@@ -3,28 +3,23 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
CreatePackagePatch(buildParameters, buildMapContext);
|
||||||
if (buildMode != EBuildMode.SimulateBuild && buildMode != EBuildMode.DryRunBuild)
|
|
||||||
{
|
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackagePatch(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 +41,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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -14,12 +13,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,13 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,13 +7,12 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -18,12 +17,42 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
|
// 检测是否有未保存场景
|
||||||
|
if (EditorTools.HasDirtyScenes())
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除包裹目录
|
||||||
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
|
{
|
||||||
|
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||||
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果输出目录不存在
|
||||||
|
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||||
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
|
}
|
||||||
|
|
||||||
// 检测Unity版本
|
// 检测Unity版本
|
||||||
#if UNITY_2021_3_OR_NEWER
|
#if UNITY_2021_3_OR_NEWER
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
string warning = BuildLogger.GetErrorMessage(ErrorCode.RecommendScriptBuildPipeline, $"Starting with UnityEngine2021, recommend use script build pipeline (SBP) !");
|
||||||
{
|
BuildLogger.Warning(warning);
|
||||||
BuildLogger.Warning("Unity2021版本开始内置构建管线不再维护,推荐使用可编程构建管线(SBP)!");
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -15,64 +14,45 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var parameters = buildParametersContext.Parameters;
|
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
return "00000000000000000000000000000000"; //32位
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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)
|
||||||
{
|
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var parameters = buildParametersContext.Parameters;
|
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
return crc;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
}
|
||||||
return GetFilePathTempHash(filePath);
|
|
||||||
else
|
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;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.DryRunBuild || buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -16,10 +15,6 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
var buildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParameters.VerifyBuildingResult)
|
if (buildParameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
@@ -33,36 +28,41 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
private void VerifyingBuildingResult(BuildContext context, AssetBundleManifest unityManifest)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
string[] unityCreateBundles = unityManifest.GetAllAssetBundles();
|
string[] unityBuildContent = unityManifest.GetAllAssetBundles();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 计划内容
|
||||||
string[] mapBundles = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
string[] planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToArray();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证差异
|
||||||
List<string> exceptBundleList1 = unityCreateBundles.Except(mapBundles).ToList();
|
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
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("存在差异资源包!请查看警告信息!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
List<string> exceptBundleList2 = mapBundles.Except(unityCreateBundles).ToList();
|
throw new Exception(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 验证差异
|
||||||
|
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
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!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -34,18 +34,12 @@ namespace YooAsset.Editor
|
|||||||
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
BuildAssetBundleOptions opt = BuildAssetBundleOptions.None;
|
||||||
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
opt |= BuildAssetBundleOptions.StrictMode; //Do not allow the build to succeed if any errors are reporting during it.
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.DryRunBuild)
|
|
||||||
{
|
|
||||||
opt |= BuildAssetBundleOptions.DryRunBuild;
|
|
||||||
return opt;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CompressOption == ECompressOption.Uncompressed)
|
if (CompressOption == ECompressOption.Uncompressed)
|
||||||
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
opt |= BuildAssetBundleOptions.UncompressedAssetBundle;
|
||||||
else if (CompressOption == ECompressOption.LZ4)
|
else if (CompressOption == ECompressOption.LZ4)
|
||||||
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
opt |= BuildAssetBundleOptions.ChunkBasedCompression;
|
||||||
|
|
||||||
if (BuildMode == EBuildMode.ForceRebuild)
|
if (ClearBuildCacheFiles)
|
||||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
public class BuiltinBuildPipeline : IBuildPipeline
|
public class BuiltinBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is BuiltinBuildParameters)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
@@ -22,15 +26,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: a82eeb6a47cd02c4cb38e851c8ed8784
|
guid: 12f78ad22f0513c44b6037469dbd6363
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 8a97534752300584a9b8c60c04c6a6a8
|
guid: 1138888cdba447345abb498b0c89affa
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateManifest_ESBP : TaskCreateManifest, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
CreateManifestFile(false, false, context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
|
{
|
||||||
|
return Array.Empty<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 0b6f2523a865e454d8fa3f48a2852d5a
|
guid: 120e126cc10604c4f811c3b6377f7452
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskGetBuildMap_ESBP : TaskGetBuildMap, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
|
context.SetContextObject(buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: f01d5c82be95c8f4b93aeefc0454ae5c
|
guid: 789c337b5b82f1c438a588982dfca346
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskPrepare_ESBP : IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
|
|
||||||
|
// 检测基础构建参数
|
||||||
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 7fbb7b27f54d3b0439a951348fd9d785
|
guid: abbe56a7120e34349b10f20956ed51a7
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
|
||||||
|
using System.Text;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskUpdateBundleInfo_ESBP : TaskUpdateBundleInfo, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
UpdateBundleInfo(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return "00000000000000000000000000000000"; //32位
|
||||||
|
}
|
||||||
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
|
return GetFilePathTempHash(filePath);
|
||||||
|
}
|
||||||
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
return "00000000"; //8位
|
||||||
|
}
|
||||||
|
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
|
{
|
||||||
|
return GetBundleTempSize(bundleInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetFilePathTempHash(string filePath)
|
||||||
|
{
|
||||||
|
byte[] bytes = Encoding.UTF8.GetBytes(filePath);
|
||||||
|
return HashUtility.BytesMD5(bytes);
|
||||||
|
|
||||||
|
// 注意:在文件路径的哈希值冲突的情况下,可以使用下面的方法
|
||||||
|
//return $"{HashUtility.BytesMD5(bytes)}-{Guid.NewGuid():N}";
|
||||||
|
}
|
||||||
|
private 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 35749e57d9a3da84aa60c348bc6bbe9d
|
guid: 990b41f647b80a34ab666a3b0c1ba3f6
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class EditorSimulateBuildParameters : BuildParameters
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 03ea37371e6dc644cb2e6eabf9e7e2ad
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class EditorSimulateBuildPipeline : IBuildPipeline
|
||||||
|
{
|
||||||
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is EditorSimulateBuildParameters)
|
||||||
|
{
|
||||||
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取默认的构建流程
|
||||||
|
/// </summary>
|
||||||
|
private List<IBuildTask> GetDefaultBuildPipeline()
|
||||||
|
{
|
||||||
|
List<IBuildTask> pipeline = new List<IBuildTask>
|
||||||
|
{
|
||||||
|
new TaskPrepare_ESBP(),
|
||||||
|
new TaskGetBuildMap_ESBP(),
|
||||||
|
new TaskUpdateBundleInfo_ESBP(),
|
||||||
|
new TaskCreateManifest_ESBP()
|
||||||
|
};
|
||||||
|
return pipeline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 9caf8e4846ad8b64eb04a4d5179942ff
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -5,21 +5,14 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
CopyRawBundle(buildMapContext, buildParametersContext);
|
CopyRawBundle(buildMapContext, buildParametersContext);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝原生文件
|
/// 拷贝原生文件
|
||||||
@@ -30,9 +23,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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -14,14 +13,10 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters;
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
if (buildParameters.BuildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -5,17 +5,16 @@ 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)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(false, true, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
{
|
{
|
||||||
return new string[] { };
|
return Array.Empty<string>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,29 +3,22 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
CreatePackagePatch(buildParameters, buildMapContext);
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackagePatch(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 +26,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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -14,12 +13,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskEncryption_RFBP : TaskEncryption, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b3e156139dcc25f4c9440ec3d6cb96d2
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -7,13 +7,12 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(true, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
|
|
||||||
// 检测构建结果
|
// 检测构建结果
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -17,11 +16,30 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 删除包裹目录
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
{
|
||||||
if (buildParameters.BuildMode == EBuildMode.IncrementalBuild)
|
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.IncrementalBuild)} build mode !");
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果输出目录不存在
|
||||||
|
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||||
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
@@ -15,46 +14,27 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var parameters = buildParametersContext.Parameters;
|
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
return "00000000000000000000000000000000"; //32位
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
string filePath = bundleInfo.PackageSourceFilePath;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileHash(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return GetFilePathTempHash(filePath);
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,17 @@ namespace YooAsset.Editor
|
|||||||
public class RawFileBuildPipeline : IBuildPipeline
|
public class RawFileBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is RawFileBuildParameters)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
@@ -22,14 +29,15 @@ 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 TaskEncryption_RFBP(),
|
||||||
new TaskCreateManifest_RFBP(), //创建清单文件
|
new TaskUpdateBundleInfo_RFBP(),
|
||||||
new TaskCreateReport_RFBP(), //创建报告文件
|
new TaskCreateManifest_RFBP(),
|
||||||
new TaskCreatePackage_RFBP(), //制作包裹
|
new TaskCreateReport_RFBP(),
|
||||||
new TaskCopyBuildinFiles_RFBP(), //拷贝内置文件
|
new TaskCreatePackage_RFBP(),
|
||||||
|
new TaskCopyBuildinFiles_RFBP(),
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -22,22 +21,18 @@ namespace YooAsset.Editor
|
|||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过引擎构建
|
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 构建内容
|
// 构建内容
|
||||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||||
|
|
||||||
// 开始构建
|
// 开始构建
|
||||||
IBundleBuildResults buildResults;
|
IBundleBuildResults buildResults;
|
||||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName);
|
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName, null);
|
||||||
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 +44,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);
|
||||||
|
|||||||
@@ -6,22 +6,16 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
|
||||||
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
{
|
{
|
||||||
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
CopyBuildinFilesToStreaming(buildParametersContext, manifestContext.Manifest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,14 +7,13 @@ 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;
|
||||||
|
|
||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
CreateManifestFile(context);
|
CreateManifestFile(true, true, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,29 +3,24 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
CreatePackagePatch(buildParameters, buildMapContext);
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CopyPackageFiles(buildParameters, buildMapContext);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 拷贝补丁文件到补丁包目录
|
/// 拷贝补丁文件到补丁包目录
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void CopyPackageFiles(BuildParametersContext buildParametersContext, BuildMapContext buildMapContext)
|
private void CreatePackagePatch(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 +43,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();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -14,12 +13,7 @@ namespace YooAsset.Editor
|
|||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
var manifestContext = context.GetContextObject<ManifestContext>();
|
var manifestContext = context.GetContextObject<ManifestContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode != EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
CreateReportFile(buildParameters, buildMapContext, manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -1,24 +1,13 @@
|
|||||||
using System;
|
|
||||||
using System.Linq;
|
|
||||||
using System.IO;
|
|
||||||
using System.Collections;
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
|
|
||||||
var buildMode = buildParameters.Parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.ForceRebuild || buildMode == EBuildMode.IncrementalBuild)
|
|
||||||
{
|
|
||||||
EncryptingBundleFiles(buildParameters, buildMapContext);
|
EncryptingBundleFiles(buildParameters, buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -7,13 +7,12 @@ 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)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildMapContext = CreateBuildMap(buildParametersContext.Parameters);
|
var buildMapContext = CreateBuildMap(false, buildParametersContext.Parameters);
|
||||||
context.SetContextObject(buildMapContext);
|
context.SetContextObject(buildMapContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -17,11 +16,40 @@ namespace YooAsset.Editor
|
|||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
|
|
||||||
// 检测不被支持的构建模式
|
// 检测是否有未保存场景
|
||||||
if (buildParameters.BuildMode == EBuildMode.DryRunBuild)
|
if (EditorTools.HasDirtyScenes())
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.DryRunBuild)} build mode !");
|
{
|
||||||
if (buildParameters.BuildMode == EBuildMode.ForceRebuild)
|
string message = BuildLogger.GetErrorMessage(ErrorCode.FoundUnsavedScene, "Found unsaved scene !");
|
||||||
throw new Exception($"{nameof(EBuildPipeline.ScriptableBuildPipeline)} not support {nameof(EBuildMode.ForceRebuild)} build mode !");
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除包裹目录
|
||||||
|
if (buildParameters.ClearBuildCacheFiles)
|
||||||
|
{
|
||||||
|
// Deletes the build cache directory.
|
||||||
|
UnityEditor.Build.Pipeline.Utilities.BuildCache.PurgeCache(false);
|
||||||
|
|
||||||
|
string packageRootDirectory = buildParameters.GetPackageRootDirectory();
|
||||||
|
if (EditorTools.DeleteDirectory(packageRootDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Delete package root directory: {packageRootDirectory}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检测包裹输出目录是否存在
|
||||||
|
string packageOutputDirectory = buildParameters.GetPackageOutputDirectory();
|
||||||
|
if (Directory.Exists(packageOutputDirectory))
|
||||||
|
{
|
||||||
|
string message = BuildLogger.GetErrorMessage(ErrorCode.PackageOutputDirectoryExists, $"Package outout directory exists: {packageOutputDirectory}");
|
||||||
|
throw new Exception(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果输出目录不存在
|
||||||
|
string pipelineOutputDirectory = buildParameters.GetPipelineOutputDirectory();
|
||||||
|
if (EditorTools.CreateDirectory(pipelineOutputDirectory))
|
||||||
|
{
|
||||||
|
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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)
|
||||||
@@ -15,64 +14,45 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||||
{
|
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var parameters = buildParametersContext.Parameters;
|
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
return "00000000000000000000000000000000"; //32位
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
// 注意:当资源包的依赖列表发生变化的时候,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)
|
||||||
{
|
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var parameters = buildParametersContext.Parameters;
|
|
||||||
var buildMode = parameters.BuildMode;
|
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
return value.Crc;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
}
|
||||||
return GetFilePathTempHash(filePath);
|
|
||||||
else
|
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;
|
||||||
return HashUtility.FileMD5(filePath);
|
return HashUtility.FileMD5(filePath);
|
||||||
}
|
}
|
||||||
protected override string GetBundleFileCRC(string filePath, BuildParametersContext buildParametersContext)
|
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return "00000000"; //8位
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var buildMode = buildParametersContext.Parameters.BuildMode;
|
string filePath = bundleInfo.PackageSourceFilePath;
|
||||||
if (buildMode == EBuildMode.SimulateBuild)
|
|
||||||
return 0;
|
|
||||||
else
|
|
||||||
return FileUtility.GetFileSize(filePath);
|
return FileUtility.GetFileSize(filePath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
@@ -17,10 +16,6 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
|
|
||||||
// 模拟构建模式下跳过验证
|
|
||||||
if (buildParameters.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
return;
|
|
||||||
|
|
||||||
// 验证构建结果
|
// 验证构建结果
|
||||||
if (buildParameters.VerifyBuildingResult)
|
if (buildParameters.VerifyBuildingResult)
|
||||||
{
|
{
|
||||||
@@ -34,36 +29,41 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
private void VerifyingBuildingResult(BuildContext context, IBundleBuildResults buildResults)
|
||||||
{
|
{
|
||||||
var buildParameters = context.GetContextObject<BuildParametersContext>();
|
|
||||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||||
List<string> unityCreateBundles = buildResults.BundleInfos.Keys.ToList();
|
List<string> unityBuildContent = buildResults.BundleInfos.Keys.ToList();
|
||||||
|
|
||||||
// 1. 过滤掉原生Bundle
|
// 1. 计划内容
|
||||||
List<string> expectBundles = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
List<string> planningContent = buildMapContext.Collection.Select(t => t.BundleName).ToList();
|
||||||
|
|
||||||
// 2. 验证Bundle
|
// 2. 验证差异
|
||||||
List<string> exceptBundleList1 = unityCreateBundles.Except(expectBundles).ToList();
|
List<string> exceptBundleList1 = unityBuildContent.Except(planningContent).ToList();
|
||||||
if (exceptBundleList1.Count > 0)
|
if (exceptBundleList1.Count > 0)
|
||||||
{
|
{
|
||||||
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("存在差异资源包!请查看警告信息!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. 验证Bundle
|
string exception = BuildLogger.GetErrorMessage(ErrorCode.UnintendedBuildResult, $"Unintended build, See the detailed warnings !");
|
||||||
List<string> exceptBundleList2 = expectBundles.Except(unityCreateBundles).ToList();
|
throw new Exception(exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 验证差异
|
||||||
|
List<string> exceptBundleList2 = planningContent.Except(unityBuildContent).ToList();
|
||||||
if (exceptBundleList2.Count > 0)
|
if (exceptBundleList2.Count > 0)
|
||||||
{
|
{
|
||||||
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!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
{
|
{
|
||||||
public static class SBPBuildTasks
|
public static class SBPBuildTasks
|
||||||
{
|
{
|
||||||
public static IList<IBuildTask> Create(string builtInShaderBundleName)
|
public static IList<IBuildTask> Create(string builtInShaderBundleName, string unityMonoScriptsBundleName)
|
||||||
{
|
{
|
||||||
var buildTasks = new List<IBuildTask>();
|
var buildTasks = new List<IBuildTask>();
|
||||||
|
|
||||||
@@ -28,12 +28,14 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
|||||||
#endif
|
#endif
|
||||||
buildTasks.Add(new CalculateAssetDependencyData());
|
buildTasks.Add(new CalculateAssetDependencyData());
|
||||||
buildTasks.Add(new StripUnusedSpriteSources());
|
buildTasks.Add(new StripUnusedSpriteSources());
|
||||||
|
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
||||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||||
|
if (string.IsNullOrEmpty(unityMonoScriptsBundleName) == false)
|
||||||
|
buildTasks.Add(new CreateMonoScriptBundle(unityMonoScriptsBundleName));
|
||||||
buildTasks.Add(new PostDependencyCallback());
|
buildTasks.Add(new PostDependencyCallback());
|
||||||
|
|
||||||
// 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());
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
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
|
||||||
{
|
{
|
||||||
public class ScriptableBuildPipeline : IBuildPipeline
|
public class ScriptableBuildPipeline : IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
public BuildResult Run(BuildParameters buildParameters, bool enableLog)
|
||||||
|
{
|
||||||
|
if (buildParameters is ScriptableBuildParameters)
|
||||||
{
|
{
|
||||||
AssetBundleBuilder builder = new AssetBundleBuilder();
|
AssetBundleBuilder builder = new AssetBundleBuilder();
|
||||||
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
return builder.Run(buildParameters, GetDefaultBuildPipeline(), enableLog);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"Invalid build parameter type : {buildParameters.GetType().Name}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取默认的构建流程
|
/// 获取默认的构建流程
|
||||||
@@ -22,15 +26,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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|
||||||
|
// 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,
|
||||||
|
BundleHashConflict = 602,
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c3a10fd19801c0c428bac53081a96517
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 资源包流水线的构建模式
|
|
||||||
/// </summary>
|
|
||||||
public enum EBuildMode
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 强制重建模式
|
|
||||||
/// </summary>
|
|
||||||
ForceRebuild,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 增量构建模式
|
|
||||||
/// </summary>
|
|
||||||
IncrementalBuild,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 演练构建模式
|
|
||||||
/// </summary>
|
|
||||||
DryRunBuild,
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 模拟构建模式
|
|
||||||
/// </summary>
|
|
||||||
SimulateBuild,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -6,6 +6,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public enum EBuildPipeline
|
public enum EBuildPipeline
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 编辑器下的模拟构建管线(ESBP)
|
||||||
|
/// </summary>
|
||||||
|
EditorSimulateBuildPipeline,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 传统内置构建管线 (BBP)
|
/// 传统内置构建管线 (BBP)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -3,6 +3,6 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public interface IBuildPipeline
|
public interface IBuildPipeline
|
||||||
{
|
{
|
||||||
public BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ namespace YooAsset.Editor
|
|||||||
internal abstract class BuildPipelineViewerBase
|
internal abstract class BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
private const int StyleWidth = 400;
|
private const int StyleWidth = 400;
|
||||||
|
private const int LabelMinWidth = 180;
|
||||||
|
|
||||||
protected readonly string PackageName;
|
protected readonly string PackageName;
|
||||||
protected readonly BuildTarget BuildTarget;
|
protected readonly BuildTarget BuildTarget;
|
||||||
@@ -27,6 +28,8 @@ namespace YooAsset.Editor
|
|||||||
private EnumField _outputNameStyleField;
|
private EnumField _outputNameStyleField;
|
||||||
private EnumField _copyBuildinFileOptionField;
|
private EnumField _copyBuildinFileOptionField;
|
||||||
private TextField _copyBuildinFileTagsField;
|
private TextField _copyBuildinFileTagsField;
|
||||||
|
private Toggle _clearBuildCacheToggle;
|
||||||
|
private Toggle _useAssetDependencyDBToggle;
|
||||||
|
|
||||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||||
{
|
{
|
||||||
@@ -39,7 +42,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,34 +51,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 buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
|
||||||
var buildModeList = GetSupportBuildModes();
|
|
||||||
int defaultIndex = buildModeList.FindIndex(x => x.Equals(buildMode));
|
|
||||||
_buildModeField = new PopupField<Enum>(buildModeList, defaultIndex);
|
|
||||||
_buildModeField.label = "BuildMode";
|
|
||||||
_buildModeField.style.width = StyleWidth;
|
|
||||||
_buildModeField.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
AssetBundleBuilderSetting.SetPackageBuildMode(PackageName, BuildPipeline, (EBuildMode)_buildModeField.value);
|
|
||||||
});
|
|
||||||
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));
|
||||||
@@ -83,6 +70,8 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||||
|
if (defaultIndex < 0)
|
||||||
|
defaultIndex = 0;
|
||||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||||
_encryptionField.label = "Encryption";
|
_encryptionField.label = "Encryption";
|
||||||
_encryptionField.style.width = StyleWidth;
|
_encryptionField.style.width = StyleWidth;
|
||||||
@@ -101,7 +90,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 +101,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 +112,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 +124,45 @@ 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>ť
|
// 清理构建缓存
|
||||||
|
bool clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||||
|
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||||
|
_clearBuildCacheToggle.SetValueWithoutNotify(clearBuildCache);
|
||||||
|
_clearBuildCacheToggle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSetting.SetPackageClearBuildCache(PackageName, BuildPipeline, _clearBuildCacheToggle.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 使用资源依赖数据库
|
||||||
|
bool useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||||
|
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||||
|
_useAssetDependencyDBToggle.SetValueWithoutNotify(useAssetDependencyDB);
|
||||||
|
_useAssetDependencyDBToggle.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSetting.SetPackageUseAssetDependencyDB(PackageName, BuildPipeline, _useAssetDependencyDBToggle.value);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 对齐文本间距
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_buildOutputField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_buildVersionField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_compressionField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_encryptionField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_outputNameStyleField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_copyBuildinFileOptionField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_copyBuildinFileTagsField, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_clearBuildCacheToggle, LabelMinWidth);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(_useAssetDependencyDBToggle, LabelMinWidth);
|
||||||
|
|
||||||
|
// 构建按钮
|
||||||
var buildButton = Root.Q<Button>("Build");
|
var buildButton = Root.Q<Button>("Build");
|
||||||
buildButton.clicked += BuildButton_clicked;
|
buildButton.clicked += BuildButton_clicked;
|
||||||
}
|
}
|
||||||
@@ -156,30 +174,24 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void BuildButton_clicked()
|
private void BuildButton_clicked()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||||
if (EditorUtility.DisplayDialog("<22><>ʾ", $"ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ģʽ<C4A3><CABD>{buildMode}<7D><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "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>
|
|
||||||
protected abstract List<Enum> GetSupportBuildModes();
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD>汾
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected string GetPackageVersion()
|
protected string GetPackageVersion()
|
||||||
{
|
{
|
||||||
@@ -187,7 +199,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()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
<ui:VisualElement name="BuildContainer">
|
<ui:VisualElement name="BuildContainer">
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||||
<ui:VisualElement name="BuildModeContainer" style="height: 24px;" />
|
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||||
|
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||||
<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>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,46 +18,40 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ִ<>й<EFBFBD><D0B9><EFBFBD>
|
/// 执行构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
|
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||||
|
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||||
|
|
||||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
|
||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
|
||||||
{
|
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
|
||||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
|
||||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
|
||||||
buildModeList.Add(EBuildMode.DryRunBuild);
|
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
|
||||||
return buildModeList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
internal class EditorSimulateBuildPipelineViewer : BuildPipelineViewerBase
|
||||||
|
{
|
||||||
|
public EditorSimulateBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||||
|
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||||
|
{
|
||||||
|
var compressionField = Root.Q<EnumField>("Compression");
|
||||||
|
UIElementsTools.SetElementVisible(compressionField, false);
|
||||||
|
|
||||||
|
var encryptionContainer = Root.Q<VisualElement>("EncryptionContainer");
|
||||||
|
UIElementsTools.SetElementVisible(encryptionContainer, false);
|
||||||
|
|
||||||
|
var fileNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||||
|
UIElementsTools.SetElementVisible(fileNameStyleField, false);
|
||||||
|
|
||||||
|
var copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||||
|
UIElementsTools.SetElementVisible(copyBuildinFileOptionField, false);
|
||||||
|
|
||||||
|
var copyBuildinFileParamField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||||
|
UIElementsTools.SetElementVisible(copyBuildinFileParamField, false);
|
||||||
|
|
||||||
|
var clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||||
|
UIElementsTools.SetElementVisible(clearBuildCacheToggle, false);
|
||||||
|
|
||||||
|
var useAssetDependencyToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||||
|
UIElementsTools.SetElementVisible(useAssetDependencyToggle, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行构建
|
||||||
|
/// </summary>
|
||||||
|
protected override void ExecuteBuild()
|
||||||
|
{
|
||||||
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
|
|
||||||
|
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||||
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||||
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
|
buildParameters.PackageName = PackageName;
|
||||||
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.VerifyBuildingResult = true;
|
||||||
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
|
EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline();
|
||||||
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
|
if (buildResult.Success)
|
||||||
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 01e426f05b237b340881910d779e4c2e
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
#if UNITY_2019_4_OR_NEWER
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -20,27 +20,30 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ִ<>й<EFBFBD><D0B9><EFBFBD>
|
/// 执行构建
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
|
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||||
|
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||||
|
|
||||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||||
@@ -48,14 +51,6 @@ namespace YooAsset.Editor
|
|||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
|
||||||
{
|
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
|
||||||
buildModeList.Add(EBuildMode.ForceRebuild);
|
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
|
||||||
return buildModeList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -22,40 +22,36 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void ExecuteBuild()
|
protected override void ExecuteBuild()
|
||||||
{
|
{
|
||||||
var buildMode = AssetBundleBuilderSetting.GetPackageBuildMode(PackageName, BuildPipeline);
|
|
||||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||||
|
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||||
|
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||||
|
|
||||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||||
|
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||||
buildParameters.BuildTarget = BuildTarget;
|
buildParameters.BuildTarget = BuildTarget;
|
||||||
buildParameters.BuildMode = buildMode;
|
|
||||||
buildParameters.PackageName = PackageName;
|
buildParameters.PackageName = PackageName;
|
||||||
buildParameters.PackageVersion = GetPackageVersion();
|
buildParameters.PackageVersion = GetPackageVersion();
|
||||||
|
buildParameters.EnableSharePackRule = true;
|
||||||
buildParameters.VerifyBuildingResult = true;
|
buildParameters.VerifyBuildingResult = true;
|
||||||
buildParameters.FileNameStyle = fileNameStyle;
|
buildParameters.FileNameStyle = fileNameStyle;
|
||||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
|
||||||
buildParameters.CompressOption = compressOption;
|
buildParameters.CompressOption = compressOption;
|
||||||
|
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||||
|
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
|
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||||
|
|
||||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||||
var buildResult = pipeline.Run(buildParameters, true);
|
var buildResult = pipeline.Run(buildParameters, true);
|
||||||
if (buildResult.Success)
|
if (buildResult.Success)
|
||||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override List<Enum> GetSupportBuildModes()
|
|
||||||
{
|
|
||||||
List<Enum> buildModeList = new List<Enum>();
|
|
||||||
buildModeList.Add(EBuildMode.IncrementalBuild);
|
|
||||||
buildModeList.Add(EBuildMode.SimulateBuild);
|
|
||||||
return buildModeList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -140,7 +140,7 @@ namespace YooAsset.Editor
|
|||||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
// 注意:模拟构建模式下只收集主资源
|
// 注意:模拟构建模式下只收集主资源
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
if (command.SimulateBuild)
|
||||||
{
|
{
|
||||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
@@ -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 (command.IgnoreRule.IsIgnore(assetInfo) == false && 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,27 @@ 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);
|
||||||
|
collectAssetInfo.DependAssets = GetAllDependencies(command, assetInfo.AssetPath);
|
||||||
// 注意:模拟构建模式下不需要收集依赖资源
|
|
||||||
if (command.BuildMode == EBuildMode.SimulateBuild)
|
|
||||||
collectAssetInfo.DependAssets = new List<string>();
|
|
||||||
else
|
|
||||||
collectAssetInfo.DependAssets = GetAllDependencies(command, assetPath);
|
|
||||||
|
|
||||||
return collectAssetInfo;
|
return collectAssetInfo;
|
||||||
}
|
}
|
||||||
private bool IsValidateAsset(CollectCommand command, string assetPath)
|
|
||||||
{
|
|
||||||
if (assetPath.StartsWith("Assets/") == false && assetPath.StartsWith("Packages/") == false)
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogError($"Invalid asset path : {assetPath}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 忽略文件夹
|
private bool IsCollectAsset(AssetBundleCollectorGroup group, AssetInfo assetInfo)
|
||||||
if (AssetDatabase.IsValidFolder(assetPath))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 忽略编辑器下的类型资源
|
|
||||||
Type assetType = AssetDatabase.GetMainAssetTypeAtPath(assetPath);
|
|
||||||
if (assetType == typeof(LightingDataAsset))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// 忽略Unity引擎无法识别的文件
|
|
||||||
if (command.IgnoreDefaultType)
|
|
||||||
{
|
|
||||||
if (assetType == typeof(UnityEditor.DefaultAsset))
|
|
||||||
{
|
|
||||||
UnityEngine.Debug.LogWarning($"Cannot pack default asset : {assetPath}");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string fileExtension = System.IO.Path.GetExtension(assetPath);
|
|
||||||
if (DefaultFilterRule.IsIgnoreFile(fileExtension))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
private bool IsCollectAsset(AssetBundleCollectorGroup group, string assetPath)
|
|
||||||
{
|
{
|
||||||
// 根据规则设置过滤资源文件
|
// 根据规则设置过滤资源文件
|
||||||
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 +237,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 +254,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 +264,23 @@ 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);
|
// 注意:模拟构建模式下不需要收集依赖资源
|
||||||
List<string> result = new List<string>(depends.Length);
|
if (command.SimulateBuild)
|
||||||
|
return new List<AssetInfo>();
|
||||||
|
|
||||||
|
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);
|
||||||
|
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 (command.IgnoreRule.IsIgnore(assetInfo) == false)
|
||||||
|
result.Add(assetInfo);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public class AssetBundleCollectorConfig
|
public class AssetBundleCollectorConfig
|
||||||
{
|
{
|
||||||
public const string ConfigVersion = "v2.0.0";
|
public const string ConfigVersion = "v2.1";
|
||||||
|
|
||||||
public const string XmlVersion = "Version";
|
public const string XmlVersion = "Version";
|
||||||
public const string XmlCommon = "Common";
|
public const string XmlCommon = "Common";
|
||||||
@@ -25,7 +25,7 @@ namespace YooAsset.Editor
|
|||||||
public const string XmlEnableAddressable = "AutoAddressable";
|
public const string XmlEnableAddressable = "AutoAddressable";
|
||||||
public const string XmlLocationToLower = "LocationToLower";
|
public const string XmlLocationToLower = "LocationToLower";
|
||||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||||
public const string XmlIgnoreDefaultType = "IgnoreDefaultType";
|
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
||||||
|
|
||||||
public const string XmlGroup = "Group";
|
public const string XmlGroup = "Group";
|
||||||
public const string XmlGroupActiveRule = "GroupActiveRule";
|
public const string XmlGroupActiveRule = "GroupActiveRule";
|
||||||
@@ -101,7 +101,7 @@ namespace YooAsset.Editor
|
|||||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||||
package.IgnoreDefaultType = packageElement.GetAttribute(XmlIgnoreDefaultType) == "True" ? true : false;
|
package.IgnoreRuleName = packageElement.GetAttribute(XmlIgnoreRuleName);
|
||||||
packages.Add(package);
|
packages.Add(package);
|
||||||
|
|
||||||
// 读取分组配置
|
// 读取分组配置
|
||||||
@@ -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>
|
||||||
@@ -213,7 +213,7 @@ namespace YooAsset.Editor
|
|||||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||||
packageElement.SetAttribute(XmlIgnoreDefaultType, package.IgnoreDefaultType.ToString());
|
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
||||||
root.AppendChild(packageElement);
|
root.AppendChild(packageElement);
|
||||||
|
|
||||||
// 设置分组配置
|
// 设置分组配置
|
||||||
@@ -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>
|
||||||
@@ -258,6 +258,23 @@ namespace YooAsset.Editor
|
|||||||
if (configVersion == ConfigVersion)
|
if (configVersion == ConfigVersion)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
// v2.0.0 -> v2.1
|
||||||
|
if (configVersion == "v2.0.0")
|
||||||
|
{
|
||||||
|
// 读取包裹配置
|
||||||
|
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||||
|
foreach (var packageNode in packageNodeList)
|
||||||
|
{
|
||||||
|
XmlElement packageElement = packageNode as XmlElement;
|
||||||
|
if (packageElement.HasAttribute(XmlIgnoreRuleName) == false)
|
||||||
|
packageElement.SetAttribute(XmlIgnoreRuleName, nameof(NormalIgnoreRule));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新版本
|
||||||
|
root.SetAttribute(XmlVersion, "v2.1");
|
||||||
|
return UpdateXmlConfig(xmlDoc);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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(new GroupData(GroupName)) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
foreach (var collector in Collectors)
|
foreach (var collector in Collectors)
|
||||||
{
|
{
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
@@ -75,7 +80,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 检测分组是否激活
|
// 检测分组是否激活
|
||||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(ActiveRuleName);
|
||||||
if (activeRule.IsActiveGroup() == false)
|
if (activeRule.IsActiveGroup(new GroupData(GroupName)) == false)
|
||||||
{
|
{
|
||||||
return new List<CollectAssetInfo>();
|
return new List<CollectAssetInfo>();
|
||||||
}
|
}
|
||||||
@@ -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;
|
||||||
|
|
||||||
|
|||||||
@@ -35,16 +35,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IncludeAssetGUID = false;
|
public bool IncludeAssetGUID = false;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略Unity引擎无法识别的文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreDefaultType = true;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
/// 自动收集所有着色器(所有着色器存储在一个资源包内)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool AutoCollectShaders = true;
|
public bool AutoCollectShaders = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源忽略规则名
|
||||||
|
/// </summary>
|
||||||
|
public string IgnoreRuleName = nameof(NormalIgnoreRule);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 分组列表
|
/// 分组列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -56,6 +56,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void CheckConfigError()
|
public void CheckConfigError()
|
||||||
{
|
{
|
||||||
|
if (string.IsNullOrEmpty(IgnoreRuleName))
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(IgnoreRuleName)} is null or empty !");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (AssetBundleCollectorSettingData.HasIgnoreRuleName(IgnoreRuleName) == false)
|
||||||
|
throw new Exception($"Invalid {nameof(IIgnoreRule)} class type : {IgnoreRuleName} in package : {PackageName}");
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
group.CheckConfigError();
|
group.CheckConfigError();
|
||||||
@@ -68,6 +78,14 @@ namespace YooAsset.Editor
|
|||||||
public bool FixConfigError()
|
public bool FixConfigError()
|
||||||
{
|
{
|
||||||
bool isFixed = false;
|
bool isFixed = false;
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(IgnoreRuleName))
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Set the {nameof(IgnoreRuleName)} to {nameof(NormalIgnoreRule)}");
|
||||||
|
IgnoreRuleName = nameof(NormalIgnoreRule);
|
||||||
|
isFixed = true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (var group in Groups)
|
foreach (var group in Groups)
|
||||||
{
|
{
|
||||||
if (group.FixConfigError())
|
if (group.FixConfigError())
|
||||||
@@ -75,6 +93,7 @@ namespace YooAsset.Editor
|
|||||||
isFixed = true;
|
isFixed = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return isFixed;
|
return isFixed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,12 +108,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 +126,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;
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool UniqueBundleName = false;
|
public bool UniqueBundleName = false;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹列表
|
/// 包裹列表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -90,7 +89,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取包裹收集的资源文件
|
/// 获取包裹收集的资源文件
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public CollectResult GetPackageAssets(EBuildMode buildMode, string packageName)
|
public CollectResult GetPackageAssets(bool simulateBuild, bool useAssetDependencyDB, string packageName)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(packageName))
|
if (string.IsNullOrEmpty(packageName))
|
||||||
throw new Exception("Build package name is null or empty !");
|
throw new Exception("Build package name is null or empty !");
|
||||||
@@ -100,13 +99,13 @@ namespace YooAsset.Editor
|
|||||||
package.CheckConfigError();
|
package.CheckConfigError();
|
||||||
|
|
||||||
// 创建资源收集命令
|
// 创建资源收集命令
|
||||||
CollectCommand command = new CollectCommand(buildMode, packageName,
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(package.IgnoreRuleName);
|
||||||
|
CollectCommand command = new CollectCommand(simulateBuild, useAssetDependencyDB, packageName,
|
||||||
package.EnableAddressable,
|
package.EnableAddressable,
|
||||||
package.LocationToLower,
|
package.LocationToLower,
|
||||||
package.IncludeAssetGUID,
|
package.IncludeAssetGUID,
|
||||||
package.IgnoreDefaultType,
|
|
||||||
package.AutoCollectShaders,
|
package.AutoCollectShaders,
|
||||||
UniqueBundleName);
|
UniqueBundleName, ignoreRule);
|
||||||
|
|
||||||
// 获取收集的资源集合
|
// 获取收集的资源集合
|
||||||
CollectResult collectResult = new CollectResult(command);
|
CollectResult collectResult = new CollectResult(command);
|
||||||
|
|||||||
@@ -21,6 +21,9 @@ namespace YooAsset.Editor
|
|||||||
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
private static readonly Dictionary<string, System.Type> _cacheFilterRuleTypes = new Dictionary<string, System.Type>();
|
||||||
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
private static readonly Dictionary<string, IFilterRule> _cacheFilterRuleInstance = new Dictionary<string, IFilterRule>();
|
||||||
|
|
||||||
|
private static readonly Dictionary<string, System.Type> _cacheIgnoreRuleTypes = new Dictionary<string, System.Type>();
|
||||||
|
private static readonly Dictionary<string, IIgnoreRule> _cacheIgnoreRuleInstance = new Dictionary<string, IIgnoreRule>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 配置数据是否被修改
|
/// 配置数据是否被修改
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -92,7 +95,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)
|
||||||
@@ -130,6 +132,29 @@ namespace YooAsset.Editor
|
|||||||
_cacheActiveRuleTypes.Add(type.Name, type);
|
_cacheActiveRuleTypes.Add(type.Name, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IIgnoreRule
|
||||||
|
{
|
||||||
|
// 清空缓存集合
|
||||||
|
_cacheIgnoreRuleTypes.Clear();
|
||||||
|
_cacheIgnoreRuleInstance.Clear();
|
||||||
|
|
||||||
|
// 获取所有类型
|
||||||
|
List<Type> types = new List<Type>(100)
|
||||||
|
{
|
||||||
|
typeof(NormalIgnoreRule),
|
||||||
|
typeof(RawFileIgnoreRule),
|
||||||
|
};
|
||||||
|
|
||||||
|
var customTypes = EditorTools.GetAssignableTypes(typeof(IIgnoreRule));
|
||||||
|
types.AddRange(customTypes);
|
||||||
|
for (int i = 0; i < types.Count; i++)
|
||||||
|
{
|
||||||
|
Type type = types[i];
|
||||||
|
if (_cacheIgnoreRuleTypes.ContainsKey(type.Name) == false)
|
||||||
|
_cacheIgnoreRuleTypes.Add(type.Name, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AssetBundleCollectorSetting _setting = null;
|
private static AssetBundleCollectorSetting _setting = null;
|
||||||
@@ -166,6 +191,7 @@ namespace YooAsset.Editor
|
|||||||
if (isFixed)
|
if (isFixed)
|
||||||
{
|
{
|
||||||
IsDirty = true;
|
IsDirty = true;
|
||||||
|
Debug.Log("Fix package config error done !");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -226,6 +252,18 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
public static List<RuleDisplayName> GetIgnoreRuleNames()
|
||||||
|
{
|
||||||
|
List<RuleDisplayName> names = new List<RuleDisplayName>();
|
||||||
|
foreach (var pair in _cacheIgnoreRuleTypes)
|
||||||
|
{
|
||||||
|
RuleDisplayName ruleName = new RuleDisplayName();
|
||||||
|
ruleName.ClassName = pair.Key;
|
||||||
|
ruleName.DisplayName = GetRuleDisplayName(pair.Key, pair.Value);
|
||||||
|
names.Add(ruleName);
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
private static string GetRuleDisplayName(string name, Type type)
|
private static string GetRuleDisplayName(string name, Type type)
|
||||||
{
|
{
|
||||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||||
@@ -237,19 +275,23 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
public static bool HasActiveRuleName(string ruleName)
|
public static bool HasActiveRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheActiveRuleTypes.Keys.Contains(ruleName);
|
return _cacheActiveRuleTypes.ContainsKey(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasAddressRuleName(string ruleName)
|
public static bool HasAddressRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheAddressRuleTypes.Keys.Contains(ruleName);
|
return _cacheAddressRuleTypes.ContainsKey(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasPackRuleName(string ruleName)
|
public static bool HasPackRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cachePackRuleTypes.Keys.Contains(ruleName);
|
return _cachePackRuleTypes.ContainsKey(ruleName);
|
||||||
}
|
}
|
||||||
public static bool HasFilterRuleName(string ruleName)
|
public static bool HasFilterRuleName(string ruleName)
|
||||||
{
|
{
|
||||||
return _cacheFilterRuleTypes.Keys.Contains(ruleName);
|
return _cacheFilterRuleTypes.ContainsKey(ruleName);
|
||||||
|
}
|
||||||
|
public static bool HasIgnoreRuleName(string ruleName)
|
||||||
|
{
|
||||||
|
return _cacheIgnoreRuleTypes.ContainsKey(ruleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
public static IActiveRule GetActiveRuleInstance(string ruleName)
|
||||||
@@ -266,7 +308,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 +325,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 +342,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 +359,24 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new Exception($"{nameof(IFilterRule)}类型无效:{ruleName}");
|
throw new Exception($"{nameof(IFilterRule)} is invalid:{ruleName}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static IIgnoreRule GetIgnoreRuleInstance(string ruleName)
|
||||||
|
{
|
||||||
|
if (_cacheIgnoreRuleInstance.TryGetValue(ruleName, out IIgnoreRule instance))
|
||||||
|
return instance;
|
||||||
|
|
||||||
|
// 如果不存在创建类的实例
|
||||||
|
if (_cacheIgnoreRuleTypes.TryGetValue(ruleName, out Type type))
|
||||||
|
{
|
||||||
|
instance = (IIgnoreRule)Activator.CreateInstance(type);
|
||||||
|
_cacheIgnoreRuleInstance.Add(ruleName, instance);
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception($"{nameof(IIgnoreRule)} is invalid:{ruleName}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,6 +24,7 @@ namespace YooAsset.Editor
|
|||||||
private List<RuleDisplayName> _addressRuleList;
|
private List<RuleDisplayName> _addressRuleList;
|
||||||
private List<RuleDisplayName> _packRuleList;
|
private List<RuleDisplayName> _packRuleList;
|
||||||
private List<RuleDisplayName> _filterRuleList;
|
private List<RuleDisplayName> _filterRuleList;
|
||||||
|
private List<RuleDisplayName> _ignoreRuleList;
|
||||||
|
|
||||||
private VisualElement _helpBoxContainer;
|
private VisualElement _helpBoxContainer;
|
||||||
|
|
||||||
@@ -39,8 +40,8 @@ namespace YooAsset.Editor
|
|||||||
private Toggle _enableAddressableToogle;
|
private Toggle _enableAddressableToogle;
|
||||||
private Toggle _locationToLowerToogle;
|
private Toggle _locationToLowerToogle;
|
||||||
private Toggle _includeAssetGUIDToogle;
|
private Toggle _includeAssetGUIDToogle;
|
||||||
private Toggle _ignoreDefaultTypeToogle;
|
|
||||||
private Toggle _autoCollectShadersToogle;
|
private Toggle _autoCollectShadersToogle;
|
||||||
|
private PopupField<RuleDisplayName> _ignoreRulePopupField;
|
||||||
|
|
||||||
private VisualElement _packageContainer;
|
private VisualElement _packageContainer;
|
||||||
private ListView _packageListView;
|
private ListView _packageListView;
|
||||||
@@ -51,7 +52,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 +66,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>()
|
||||||
@@ -80,6 +78,7 @@ namespace YooAsset.Editor
|
|||||||
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
_addressRuleList = AssetBundleCollectorSettingData.GetAddressRuleNames();
|
||||||
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
_packRuleList = AssetBundleCollectorSettingData.GetPackRuleNames();
|
||||||
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
_filterRuleList = AssetBundleCollectorSettingData.GetFilterRuleNames();
|
||||||
|
_ignoreRuleList = AssetBundleCollectorSettingData.GetIgnoreRuleNames();
|
||||||
|
|
||||||
VisualElement root = this.rootVisualElement;
|
VisualElement root = this.rootVisualElement;
|
||||||
|
|
||||||
@@ -106,7 +105,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);
|
||||||
@@ -154,17 +153,6 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
_ignoreDefaultTypeToogle = root.Q<Toggle>("IgnoreDefaultType");
|
|
||||||
_ignoreDefaultTypeToogle.RegisterValueChangedCallback(evt =>
|
|
||||||
{
|
|
||||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
|
||||||
if (selectPackage != null)
|
|
||||||
{
|
|
||||||
selectPackage.IgnoreDefaultType = evt.newValue;
|
|
||||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
|
||||||
RefreshWindow();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
_autoCollectShadersToogle = root.Q<Toggle>("AutoCollectShaders");
|
_autoCollectShadersToogle = root.Q<Toggle>("AutoCollectShaders");
|
||||||
_autoCollectShadersToogle.RegisterValueChangedCallback(evt =>
|
_autoCollectShadersToogle.RegisterValueChangedCallback(evt =>
|
||||||
{
|
{
|
||||||
@@ -176,6 +164,25 @@ namespace YooAsset.Editor
|
|||||||
RefreshWindow();
|
RefreshWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
{
|
||||||
|
_ignoreRulePopupField = new PopupField<RuleDisplayName>(_ignoreRuleList, 0);
|
||||||
|
_ignoreRulePopupField.label = "File Ignore Rule";
|
||||||
|
_ignoreRulePopupField.name = "IgnoreRulePopupField";
|
||||||
|
_ignoreRulePopupField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
_ignoreRulePopupField.style.width = 300;
|
||||||
|
_ignoreRulePopupField.formatListItemCallback = FormatListItemCallback;
|
||||||
|
_ignoreRulePopupField.formatSelectedValueCallback = FormatSelectedValueCallback;
|
||||||
|
_ignoreRulePopupField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||||
|
if (selectPackage != null)
|
||||||
|
{
|
||||||
|
selectPackage.IgnoreRuleName = evt.newValue.ClassName;
|
||||||
|
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
_setting2Container.Add(_ignoreRulePopupField);
|
||||||
|
}
|
||||||
|
|
||||||
// 配置修复按钮
|
// 配置修复按钮
|
||||||
var fixBtn = root.Q<Button>("FixButton");
|
var fixBtn = root.Q<Button>("FixButton");
|
||||||
@@ -198,7 +205,9 @@ namespace YooAsset.Editor
|
|||||||
_packageListView = root.Q<ListView>("PackageListView");
|
_packageListView = root.Q<ListView>("PackageListView");
|
||||||
_packageListView.makeItem = MakePackageListViewItem;
|
_packageListView.makeItem = MakePackageListViewItem;
|
||||||
_packageListView.bindItem = BindPackageListViewItem;
|
_packageListView.bindItem = BindPackageListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
#if UNITY_2022_3_OR_NEWER
|
||||||
|
_packageListView.selectionChanged += PackageListView_onSelectionChange;
|
||||||
|
#elif UNITY_2020_1_OR_NEWER
|
||||||
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
|
_packageListView.onSelectionChange += PackageListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
|
_packageListView.onSelectionChanged += PackageListView_onSelectionChange;
|
||||||
@@ -243,7 +252,9 @@ namespace YooAsset.Editor
|
|||||||
_groupListView = root.Q<ListView>("GroupListView");
|
_groupListView = root.Q<ListView>("GroupListView");
|
||||||
_groupListView.makeItem = MakeGroupListViewItem;
|
_groupListView.makeItem = MakeGroupListViewItem;
|
||||||
_groupListView.bindItem = BindGroupListViewItem;
|
_groupListView.bindItem = BindGroupListViewItem;
|
||||||
#if UNITY_2020_1_OR_NEWER
|
#if UNITY_2022_3_OR_NEWER
|
||||||
|
_groupListView.selectionChanged += GroupListView_onSelectionChange;
|
||||||
|
#elif UNITY_2020_1_OR_NEWER
|
||||||
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
_groupListView.onSelectionChange += GroupListView_onSelectionChange;
|
||||||
#else
|
#else
|
||||||
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
_groupListView.onSelectionChanged += GroupListView_onSelectionChange;
|
||||||
@@ -290,8 +301,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 +331,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 +358,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,12 +483,14 @@ 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);
|
||||||
_ignoreDefaultTypeToogle.SetValueWithoutNotify(selectPackage.IgnoreDefaultType);
|
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
||||||
|
_ignoreRulePopupField.SetValueWithoutNotify(GetIgnoreRuleIndex(selectPackage.IgnoreRuleName));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -496,13 +518,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +661,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 激活状态
|
// 激活状态
|
||||||
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
|
IActiveRule activeRule = AssetBundleCollectorSettingData.GetActiveRuleInstance(group.ActiveRuleName);
|
||||||
bool isActive = activeRule.IsActiveGroup();
|
bool isActive = activeRule.IsActiveGroup(new GroupData(group.GroupName));
|
||||||
textField1.SetEnabled(isActive);
|
textField1.SetEnabled(isActive);
|
||||||
}
|
}
|
||||||
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
private void GroupListView_onSelectionChange(IEnumerable<object> objs)
|
||||||
@@ -654,7 +678,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();
|
||||||
}
|
}
|
||||||
@@ -778,7 +802,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
var textField = new TextField();
|
var textField = new TextField();
|
||||||
textField.name = "TextField0";
|
textField.name = "TextField0";
|
||||||
textField.label = "UserData";
|
textField.label = "User Data";
|
||||||
textField.style.width = 200;
|
textField.style.width = 200;
|
||||||
elementBottom.Add(textField);
|
elementBottom.Add(textField);
|
||||||
var label = textField.Q<Label>();
|
var label = textField.Q<Label>();
|
||||||
@@ -787,7 +811,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;
|
||||||
@@ -960,7 +984,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
if (collector.IsValid() == false)
|
if (collector.IsValid() == false)
|
||||||
{
|
{
|
||||||
Debug.LogWarning($"The collector is invalid : {collector.CollectPath} in group : {group.GroupName}");
|
collector.CheckConfigError();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -970,14 +994,15 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CollectCommand command = new CollectCommand(EBuildMode.SimulateBuild,
|
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||||
|
CollectCommand command = new CollectCommand(true, false,
|
||||||
_packageNameTxt.value,
|
_packageNameTxt.value,
|
||||||
_enableAddressableToogle.value,
|
_enableAddressableToogle.value,
|
||||||
_locationToLowerToogle.value,
|
_locationToLowerToogle.value,
|
||||||
_includeAssetGUIDToogle.value,
|
_includeAssetGUIDToogle.value,
|
||||||
_ignoreDefaultTypeToogle.value,
|
|
||||||
_autoCollectShadersToogle.value,
|
_autoCollectShadersToogle.value,
|
||||||
_uniqueBundleNameToogle.value);
|
_uniqueBundleNameToogle.value,
|
||||||
|
ignoreRule);
|
||||||
collector.CheckConfigError();
|
collector.CheckConfigError();
|
||||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||||
}
|
}
|
||||||
@@ -988,15 +1013,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;
|
||||||
@@ -1068,6 +1093,15 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
private RuleDisplayName GetIgnoreRuleIndex(string ruleName)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _ignoreRuleList.Count; i++)
|
||||||
|
{
|
||||||
|
if (_ignoreRuleList[i].ClassName == ruleName)
|
||||||
|
return _ignoreRuleList[i];
|
||||||
|
}
|
||||||
|
return _ignoreRuleList[0];
|
||||||
|
}
|
||||||
private RuleDisplayName GetActiveRuleIndex(string ruleName)
|
private RuleDisplayName GetActiveRuleIndex(string ruleName)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _activeRuleList.Count; i++)
|
for (int i = 0; i < _activeRuleList.Count; i++)
|
||||||
|
|||||||
@@ -1,27 +1,26 @@
|
|||||||
<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;" />
|
||||||
<ui:Toggle label="Ignore Default Type" name="IgnoreDefaultType" style="width: 196px; -unity-text-align: middle-left;" />
|
|
||||||
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
@@ -50,7 +49,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>
|
||||||
|
|||||||
@@ -0,0 +1,271 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class AssetDependencyCache
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源依赖缓存数据库
|
||||||
|
/// </summary>
|
||||||
|
private class CacheDatabase
|
||||||
|
{
|
||||||
|
private class CacheInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 此哈希函数会聚合了以下内容:源资源路径、源资源、元文件、目标平台以及导入器版本。
|
||||||
|
/// 如果此哈希值发送变化,则说明导入资源可能已更改,因此应重新搜集依赖关系。
|
||||||
|
/// </summary>
|
||||||
|
public string DependHash;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 直接依赖资源的GUID列表
|
||||||
|
/// </summary>
|
||||||
|
public List<string> DependGUIDs = new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private string _databaseFilePath;
|
||||||
|
private readonly Dictionary<string, CacheInfo> _database = new Dictionary<string, CacheInfo>(100000);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建数据库
|
||||||
|
/// </summary>
|
||||||
|
public void CreateDatabase(string databaseFilePath, bool useCacheDatabase)
|
||||||
|
{
|
||||||
|
_databaseFilePath = databaseFilePath;
|
||||||
|
_database.Clear();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (useCacheDatabase && File.Exists(databaseFilePath))
|
||||||
|
{
|
||||||
|
// 解析缓存文件
|
||||||
|
using var stream = File.OpenRead(databaseFilePath);
|
||||||
|
using var reader = new BinaryReader(stream);
|
||||||
|
var count = reader.ReadInt32();
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
var assetPath = reader.ReadString();
|
||||||
|
var cacheInfo = new CacheInfo
|
||||||
|
{
|
||||||
|
DependHash = reader.ReadString(),
|
||||||
|
DependGUIDs = ReadStringList(reader),
|
||||||
|
};
|
||||||
|
_database.Add(assetPath, cacheInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除无效资源
|
||||||
|
List<string> removeList = new List<string>(10000);
|
||||||
|
foreach (var cacheInfoPair in _database)
|
||||||
|
{
|
||||||
|
var assetPath = cacheInfoPair.Key;
|
||||||
|
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
|
{
|
||||||
|
removeList.Add(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var assetPath in removeList)
|
||||||
|
{
|
||||||
|
_database.Remove(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ClearCache(true);
|
||||||
|
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查找新增或变动资源
|
||||||
|
var allAssetPaths = AssetDatabase.GetAllAssetPaths();
|
||||||
|
foreach (var assetPath in allAssetPaths)
|
||||||
|
{
|
||||||
|
if (_database.TryGetValue(assetPath, out CacheInfo cacheInfo))
|
||||||
|
{
|
||||||
|
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||||
|
if (dependHash.ToString() != cacheInfo.DependHash)
|
||||||
|
{
|
||||||
|
_database[assetPath] = CreateCacheInfo(assetPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var newCacheInfo = CreateCacheInfo(assetPath);
|
||||||
|
_database.Add(assetPath, newCacheInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存缓存文件
|
||||||
|
/// </summary>
|
||||||
|
public void SaveCacheFile()
|
||||||
|
{
|
||||||
|
if (File.Exists(_databaseFilePath))
|
||||||
|
File.Delete(_databaseFilePath);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var stream = File.Create(_databaseFilePath);
|
||||||
|
using var writer = new BinaryWriter(stream);
|
||||||
|
writer.Write(_database.Count);
|
||||||
|
foreach (var assetPair in _database)
|
||||||
|
{
|
||||||
|
string assetPath = assetPair.Key;
|
||||||
|
var assetInfo = assetPair.Value;
|
||||||
|
writer.Write(assetPath);
|
||||||
|
writer.Write(assetInfo.DependHash);
|
||||||
|
WriteStringList(writer, assetInfo.DependGUIDs);
|
||||||
|
}
|
||||||
|
writer.Flush();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.LogError($"Failed to save cache database : {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理缓存数据
|
||||||
|
/// </summary>
|
||||||
|
public void ClearCache(bool clearDatabaseFile)
|
||||||
|
{
|
||||||
|
if (clearDatabaseFile)
|
||||||
|
{
|
||||||
|
if (File.Exists(_databaseFilePath))
|
||||||
|
File.Delete(_databaseFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
_database.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源的依赖列表
|
||||||
|
/// </summary>
|
||||||
|
public string[] GetDependencies(string assetPath, bool recursive)
|
||||||
|
{
|
||||||
|
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
||||||
|
// 注意:AssetDatabase.GetDependencies()方法返回结果里会包含主资源路径!
|
||||||
|
|
||||||
|
// 注意:机制上不允许存在未收录的资源
|
||||||
|
if (_database.ContainsKey(assetPath) == false)
|
||||||
|
{
|
||||||
|
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new HashSet<string> { assetPath };
|
||||||
|
CollectDependencies(assetPath, result, recursive);
|
||||||
|
|
||||||
|
// 注意:AssetDatabase.GetDependencies保持一致,将主资源添加到依赖列表最前面
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
private void CollectDependencies(string assetPath, HashSet<string> result, bool recursive)
|
||||||
|
{
|
||||||
|
if (_database.TryGetValue(assetPath, out var cacheInfo) == false)
|
||||||
|
{
|
||||||
|
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var dependGUID in cacheInfo.DependGUIDs)
|
||||||
|
{
|
||||||
|
string dependAssetPath = AssetDatabase.GUIDToAssetPath(dependGUID);
|
||||||
|
if (string.IsNullOrEmpty(dependAssetPath))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 如果是文件夹资源
|
||||||
|
if (AssetDatabase.IsValidFolder(dependAssetPath))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 如果已经收集过
|
||||||
|
if (result.Contains(dependAssetPath))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
result.Add(dependAssetPath);
|
||||||
|
|
||||||
|
// 递归收集依赖
|
||||||
|
if (recursive)
|
||||||
|
CollectDependencies(dependAssetPath, result, recursive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string> ReadStringList(BinaryReader reader)
|
||||||
|
{
|
||||||
|
var count = reader.ReadInt32();
|
||||||
|
var values = new List<string>(count);
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
values.Add(reader.ReadString());
|
||||||
|
}
|
||||||
|
return values;
|
||||||
|
}
|
||||||
|
private void WriteStringList(BinaryWriter writer, List<string> values)
|
||||||
|
{
|
||||||
|
writer.Write(values.Count);
|
||||||
|
foreach (var value in values)
|
||||||
|
{
|
||||||
|
writer.Write(value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private CacheInfo CreateCacheInfo(string assetPath)
|
||||||
|
{
|
||||||
|
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||||
|
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||||
|
var dependGUIDs = new List<string>();
|
||||||
|
foreach (var dependAssetPath in dependAssetPaths)
|
||||||
|
{
|
||||||
|
string guid = AssetDatabase.AssetPathToGUID(dependAssetPath);
|
||||||
|
if (string.IsNullOrEmpty(guid) == false)
|
||||||
|
{
|
||||||
|
dependGUIDs.Add(guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var cacheInfo = new CacheInfo();
|
||||||
|
cacheInfo.DependHash = dependHash.ToString();
|
||||||
|
cacheInfo.DependGUIDs = dependGUIDs;
|
||||||
|
return cacheInfo;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly CacheDatabase _database;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化资源依赖缓存系统
|
||||||
|
/// </summary>
|
||||||
|
public AssetDependencyCache(bool useCacheDatabase)
|
||||||
|
{
|
||||||
|
if (useCacheDatabase)
|
||||||
|
Debug.Log("Use asset dependency database !");
|
||||||
|
|
||||||
|
string databaseFilePath = "Library/AssetDependencyDB";
|
||||||
|
_database = new CacheDatabase();
|
||||||
|
_database.CreateDatabase(databaseFilePath, useCacheDatabase);
|
||||||
|
|
||||||
|
if (useCacheDatabase)
|
||||||
|
{
|
||||||
|
_database.SaveCacheFile();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取资源的依赖列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="assetPath">资源路径</param>
|
||||||
|
/// <param name="recursive">递归查找所有依赖</param>
|
||||||
|
/// <returns>返回依赖的资源路径集合</returns>
|
||||||
|
public string[] GetDependencies(string assetPath, bool recursive = true)
|
||||||
|
{
|
||||||
|
// 通过本地缓存获取依赖关系
|
||||||
|
return _database.GetDependencies(assetPath, recursive);
|
||||||
|
|
||||||
|
// 通过Unity引擎获取依赖关系
|
||||||
|
//return AssetDatabase.GetDependencies(assetPath, recursive);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: ddc7e04182c802b468e038777e4dd442
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,20 +4,20 @@ namespace YooAsset.Editor
|
|||||||
public class CollectCommand
|
public class CollectCommand
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 构建模式
|
/// 模拟构建模式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public EBuildMode BuildMode { private set; get; }
|
public bool SimulateBuild { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 使用资源依赖数据库
|
||||||
|
/// </summary>
|
||||||
|
public bool UseAssetDependencyDB { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 包裹名称
|
/// 包裹名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string PackageName { private set; get; }
|
public string PackageName { private set; get; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 忽略Unity引擎无法识别的文件
|
|
||||||
/// </summary>
|
|
||||||
public bool IgnoreDefaultType { private set; get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 启用可寻址资源定位
|
/// 启用可寻址资源定位
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -48,21 +48,40 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ShadersBundleName { private set; get; }
|
public string ShadersBundleName { private set; get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 忽略规则实例
|
||||||
|
/// </summary>
|
||||||
|
public IIgnoreRule IgnoreRule { private set; get; }
|
||||||
|
|
||||||
public CollectCommand(EBuildMode buildMode, string packageName, bool enableAddressable, bool locationToLower, bool includeAssetGUID, bool ignoreDefaultType, bool autoCollectShaders, bool uniqueBundleName)
|
|
||||||
|
public CollectCommand(bool simulateBuild, bool useAssetDependencyDB, string packageName,
|
||||||
|
bool enableAddressable, bool locationToLower, bool includeAssetGUID,
|
||||||
|
bool autoCollectShaders, bool uniqueBundleName, IIgnoreRule ignoreRule)
|
||||||
{
|
{
|
||||||
BuildMode = buildMode;
|
SimulateBuild = simulateBuild;
|
||||||
|
UseAssetDependencyDB = useAssetDependencyDB;
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
EnableAddressable = enableAddressable;
|
EnableAddressable = enableAddressable;
|
||||||
LocationToLower = locationToLower;
|
LocationToLower = locationToLower;
|
||||||
IncludeAssetGUID = includeAssetGUID;
|
IncludeAssetGUID = includeAssetGUID;
|
||||||
IgnoreDefaultType = ignoreDefaultType;
|
|
||||||
AutoCollectShaders = autoCollectShaders;
|
AutoCollectShaders = autoCollectShaders;
|
||||||
UniqueBundleName = uniqueBundleName;
|
UniqueBundleName = uniqueBundleName;
|
||||||
|
IgnoreRule = ignoreRule;
|
||||||
|
|
||||||
// 着色器统一全名称
|
// 着色器统一全名称
|
||||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||||
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
ShadersBundleName = packRuleResult.GetBundleName(packageName, uniqueBundleName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private AssetDependencyCache _assetDependency;
|
||||||
|
public AssetDependencyCache AssetDependency
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_assetDependency == null)
|
||||||
|
_assetDependency = new AssetDependencyCache(UseAssetDependencyDB);
|
||||||
|
return _assetDependency;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,16 @@
|
|||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
|
public struct GroupData
|
||||||
|
{
|
||||||
|
public string GroupName;
|
||||||
|
|
||||||
|
public GroupData(string groupName)
|
||||||
|
{
|
||||||
|
GroupName = groupName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 资源分组激活规则接口
|
/// 资源分组激活规则接口
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -9,6 +19,6 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 是否激活分组
|
/// 是否激活分组
|
||||||
/// </summary>
|
/// </summary>
|
||||||
bool IsActiveGroup();
|
bool IsActiveGroup(GroupData data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 资源忽略规则接口
|
||||||
|
/// </summary>
|
||||||
|
public interface IIgnoreRule
|
||||||
|
{
|
||||||
|
bool IsIgnore(AssetInfo assetInfo);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bd55753dbb880fa449bf4e37b33d8ba7
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -28,19 +28,41 @@ namespace YooAsset.Editor
|
|||||||
_bundleExtension = bundleExtension;
|
_bundleExtension = bundleExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 结果是否有效
|
||||||
|
/// </summary>
|
||||||
|
public bool IsValid()
|
||||||
|
{
|
||||||
|
return string.IsNullOrEmpty(_bundleName) == false && string.IsNullOrEmpty(_bundleExtension) == false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取资源包全名称
|
/// 获取资源包全名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string GetBundleName(string packageName, bool uniqueBundleName)
|
public string GetBundleName(string packageName, bool uniqueBundleName)
|
||||||
{
|
{
|
||||||
string fullName;
|
string fullName;
|
||||||
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').ToLower();
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').Replace(" ", "_").ToLower();
|
||||||
if (uniqueBundleName)
|
if (uniqueBundleName)
|
||||||
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
fullName = $"{packageName}_{bundleName}.{_bundleExtension}";
|
||||||
else
|
else
|
||||||
fullName = $"{bundleName}.{_bundleExtension}";
|
fullName = $"{bundleName}.{_bundleExtension}";
|
||||||
return fullName.ToLower();
|
return fullName.ToLower();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取共享资源包全名称
|
||||||
|
/// </summary>
|
||||||
|
public string GetShareBundleName(string packageName, bool uniqueBundleName)
|
||||||
|
{
|
||||||
|
string fullName;
|
||||||
|
string bundleName = EditorTools.GetRegularPath(_bundleName).Replace('/', '_').Replace('.', '_').Replace(" ", "_").ToLower();
|
||||||
|
if (uniqueBundleName)
|
||||||
|
fullName = $"{packageName}_share_{bundleName}.{_bundleExtension}";
|
||||||
|
else
|
||||||
|
fullName = $"share_{bundleName}.{_bundleExtension}";
|
||||||
|
return fullName.ToLower();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ namespace YooAsset.Editor
|
|||||||
[DisplayName("启用分组")]
|
[DisplayName("启用分组")]
|
||||||
public class EnableGroup : IActiveRule
|
public class EnableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup(GroupData data)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ namespace YooAsset.Editor
|
|||||||
[DisplayName("禁用分组")]
|
[DisplayName("禁用分组")]
|
||||||
public class DisableGroup : IActiveRule
|
public class DisableGroup : IActiveRule
|
||||||
{
|
{
|
||||||
public bool IsActiveGroup()
|
public bool IsActiveGroup(GroupData data)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
||||||
{
|
{
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user