mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
385 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b1f02049cc | ||
|
|
512886cdf6 | ||
|
|
0c3ccc5c2f | ||
|
|
b0ea03170f | ||
|
|
2c3b890329 | ||
|
|
0f39cb9444 | ||
|
|
8acc16d3f6 | ||
|
|
fd1715a89b | ||
|
|
0934c813d1 | ||
|
|
be71d38cd8 | ||
|
|
4cdfde31da | ||
|
|
0133549ef8 | ||
|
|
81d9eb47c8 | ||
|
|
5fde689f1f | ||
|
|
5d51bfe751 | ||
|
|
ed86edd2b0 | ||
|
|
f627b5b59a | ||
|
|
549ec74519 | ||
|
|
247ee31348 | ||
|
|
90d3a53bc3 | ||
|
|
19f1d67a61 | ||
|
|
a71c46d1c4 | ||
|
|
82d7bc8fef | ||
|
|
cc85099253 | ||
|
|
d392b02bd4 | ||
|
|
a5138b9846 | ||
|
|
e1b6458c26 | ||
|
|
0f73dc3047 | ||
|
|
a85e49c22a | ||
|
|
6b291de922 | ||
|
|
a4b1300195 | ||
|
|
6f34951a74 | ||
|
|
c798250258 | ||
|
|
6fc82bb55a | ||
|
|
c22cf5ffeb | ||
|
|
36bc24f9fd | ||
|
|
addb0ecdfe | ||
|
|
89e23e0df8 | ||
|
|
e2f582834e | ||
|
|
d2c2844f61 | ||
|
|
1de64278ad | ||
|
|
227f2332a9 | ||
|
|
131614687c | ||
|
|
b8ec902f60 | ||
|
|
eb3e29b6ad | ||
|
|
11ed9d391a | ||
|
|
9cd50bc7f3 | ||
|
|
e92505ba88 | ||
|
|
06a670730c | ||
|
|
ccd21e56cb | ||
|
|
522bcc529a | ||
|
|
2254ac9f5e | ||
|
|
956b3db71d | ||
|
|
fb56959c61 | ||
|
|
b9b9f4e37d | ||
|
|
c050d6d172 | ||
|
|
baf76a454b | ||
|
|
385d343262 | ||
|
|
1f5ad24d44 | ||
|
|
fefc0043cf | ||
|
|
f49143d4f7 | ||
|
|
fd760b12a3 | ||
|
|
14cf8e9ca3 | ||
|
|
3595219a71 | ||
|
|
a4c7d4b8f5 | ||
|
|
43c5c7fb53 | ||
|
|
48d2b36d4e | ||
|
|
2fd87f4d4b | ||
|
|
0fd75b835a | ||
|
|
4489ca570b | ||
|
|
268792b576 | ||
|
|
33907ea967 | ||
|
|
5d7afff3e4 | ||
|
|
fa15f83d85 | ||
|
|
1801974c8a | ||
|
|
bfd476d59c | ||
|
|
7dd08e9634 | ||
|
|
b2776b933a | ||
|
|
9f09b6c526 | ||
|
|
01f6103b48 | ||
|
|
053b4a00d7 | ||
|
|
db159428c6 | ||
|
|
ac7ee16017 | ||
|
|
c2fb7c3cbb | ||
|
|
e70b0d37cd | ||
|
|
53db012fc8 | ||
|
|
b3622167da | ||
|
|
dd6fab46f9 | ||
|
|
f0796dccc9 | ||
|
|
f383c59327 | ||
|
|
e34b9270d2 | ||
|
|
b90ab01fe9 | ||
|
|
236468b4a8 | ||
|
|
6f5fcd55b1 | ||
|
|
4b8f2e3acc | ||
|
|
090e4f4b15 | ||
|
|
53163a75ae | ||
|
|
273401cb20 | ||
|
|
97fe3b0681 | ||
|
|
d401086fd1 | ||
|
|
e3a12ef361 | ||
|
|
1b0288fcd0 | ||
|
|
3ee94fb3b9 | ||
|
|
a0ea80c158 | ||
|
|
264415b362 | ||
|
|
6a76d44c38 | ||
|
|
cebfd57851 | ||
|
|
60eb1c3522 | ||
|
|
40c82835bf | ||
|
|
a13913f572 | ||
|
|
150b46a0a7 | ||
|
|
ebde5a52d3 | ||
|
|
e57466e9e2 | ||
|
|
6f7fca7b34 | ||
|
|
756331fe0b | ||
|
|
5139e2f3a7 | ||
|
|
1c4aba6db5 | ||
|
|
44faa0c5e6 | ||
|
|
72c97341b1 | ||
|
|
9acc240b5a | ||
|
|
ed89e73d26 | ||
|
|
9e33df0375 | ||
|
|
6c98f9a09d | ||
|
|
9ed85afb29 | ||
|
|
560a395173 | ||
|
|
8bce963588 | ||
|
|
f8a3fe47e5 | ||
|
|
48356a4f9e | ||
|
|
d2a28bd801 | ||
|
|
3949abb53f | ||
|
|
06a50a049e | ||
|
|
6f049e2427 | ||
|
|
01c08a46ab | ||
|
|
31dc5b494d | ||
|
|
18e74e906e | ||
|
|
4f62b249b4 | ||
|
|
fe7f9bff08 | ||
|
|
e71077f294 | ||
|
|
eabebf3d8f | ||
|
|
4ef789520a | ||
|
|
4322f3c58c | ||
|
|
c40a796170 | ||
|
|
32841d4773 | ||
|
|
e469b32d94 | ||
|
|
c0e5315953 | ||
|
|
7b5f366533 | ||
|
|
e674d5bf97 | ||
|
|
9b0bebd981 | ||
|
|
dc46462bfa | ||
|
|
51c9943cf2 | ||
|
|
3db9b750e3 | ||
|
|
1b57a0b7df | ||
|
|
bd5ce1e6bd | ||
|
|
7eb74d4dd1 | ||
|
|
a384ca1f18 | ||
|
|
c7253a3f23 | ||
|
|
b296abb27e | ||
|
|
999ede6bab | ||
|
|
bd1569c34d | ||
|
|
3c265c1ab4 | ||
|
|
570a3a817c | ||
|
|
7a8f344927 | ||
|
|
b2c9cb3a7e | ||
|
|
06a5c90b23 | ||
|
|
dcd8ced42a | ||
|
|
76b31bd3cf | ||
|
|
009e8ece79 | ||
|
|
4e257ab27d | ||
|
|
927400b669 | ||
|
|
c0d42e79d8 | ||
|
|
b843c6b0ed | ||
|
|
9fb7f8bbfe | ||
|
|
b0382afad0 | ||
|
|
1ab7689174 | ||
|
|
29d456c065 | ||
|
|
b0dc829b04 | ||
|
|
b3ead90832 | ||
|
|
7bf00d4ff6 | ||
|
|
030e94d8ff | ||
|
|
cf05254121 | ||
|
|
3f786bca3b | ||
|
|
98719d212f | ||
|
|
3409f7ce4d | ||
|
|
f57b354e9b | ||
|
|
974493f88d | ||
|
|
69a69988a1 | ||
|
|
4e9c1955eb | ||
|
|
b6c68a533e | ||
|
|
38aa1c3509 | ||
|
|
eb2f783417 | ||
|
|
8556e071fa | ||
|
|
6155256fb6 | ||
|
|
0d4f2bc893 | ||
|
|
600e928ab4 | ||
|
|
4599ff098c | ||
|
|
4d2df5b705 | ||
|
|
79a7732cfd | ||
|
|
79467bbf13 | ||
|
|
c7d678282b | ||
|
|
d376afc217 | ||
|
|
a62f808591 | ||
|
|
b334a4986b | ||
|
|
a4111349a0 | ||
|
|
bdcf95384f | ||
|
|
d910af589d | ||
|
|
0531864534 | ||
|
|
72b1278f5c | ||
|
|
875cd24cba | ||
|
|
fcc729a0bf | ||
|
|
d10e54248b | ||
|
|
b84800a905 | ||
|
|
8ccd7e552c | ||
|
|
772ba484eb | ||
|
|
cdbedee705 | ||
|
|
10cce48e71 | ||
|
|
13e8410d80 | ||
|
|
6f07faf4da | ||
|
|
e3228d406e | ||
|
|
daf2133535 | ||
|
|
9bcbc10862 | ||
|
|
e6958d205e | ||
|
|
b03d9db2b0 | ||
|
|
30853b6d62 | ||
|
|
a7cafcb328 | ||
|
|
d03bca5512 | ||
|
|
af3fc50188 | ||
|
|
b71eeeb855 | ||
|
|
317c42521a | ||
|
|
064d69269e | ||
|
|
9e6401d3c0 | ||
|
|
2aaba328ee | ||
|
|
62fdc93a82 | ||
|
|
408f0942ee | ||
|
|
ddda9e29db | ||
|
|
c2b33f5ec4 | ||
|
|
e58999e484 | ||
|
|
ed9692574c | ||
|
|
f7e078e064 | ||
|
|
b74a44dc36 | ||
|
|
6b36cdb5ee | ||
|
|
56ae1a8f95 | ||
|
|
3069b1d1f1 | ||
|
|
e7d346e4e1 | ||
|
|
7d9e00a574 | ||
|
|
7382afe535 | ||
|
|
af7d4774d6 | ||
|
|
520a8a0623 | ||
|
|
fbd0d8ec40 | ||
|
|
3fea98ce4c | ||
|
|
7c561ce254 | ||
|
|
522ddb5115 | ||
|
|
47f5790507 | ||
|
|
0cdcfe7f52 | ||
|
|
e4d69d869b | ||
|
|
61afb70cb9 | ||
|
|
79580697a1 | ||
|
|
6cb74760b0 | ||
|
|
c758aa81ff | ||
|
|
400c2ccefe | ||
|
|
64e9734bbe | ||
|
|
f6244885be | ||
|
|
82c57c382f | ||
|
|
7eacb46555 | ||
|
|
d9c911d89b | ||
|
|
a3ceb3dcb6 | ||
|
|
a5b68b28b2 | ||
|
|
bd285faf37 | ||
|
|
8a4960b560 | ||
|
|
83c6ae2057 | ||
|
|
b71563e889 | ||
|
|
79e0cf85f9 | ||
|
|
e996eaa008 | ||
|
|
5088c9e985 | ||
|
|
610b3c6d32 | ||
|
|
cc7290f10e | ||
|
|
576b842368 | ||
|
|
d23c0ba715 | ||
|
|
98e19baebd | ||
|
|
f5947db44a | ||
|
|
e978164329 | ||
|
|
966c8f2efa | ||
|
|
a57fec3d71 | ||
|
|
84844eda20 | ||
|
|
698cdcba61 | ||
|
|
1d6c9393d4 | ||
|
|
b654ac156d | ||
|
|
d133a9a692 | ||
|
|
d55db19f0e | ||
|
|
e3fc3df32c | ||
|
|
f2334da72d | ||
|
|
2902b6c2cf | ||
|
|
dfa95b57b9 | ||
|
|
33a2cf66d0 | ||
|
|
5f52cf5b51 | ||
|
|
9d07905f2d | ||
|
|
26dbe9dfdd | ||
|
|
98c5851071 | ||
|
|
a6ee571d65 | ||
|
|
a138701afe | ||
|
|
e52bdea255 | ||
|
|
068a712a30 | ||
|
|
80a5300648 | ||
|
|
0c36e458f7 | ||
|
|
b2fa52e4c4 | ||
|
|
151e978e5b | ||
|
|
9e806861ec | ||
|
|
a9a9368b9b | ||
|
|
7936ba31ea | ||
|
|
afc456de9a | ||
|
|
a98db0ba83 | ||
|
|
fb8720edd3 | ||
|
|
2aa2a0ac3a | ||
|
|
0531b6ef3a | ||
|
|
24142de11f | ||
|
|
7fad6eb70b | ||
|
|
f60227abdf | ||
|
|
18d6a74c53 | ||
|
|
03d06ba657 | ||
|
|
07086b68c8 | ||
|
|
0a85f3126f | ||
|
|
efa4180340 | ||
|
|
fb06f2aa11 | ||
|
|
ce023cedb8 | ||
|
|
3d1a28a50e | ||
|
|
5d2d0b4168 | ||
|
|
fa985a5a93 | ||
|
|
40f9937b60 | ||
|
|
c543c629c3 | ||
|
|
f861279c49 | ||
|
|
ee89f81d46 | ||
|
|
6d216561f8 | ||
|
|
0a96e583d3 | ||
|
|
c9d263c60d | ||
|
|
2d6488abf4 | ||
|
|
7dfbac4a24 | ||
|
|
7cfe4cb2c9 | ||
|
|
30cba8ca5f | ||
|
|
e9261a0ec0 | ||
|
|
89ee22837d | ||
|
|
939f3747cd | ||
|
|
f72814a51b | ||
|
|
94ee2ba5c1 | ||
|
|
fd9533d63f | ||
|
|
6571faae4e | ||
|
|
e031498d5b | ||
|
|
31a0017351 | ||
|
|
6e8cb0366d | ||
|
|
a02b3fbf6e | ||
|
|
37a663e0e1 | ||
|
|
e925d9892f | ||
|
|
e7907eeaa7 | ||
|
|
644e6655ff | ||
|
|
20c07af504 | ||
|
|
38471cdd6c | ||
|
|
0b5d16bd0e | ||
|
|
203b9994df | ||
|
|
e76bbb6a85 | ||
|
|
4e6c146bde | ||
|
|
7e1dc7ef24 | ||
|
|
698d81a433 | ||
|
|
012f9b9f03 | ||
|
|
12bd282ace | ||
|
|
31a89fa1a3 | ||
|
|
57d1e92e59 | ||
|
|
377fca20d9 | ||
|
|
415f844982 | ||
|
|
cbb8472153 | ||
|
|
c85ced89ef | ||
|
|
d5b8c90c94 | ||
|
|
9bcfb04f91 | ||
|
|
ae0fbd4b10 | ||
|
|
ef4f011cf6 | ||
|
|
7cc985205a | ||
|
|
a38b76eb8f | ||
|
|
9f844912cf | ||
|
|
d72b0b10d4 | ||
|
|
655f756d56 | ||
|
|
912e2c28a3 | ||
|
|
9add447566 | ||
|
|
7c435f6dc0 | ||
|
|
5e2fc84ebf | ||
|
|
793a57647d | ||
|
|
c32e7bc525 | ||
|
|
20fac33efc | ||
|
|
8cf356cadb |
2
.gitignore
vendored
2
.gitignore
vendored
@@ -20,6 +20,8 @@
|
||||
/Assets/StreamingAssets.meta
|
||||
/Assets/Samples
|
||||
/Assets/Samples.meta
|
||||
/Assets/csc.rsp
|
||||
/Assets/csc.rsp.meta
|
||||
/UserSettings
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,684 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.16] - 2025-09-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#638) 优化了Provider加载机制,引用计数为零时自动挂起!
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#644) [**严重**] 修复了2.3.15版本,资产量巨大的情况下,编辑器下模拟模式初始化耗时很久的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#639) 新增了文件系统参数:VIRTUAL_DOWNLOAD_MODE 和 VIRTUAL_DOWNLOAD_SPEED
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟远端资源下载,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载模式
|
||||
/// </summary>
|
||||
public bool VirtualDownloadMode { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载的网速(单位:字节)
|
||||
/// </summary>
|
||||
public int VirtualDownloadSpeed { private set; get; } = 1024;
|
||||
}
|
||||
```
|
||||
|
||||
- (#640) 新增了文件系统参数:VIRTUAL_WEBGL_MODE
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟小游戏开发环境,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟WebGL平台模式
|
||||
/// </summary>
|
||||
public bool VirtualWebGLMode { private set; get; } = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#642) 新增了文件系统参数:DOWNLOAD_WATCH_DOG_TIME
|
||||
|
||||
监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
|
||||
|
||||
```csharp
|
||||
class DefaultCacheFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义参数:下载任务的看门狗机制监控时间
|
||||
/// </summary>
|
||||
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 下载器参数timeout移除。
|
||||
|
||||
可以使用文件系统的看门狗机制代替。
|
||||
|
||||
- (#632) IFilterRule接口变动。
|
||||
|
||||
收集器可以指定搜寻的资源类型,在收集目录资产量巨大的情况下,可以极大加快打包速度!
|
||||
|
||||
```csharp
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.15] - 2025-09-09
|
||||
|
||||
**重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 重构了UniTask扩展库的目录结构和说明文档。
|
||||
- 重构了内置文件系统类的加载和拷贝逻辑,解决在一些特殊机型上遇到的偶发性拷贝失败问题。
|
||||
- 增加了生成内置清单文件的窗口工具,详情见扩展工程里CreateBuildinCatalog目录。
|
||||
- 优化了异步操作系统的繁忙检测机制。
|
||||
- (#621) 资源配置页面可以展示DependCollector和StaticCollector包含的文件列表内容。
|
||||
- (#627) 优化了资源清单部分字段类型,CRC字段从字符串类型调整为整形,可以降低清单尺寸。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了构建页面扩展类缺少指定属性报错的问题。
|
||||
- (#611) 修复了资源扫描器配置页面,修改备注信息后会丢失焦点的问题。
|
||||
- (#622) 修复了纯鸿蒙系统读取内置加密文件失败的问题。
|
||||
- (#620) 修复了LINUX系统URL地址转换失败的问题。
|
||||
- (#631) 修复了NET 4.x程序集库Math.Clamp导致的编译错误。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了支持支付宝小游戏的文件系统扩展类。
|
||||
|
||||
- 新增了支持Taptap小游戏的文件系统扩展类。
|
||||
|
||||
- 新增了资源系统初始化参数:UseWeakReferenceHandle
|
||||
|
||||
目前处于预览版,可以在引擎设置页面开启宏:YOOASSET_EXPERIMENTAL
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 启用弱引用资源句柄
|
||||
/// </summary>
|
||||
public bool UseWeakReferenceHandle = false;
|
||||
```
|
||||
|
||||
- 内置文件系统和缓存文件系统新增初始化参数:FILE_VERIFY_MAX_CONCURRENCY
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 自定义参数:初始化的时候缓存文件校验最大并发数
|
||||
/// </summary>
|
||||
public int FileVerifyMaxConcurrency { private set; get; }
|
||||
```
|
||||
|
||||
- (#623) 内置构建管线新增构建参数:StripUnityVersion
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 从文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
```
|
||||
|
||||
- 可编程构建管线新增构建参数:TrackSpriteAtlasDependencies
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 自动建立资源对象对图集的依赖关系
|
||||
/// </summary>
|
||||
public bool TrackSpriteAtlasDependencies = false;
|
||||
```
|
||||
|
||||
- (#617) 新增资源收集配置参数:SupportExtensionless
|
||||
|
||||
在不需要模糊加载模式的前提下,关闭此选项,可以降低运行时内存大小。
|
||||
|
||||
该选项默认开启!
|
||||
|
||||
```csharp
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 支持无后缀名的资源定位地址
|
||||
/// </summary>
|
||||
public bool SupportExtensionless { set; get; }
|
||||
}
|
||||
```
|
||||
|
||||
- (#625) 异步操作系统类新增监听方法。
|
||||
|
||||
```csharp
|
||||
class OperationSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 监听任务开始
|
||||
/// </summary>
|
||||
public static void RegisterStartCallback(Action<string, AsyncOperationBase> callback);
|
||||
|
||||
/// <summary>
|
||||
/// 监听任务结束
|
||||
/// </summary>
|
||||
public static void RegisterFinishCallback(Action<string, AsyncOperationBase> callback);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.14] - 2025-07-23
|
||||
|
||||
**重要**:**所有下载相关的超时参数(timeout)已更新判定逻辑**
|
||||
|
||||
超时不再以‘指定时间内未接收到任何数据’为判定条件,而是以‘指定时间内未完成整个下载任务’为判定条件。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 重构了核心代码的下载逻辑,解决了同步加载触发的下载任务没有完成的问题。
|
||||
- 扩展工程里新增了PreprocessBuildCatalog类,用于处理在构建应用程序前自动生成内置资源目录文件。
|
||||
- (#592) 优化了资源清单逻辑里不必要产生的GC逻辑。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#590) 修复了TryUnloadUnusedAsset方法,在依赖嵌套层数过深导致没有卸载的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了支持Google Play的文件系统扩展示例。
|
||||
|
||||
- 新增了支持DefaultCacheFileSystem的单元测试用例。
|
||||
|
||||
- 新增了文件系统配置参数:DISABLE_ONDEMAND_DOWNLOAD
|
||||
|
||||
```csharp
|
||||
public class FileSystemParametersDefine
|
||||
{
|
||||
// 禁用边玩边下机制
|
||||
public const string DISABLE_ONDEMAND_DOWNLOAD = "DISABLE_ONDEMAND_DOWNLO";
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- IManifestServices接口拆分为了IManifestProcessServices和IManifestRestoreServices
|
||||
|
||||
```csharp
|
||||
public interface IManifestProcessServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理资源清单(压缩或加密)
|
||||
/// </summary>
|
||||
byte[] ProcessManifest(byte[] fileData);
|
||||
}
|
||||
|
||||
public interface IManifestRestoreServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 还原资源清单(解压或解密)
|
||||
/// </summary>
|
||||
byte[] RestoreManifest(byte[] fileData);
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.12] - 2025-07-01
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化了同步接口导致的资源拷贝和资源验证性能开销高的现象。
|
||||
- 微信小游戏和抖音小游戏支持资源清单加密。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#579) 修复了2.3.10版本资源包构建页面里CopyBuildinFileParam无法编辑问题。
|
||||
- (#572) 修复了资源收集页面指定收集的预制体名称变动的问题。
|
||||
- (#582) 修复了非递归收集依赖时,依赖列表中才包含主资源的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增初始化参数:WebGLForceSyncLoadAsset
|
||||
|
||||
```csharp
|
||||
public abstract class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// WebGL平台强制同步加载资源对象
|
||||
/// </summary>Add commentMore actions
|
||||
public bool WebGLForceSyncLoadAsset = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#576) 新增了资源清单服务类:IManifestServices
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 资源清单文件处理服务接口
|
||||
/// </summary>
|
||||
public interface IManifestServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 处理资源清单(压缩和加密)
|
||||
/// </summary>
|
||||
byte[] ProcessManifest(byte[] fileData);
|
||||
|
||||
/// <summary>
|
||||
/// 还原资源清单(解压和解密)
|
||||
/// </summary>
|
||||
byte[] RestoreManifest(byte[] fileData);
|
||||
}
|
||||
```
|
||||
|
||||
- (#585) 新增了本地文件拷贝服务类:ICopyLocalFileServices
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 本地文件拷贝服务类
|
||||
/// </summary>
|
||||
public interface ICopyLocalFileServices
|
||||
{
|
||||
void CopyFile(LocalFileInfo sourceFileInfo, string destFilePath);
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.10] - 2025-06-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- 小游戏扩展库已经独立,可以单独导入到项目工程。
|
||||
- 编辑器里的TableView视图新增了AssetObjectCell类。
|
||||
- (#552) 微信小游戏文件系统类,增加了URL合法性的初始化检测机制。
|
||||
- (#566) 重构了资源构建页面,方便扩展自定义界面。
|
||||
- (#573) 完善了AssetDependencyDB的输出日志,可以正确输出丢失的引用资产信息。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复太空战机DEMO在退出运行模式时的报错。
|
||||
- (#551) 修复了Unity2019, Unity2020的代码兼容性报错。
|
||||
- (#569) 修复了TVOS平台的兼容问题。
|
||||
- (#564) 修复了TiktokFileSystem文件系统里appendTimeTicks无效的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#562) 新增了解密方法。
|
||||
|
||||
```csharp
|
||||
public interface IDecryptionServices
|
||||
{
|
||||
/// <summary>
|
||||
/// 后备方式获取解密的资源包对象
|
||||
/// 注意:当正常解密方法失败后,会触发后备加载!
|
||||
/// 说明:建议通过LoadFromMemory()方法加载资源对象作为保底机制。
|
||||
/// issues : https://github.com/tuyoogame/YooAsset/issues/562
|
||||
/// </summary>
|
||||
DecryptResult LoadAssetBundleFallback(DecryptFileInfo fileInfo);
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.9] - 2025-05-13
|
||||
|
||||
### Improvements
|
||||
|
||||
- 增加了YOO_ASSET_EXPERIMENT宏,用于控制实验性代码的开关。
|
||||
- 构建管线目前会输出构建日志到输出目录下,方便查看引擎在构建时主动清空的控制台日志。
|
||||
- 优化了收集器tag传染扩散逻辑,避免Group里配置了Tag导致的无意义的警告信息。
|
||||
- 扩展工程内PanelMonitor代码默认关闭状态。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#528) 修复了AssetDependencyDatabase在查询引擎资源对象是否存在的时效问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#542) 新增了资源管理系统销毁方法。
|
||||
|
||||
该方法会销毁所有的资源包裹和异步操作任务,以及卸载所有AssetBundle对象!
|
||||
|
||||
```csharp
|
||||
public class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 销毁资源系统
|
||||
/// </summary>
|
||||
public static void Destroy();
|
||||
}
|
||||
```
|
||||
|
||||
- 新增了SBP构建管线的构建参数
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 从AssetBundle文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
```
|
||||
|
||||
- 新增了构建错误码:BuiltinShadersBundleNameIsNull
|
||||
|
||||
## [2.3.8] - 2025-04-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- 扩展工程里增加了“图集丢失变白块的解决方案”的相关代码。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#528) 修复了微信小游戏平台WXFSClearUnusedBundleFiles无法清理的问题。
|
||||
- (#531) 修复了微信小游戏平台WXFSClearUnusedBundleFiles没有适配BundleName_HashName命名方式。
|
||||
- (#533) 修复了Editor程序集下无法访问YooAsset.Editor程序集里的internal字段的问题。
|
||||
- (#534) 修复了资源报告窗口AssetView视图里,依赖资源包列表显示不准确的问题。
|
||||
|
||||
## [2.3.7] - 2025-04-01
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#526) 运行时资源清单的哈希值验证兼容了MD5和CRC32两种方式。
|
||||
- (#515) 优化了资源路径大小写不敏感的逻辑代码,减少字符串操作产生的GC。
|
||||
- (#523) UnloadUnusedAssetsOperation方法支持了分帧处理。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#520) 修复了UWP平台获取WWW加载路径未适配的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了文件系统初始化参数:INSTALL_CLEAR_MODE
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 覆盖安装清理模式
|
||||
/// </summary>
|
||||
public enum EOverwriteInstallClearMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 不做任何处理
|
||||
/// </summary>
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存文件(包含资源文件和清单文件)
|
||||
/// </summary>
|
||||
ClearAllCacheFiles = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存的资源文件
|
||||
/// </summary>
|
||||
ClearAllBundleFiles = 2,
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有缓存的清单文件
|
||||
/// </summary>
|
||||
ClearAllManifestFiles = 3,
|
||||
}
|
||||
```
|
||||
|
||||
- 新增了初始化参数:BundleLoadingMaxConcurrency
|
||||
|
||||
```csharp
|
||||
public abstract class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 同时加载Bundle文件的最大并发数
|
||||
/// </summary>
|
||||
public int BundleLoadingMaxConcurrency = int.MaxValue;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.6] - 2025-03-25
|
||||
|
||||
### Improvements
|
||||
|
||||
- 构建管线新增了TaskCreateCatalog任务节点。
|
||||
- 内置文件系统的catalog文件现在存储在streammingAssets目录下。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#486) 修复了微信小游戏文件系统调用ClearUnusedBundleFiles时候的异常。
|
||||
|
||||
## [2.3.5-preview] - 2025-03-14
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#502) 修复了原生缓存文件由于文件格式变动导致的加载本地缓存文件失败的问题。
|
||||
- (#504) 修复了MacOS平台Offline Play Mode模式请求本地资源清单失败的问题。
|
||||
- (#506) 修复了v2.3x版本LoadAllAssets方法计算依赖Bundle不完整的问题。
|
||||
- (#506) 修复了微信小游戏文件系统,在启用加密算法后卸载bundle报错的问题。
|
||||
|
||||
## [2.3.4-preview] - 2025-03-08
|
||||
|
||||
### Improvements
|
||||
|
||||
- YooAsset支持了版本宏定义。
|
||||
|
||||
```csharp
|
||||
YOO_ASSET_2
|
||||
YOO_ASSET_2_3
|
||||
YOO_ASSET_2_3_OR_NEWER
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#389) 修复了禁用域重载(Reload Domain)的情况下,再次启动游戏报错的问题。
|
||||
- (#496) 修复了文件系统参数RESUME_DOWNLOAD_MINMUM_SIZE传入int值会导致异常的错误。
|
||||
- (#498) 修复了v2.3版本尝试加载安卓包内的原生资源包失败的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了YooAssets.GetAllPackages()方法
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 获取所有资源包裹
|
||||
/// </summary>
|
||||
public static List<ResourcePackage> GetAllPackages()
|
||||
```
|
||||
|
||||
## [2.3.3-preview] - 2025-03-06
|
||||
|
||||
### Improvements
|
||||
|
||||
- 新增了异步操作任务调试器,AssetBundleDebugger窗口-->OperationView视图模式
|
||||
- 编辑器下模拟构建默认启用依赖关系数据库,可以大幅降低编辑器下启动游戏的时间。
|
||||
- 单元测试用例增加加密解密测试用例。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#492) 修复了发布的MAC平台应用,在启动的时候提示权限无法获取的问题。
|
||||
|
||||
## [2.3.2-preview] - 2025-02-27
|
||||
|
||||
### Fixed
|
||||
|
||||
- (2.3.1) 修复小游戏平台下载器不生效的问题。
|
||||
- (#480) 修复了Unity工程打包导出时的报错。
|
||||
|
||||
### Added
|
||||
|
||||
- 下载器新增参数:recursiveDownload
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 创建资源下载器,用于下载指定的资源依赖的资源包文件
|
||||
/// </summary>
|
||||
/// <param name="recursiveDownload">下载资源对象所属资源包内所有资源对象依赖的资源包
|
||||
public ResourceDownloaderOperation CreateBundleDownloader()
|
||||
```
|
||||
|
||||
- 新增CustomPlayMode模式
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 自定义运行模式的初始化参数
|
||||
/// </summary>
|
||||
public class CustomPlayModeParameters : InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件系统初始化参数列表
|
||||
/// 注意:列表最后一个元素作为主文件系统!
|
||||
/// </summary>
|
||||
public List<FileSystemParameters> FileSystemParameterList;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.1-preview] - 2025-02-25
|
||||
|
||||
**资源加载依赖计算方式还原为了1.5x版本的模式,只加载资源对象实际依赖的资源包,不再以资源对象所在资源包的依赖关系为加载标准**。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 优化OperationSystem的更新机制,异步加载的耗时降低了50%。
|
||||
- 优化了Debugger窗口的显示页面,BundleView页面增加资源包的引用列表。
|
||||
- 优化了Reporter窗口的显示页面。
|
||||
|
||||
### Fixed
|
||||
|
||||
- 修复了怀旧依赖模式下,TAG传染不正确的问题。
|
||||
|
||||
## [2.3.0-preview] - 2025-02-19
|
||||
|
||||
### Improvements
|
||||
|
||||
资源收集窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
资源扫描窗口列表元素支持手动上下拖拽排序!
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了UIElements扩展类ReorderableListView
|
||||
|
||||
- 新增初始化方法
|
||||
|
||||
```csharp
|
||||
public class YooAssets
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置异步系统参数,快速启动模式的开关
|
||||
/// 注意:该模式默认开启
|
||||
/// </summary>
|
||||
public static void SetOperationSystemQuickStartMode(bool state)
|
||||
}
|
||||
```
|
||||
|
||||
- 新增打包构建参数
|
||||
|
||||
```csharp
|
||||
public class BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 旧版依赖模式
|
||||
/// 说明:兼容YooAssets1.5.x版本
|
||||
/// </summary>
|
||||
public bool LegacyDependency = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#472) 修复了Unity6平台,TableView视图无法显示问题。
|
||||
- 修复了微信小游戏和抖音小游戏未正确使用插件的卸载方法。
|
||||
|
||||
## [2.2.12] - 2025-02-14
|
||||
|
||||
### Improvements
|
||||
|
||||
- WebGL网页平台支持文件加密。
|
||||
- 微信小游戏平台支持文件加密。
|
||||
- 抖音小游戏平台支持文件加密。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#466) 修复了微信小游戏文件系统查询机制不生效!
|
||||
- (#341) 修复了微信小游戏的下载进度异常问题。
|
||||
- (#471) 修复了Unity2019,Unity2020平台上,TableView视图无法显示的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了ResourcePackage.UnloadAllAssetsAsync(UnloadAllAssetsOptions options)方法
|
||||
|
||||
```csharp
|
||||
public sealed class UnloadAllAssetsOptions
|
||||
{
|
||||
/// <summary>
|
||||
/// 释放所有资源句柄,防止卸载过程中触发完成回调!
|
||||
/// </summary>
|
||||
public bool ReleaseAllHandles = true;
|
||||
|
||||
/// <summary>
|
||||
/// 卸载过程中锁定加载操作,防止新的任务请求!
|
||||
/// </summary>
|
||||
public bool LockLoadOperation = true;
|
||||
}
|
||||
```
|
||||
|
||||
## [2.2.11] - 2025-02-10
|
||||
|
||||
### Improvements
|
||||
|
||||
- AssetArtScanner配置和生成报告的容错性检测。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#465) 修复了特殊情况下,没有配置资源包文件后缀名构建失败的问题。
|
||||
- (#468) 修复了安卓平台二次启动加载原生文件或加密文件失败的问题。
|
||||
|
||||
## [2.2.10] - 2025-02-08
|
||||
|
||||
### Improvements
|
||||
|
||||
- 新增了可扩展的AssetArtScanner资源扫描工具,详细请见官方说明文档。
|
||||
- 优化了AssetBundleReporter页面。
|
||||
- 优化了AssetBundleDebugger页面。
|
||||
- 优化了微信小游戏文件系统的缓存查询机制。
|
||||
- 优化了抖音小游戏文件系统的缓存查询机制。
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#447) 修复了Unity2019平台代码编译错误问题。
|
||||
- (#456) 修复了在Package未激活有效清单之前,无法销毁的问题。
|
||||
- (#452) 修复了内置文件系统类NeedPack方法总是返回TRUE的问题。
|
||||
- (#424) 适配了Unity6000版本替换了过时方法。
|
||||
|
||||
### Added
|
||||
|
||||
- 新增了SBP构建管线构建参数:BuiltinShadersBundleName
|
||||
|
||||
- 新增了SBP构建管线构建参数:MonoScriptsBundleName
|
||||
|
||||
- 新增了全局构建管线构建参数:SingleReferencedPackAlone
|
||||
|
||||
```csharp
|
||||
/// <summary>
|
||||
/// 对单独引用的共享资源进行独立打包
|
||||
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||
/// </summary>
|
||||
public bool SingleReferencedPackAlone = true;
|
||||
```
|
||||
|
||||
- 新增了内置文件系统初始化参数:COPY_BUILDIN_PACKAGE_MANIFEST
|
||||
|
||||
```csharp
|
||||
// 内置文件系统初始化的时候,自动拷贝内置清单到沙盒目录。
|
||||
var systemParameters = FileSystemParameters.CreateDefaultBuildinFileSystemParameters();
|
||||
systemParameters.AddParameter(FileSystemParametersDefine.COPY_BUILDIN_PACKAGE_MANIFEST, true);
|
||||
```
|
||||
|
||||
## [2.2.9] - 2025-01-14
|
||||
|
||||
### Fixed
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97923f5987c469a4898718033af09e99
|
||||
guid: fab3cd742c11be2479b07f5d447a78c9
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
5
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs
Normal file
5
Assets/YooAsset/Editor/Assembly/AssemblyInfo.cs
Normal file
@@ -0,0 +1,5 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// 外部友元
|
||||
[assembly: InternalsVisibleTo("YooAsset.EditorExtension")]
|
||||
[assembly: InternalsVisibleTo("Assembly-CSharp-Editor")]
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0c3f4136cf7142346ae33e8a82cbdb27
|
||||
guid: ef774f01e50ab0a4d88122041938a6b9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
19
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
19
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class MacroDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// YooAsset版本宏定义
|
||||
/// </summary>
|
||||
public static readonly List<string> Macros = new List<string>()
|
||||
{
|
||||
"YOO_ASSET_2",
|
||||
"YOO_ASSET_2_3",
|
||||
"YOO_ASSET_2_3_OR_NEWER",
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56ea224b45d314e4a86b558404e9b6c8
|
||||
guid: a61e5c2ca04aab647b1ed0492086aa8f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
106
Assets/YooAsset/Editor/Assembly/MacroProcessor.cs
Normal file
106
Assets/YooAsset/Editor/Assembly/MacroProcessor.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class MacroProcessor : AssetPostprocessor
|
||||
{
|
||||
static string OnGeneratedCSProject(string path, string content)
|
||||
{
|
||||
XmlDocument xmlDoc = new XmlDocument();
|
||||
xmlDoc.LoadXml(content);
|
||||
|
||||
if (IsCSProjectReferenced(xmlDoc.DocumentElement) == false)
|
||||
return content;
|
||||
|
||||
if (ProcessDefineConstants(xmlDoc.DocumentElement) == false)
|
||||
return content;
|
||||
|
||||
// 将修改后的XML结构重新输出为文本
|
||||
using (var memoryStream = new MemoryStream())
|
||||
{
|
||||
var writerSettings = new XmlWriterSettings
|
||||
{
|
||||
Indent = true,
|
||||
Encoding = new UTF8Encoding(false), //无BOM
|
||||
OmitXmlDeclaration = false
|
||||
};
|
||||
|
||||
using (var xmlWriter = XmlWriter.Create(memoryStream, writerSettings))
|
||||
{
|
||||
xmlDoc.Save(xmlWriter);
|
||||
}
|
||||
return Encoding.UTF8.GetString(memoryStream.ToArray());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理宏定义
|
||||
/// </summary>
|
||||
private static bool ProcessDefineConstants(XmlElement element)
|
||||
{
|
||||
if (element == null)
|
||||
return false;
|
||||
|
||||
bool processed = false;
|
||||
foreach (XmlNode node in element.ChildNodes)
|
||||
{
|
||||
if (node.Name != "PropertyGroup")
|
||||
continue;
|
||||
|
||||
foreach (XmlNode childNode in node.ChildNodes)
|
||||
{
|
||||
if (childNode.Name != "DefineConstants")
|
||||
continue;
|
||||
|
||||
string[] defines = childNode.InnerText.Split(';');
|
||||
HashSet<string> hashSets = new HashSet<string>(defines);
|
||||
foreach (string yooMacro in MacroDefine.Macros)
|
||||
{
|
||||
string tmpMacro = yooMacro.Trim();
|
||||
if (hashSets.Contains(tmpMacro) == false)
|
||||
hashSets.Add(tmpMacro);
|
||||
}
|
||||
childNode.InnerText = string.Join(";", hashSets.ToArray());
|
||||
processed = true;
|
||||
}
|
||||
}
|
||||
|
||||
return processed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测工程是否引用了YooAsset
|
||||
/// </summary>
|
||||
private static bool IsCSProjectReferenced(XmlElement element)
|
||||
{
|
||||
if (element == null)
|
||||
return false;
|
||||
|
||||
foreach (XmlNode node in element.ChildNodes)
|
||||
{
|
||||
if (node.Name != "ItemGroup")
|
||||
continue;
|
||||
|
||||
foreach (XmlNode childNode in node.ChildNodes)
|
||||
{
|
||||
if (childNode.Name != "Reference" && childNode.Name != "ProjectReference")
|
||||
continue;
|
||||
|
||||
string include = childNode.Attributes["Include"].Value;
|
||||
if (include.Contains("YooAsset"))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94254ab8e4496214884c11a891c131c6
|
||||
guid: 88d5a41d078a82e40b82265ed4c3631a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
#if YOO_ASSET_EXPERIMENT
|
||||
namespace YooAsset.Editor.Experiment
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public class RspGenerator
|
||||
{
|
||||
// csc.rsp文件路径
|
||||
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
|
||||
|
||||
static RspGenerator()
|
||||
{
|
||||
UpdateRspFile(MacroDefine.Macros, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新csc.rsp文件
|
||||
/// </summary>
|
||||
private static void UpdateRspFile(List<string> addMacros, List<string> removeMacros)
|
||||
{
|
||||
var existingDefines = new HashSet<string>();
|
||||
var otherLines = new List<string>();
|
||||
|
||||
// 1. 读取现有内容
|
||||
ReadRspFile(existingDefines, otherLines);
|
||||
|
||||
// 2. 添加新宏
|
||||
if (addMacros != null && addMacros.Count > 0)
|
||||
{
|
||||
addMacros.ForEach(x =>
|
||||
{
|
||||
if (existingDefines.Contains(x) == false)
|
||||
existingDefines.Add(x);
|
||||
});
|
||||
}
|
||||
|
||||
// 3. 移除指定宏
|
||||
if (removeMacros != null && removeMacros.Count > 0)
|
||||
{
|
||||
removeMacros.ForEach(x =>
|
||||
{
|
||||
existingDefines.Remove(x);
|
||||
});
|
||||
}
|
||||
|
||||
// 4. 重新生成内容
|
||||
WriteRspFile(existingDefines, otherLines);
|
||||
|
||||
// 5. 刷新AssetDatabase
|
||||
AssetDatabase.Refresh();
|
||||
EditorUtility.RequestScriptReload();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取csc.rsp文件,返回宏定义和其他行
|
||||
/// </summary>
|
||||
private static void ReadRspFile(HashSet<string> defines, List<string> others)
|
||||
{
|
||||
if (defines == null)
|
||||
defines = new HashSet<string>();
|
||||
|
||||
if (others == null)
|
||||
others = new List<string>();
|
||||
|
||||
if (File.Exists(RspFilePath) == false)
|
||||
return;
|
||||
|
||||
foreach (string line in File.ReadAllLines(RspFilePath))
|
||||
{
|
||||
if (line.StartsWith("-define:"))
|
||||
{
|
||||
string[] parts = line.Split(new[] { ':' }, 2);
|
||||
if (parts.Length == 2)
|
||||
{
|
||||
defines.Add(parts[1].Trim());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
others.Add(line);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新写入csc.rsp文件
|
||||
/// </summary>
|
||||
private static void WriteRspFile(HashSet<string> defines, List<string> others)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (others != null && others.Count > 0)
|
||||
{
|
||||
others.ForEach(o => sb.AppendLine(o));
|
||||
}
|
||||
|
||||
if (defines != null && defines.Count > 0)
|
||||
{
|
||||
foreach (string define in defines)
|
||||
{
|
||||
sb.AppendLine($"-define:{define}");
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllText(RspFilePath, sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ac57bde14f2e1a4e9323751a7157ed7
|
||||
guid: c2662e1d33b1eea469695b68d18b1739
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5280dfac6a481ee429c769ba5688c9d2
|
||||
guid: bdbb4647038dcc842802f546c2fedc83
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,670 @@
|
||||
#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
|
||||
{
|
||||
public class AssetArtReporterWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetArt Reporter", false, 302)]
|
||||
public static AssetArtReporterWindow OpenWindow()
|
||||
{
|
||||
AssetArtReporterWindow window = GetWindow<AssetArtReporterWindow>("AssetArt Reporter", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
return window;
|
||||
}
|
||||
|
||||
private class ElementTableData : DefaultTableData
|
||||
{
|
||||
public ReportElement Element;
|
||||
}
|
||||
private class PassesBtnCell : ITableCell, IComparable
|
||||
{
|
||||
public object CellValue { set; get; }
|
||||
public string SearchTag { private set; get; }
|
||||
public ReportElement Element
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ReportElement)CellValue;
|
||||
}
|
||||
}
|
||||
|
||||
public PassesBtnCell(string searchTag, ReportElement element)
|
||||
{
|
||||
SearchTag = searchTag;
|
||||
CellValue = element;
|
||||
}
|
||||
public object GetDisplayObject()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other is PassesBtnCell cell)
|
||||
{
|
||||
return this.Element.Passes.CompareTo(cell.Element.Passes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
private class WhiteListBtnCell : ITableCell, IComparable
|
||||
{
|
||||
public object CellValue { set; get; }
|
||||
public string SearchTag { private set; get; }
|
||||
public ReportElement Element
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ReportElement)CellValue;
|
||||
}
|
||||
}
|
||||
|
||||
public WhiteListBtnCell(string searchTag, ReportElement element)
|
||||
{
|
||||
SearchTag = searchTag;
|
||||
CellValue = element;
|
||||
}
|
||||
public object GetDisplayObject()
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
public int CompareTo(object other)
|
||||
{
|
||||
if (other is WhiteListBtnCell cell)
|
||||
{
|
||||
return this.Element.IsWhiteList.CompareTo(cell.Element.IsWhiteList);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ToolbarSearchField _searchField;
|
||||
private Button _showHiddenBtn;
|
||||
private Button _whiteListVisibleBtn;
|
||||
private Button _passesVisibleBtn;
|
||||
private Label _titleLabel;
|
||||
private Label _descLabel;
|
||||
private TableViewer _elementTableView;
|
||||
|
||||
private ScanReportCombiner _reportCombiner;
|
||||
private string _lastestOpenFolder;
|
||||
private List<ITableData> _sourceDatas;
|
||||
private bool _elementVisibleState = true;
|
||||
private bool _whiteListVisibleState = true;
|
||||
private bool _passesVisibleState = true;
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtReporterWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入按钮
|
||||
var importSingleBtn = root.Q<Button>("SingleImportButton");
|
||||
importSingleBtn.clicked += ImportSingleBtn_clicked;
|
||||
var importMultiBtn = root.Q<Button>("MultiImportButton");
|
||||
importMultiBtn.clicked += ImportMultiBtn_clicked;
|
||||
|
||||
// 修复按钮
|
||||
var fixAllBtn = root.Q<Button>("FixAllButton");
|
||||
fixAllBtn.clicked += FixAllBtn_clicked;
|
||||
var fixSelectBtn = root.Q<Button>("FixSelectButton");
|
||||
fixSelectBtn.clicked += FixSelectBtn_clicked;
|
||||
|
||||
// 可见性按钮
|
||||
_showHiddenBtn = root.Q<Button>("ShowHiddenButton");
|
||||
_showHiddenBtn.clicked += ShowHiddenBtn_clicked;
|
||||
_whiteListVisibleBtn = root.Q<Button>("WhiteListVisibleButton");
|
||||
_whiteListVisibleBtn.clicked += WhiteListVisibleBtn_clicked;
|
||||
_passesVisibleBtn = root.Q<Button>("PassesVisibleButton");
|
||||
_passesVisibleBtn.clicked += PassesVsibleBtn_clicked;
|
||||
|
||||
// 文件导出按钮
|
||||
var exportFilesBtn = root.Q<Button>("ExportFilesButton");
|
||||
exportFilesBtn.clicked += ExportFilesBtn_clicked;
|
||||
|
||||
// 搜索过滤
|
||||
_searchField = root.Q<ToolbarSearchField>("SearchField");
|
||||
_searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 标题和备注
|
||||
_titleLabel = root.Q<Label>("ReportTitle");
|
||||
_descLabel = root.Q<Label>("ReportDesc");
|
||||
|
||||
// 列表相关
|
||||
_elementTableView = root.Q<TableViewer>("TopTableView");
|
||||
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
||||
|
||||
_lastestOpenFolder = EditorTools.GetProjectPath();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.SaveChange();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入单个报告文件
|
||||
/// </summary>
|
||||
public void ImportSingleReprotFile(string filePath)
|
||||
{
|
||||
// 记录本次打开目录
|
||||
_lastestOpenFolder = Path.GetDirectoryName(filePath);
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||
_reportCombiner.Combine(scanReport);
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入单个报告对象
|
||||
/// </summary>
|
||||
public void ImportSingleReprotFile(ScanReport report)
|
||||
{
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
_reportCombiner.Combine(report);
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void ImportSingleBtn_clicked()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
ImportSingleReprotFile(selectFilePath);
|
||||
}
|
||||
private void ImportMultiBtn_clicked()
|
||||
{
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("导入报告", _lastestOpenFolder, null);
|
||||
if (string.IsNullOrEmpty(selectFolderPath))
|
||||
return;
|
||||
|
||||
// 记录本次打开目录
|
||||
_lastestOpenFolder = selectFolderPath;
|
||||
_reportCombiner = new ScanReportCombiner();
|
||||
|
||||
try
|
||||
{
|
||||
string[] files = Directory.GetFiles(selectFolderPath);
|
||||
foreach (string filePath in files)
|
||||
{
|
||||
string extension = System.IO.Path.GetExtension(filePath);
|
||||
if (extension == ".json")
|
||||
{
|
||||
var scanReport = ScanReportConfig.ImportJsonConfig(filePath);
|
||||
_reportCombiner.Combine(scanReport);
|
||||
}
|
||||
}
|
||||
|
||||
// 刷新页面
|
||||
RefreshToolbar();
|
||||
FillTableView();
|
||||
RebuildView();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
private void FixAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复全部资源(排除白名单和隐藏元素)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixAll();
|
||||
}
|
||||
}
|
||||
private void FixSelectBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复勾选资源(包含白名单和隐藏元素)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixSelect();
|
||||
}
|
||||
}
|
||||
private void ShowHiddenBtn_clicked()
|
||||
{
|
||||
_elementVisibleState = !_elementVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void WhiteListVisibleBtn_clicked()
|
||||
{
|
||||
_whiteListVisibleState = !_whiteListVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void PassesVsibleBtn_clicked()
|
||||
{
|
||||
_passesVisibleState = !_passesVisibleState;
|
||||
RefreshToolbar();
|
||||
RebuildView();
|
||||
}
|
||||
private void ExportFilesBtn_clicked()
|
||||
{
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("导入所有选中资源", EditorTools.GetProjectPath(), string.Empty);
|
||||
if (string.IsNullOrEmpty(selectFolderPath) == false)
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.ExportFiles(selectFolderPath);
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshToolbar()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
_titleLabel.text = _reportCombiner.ReportTitle;
|
||||
_descLabel.text = _reportCombiner.ReportDesc;
|
||||
|
||||
var enableColor = new Color32(18, 100, 18, 255);
|
||||
var disableColor = new Color32(100, 100, 100, 255);
|
||||
|
||||
if (_elementVisibleState)
|
||||
_showHiddenBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_showHiddenBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
|
||||
if (_whiteListVisibleState)
|
||||
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_whiteListVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
|
||||
if (_passesVisibleState)
|
||||
_passesVisibleBtn.style.backgroundColor = new StyleColor(enableColor);
|
||||
else
|
||||
_passesVisibleBtn.style.backgroundColor = new StyleColor(disableColor);
|
||||
}
|
||||
private void FillTableView()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
_elementTableView.ClearAll(true, true);
|
||||
|
||||
// 眼睛标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(20);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var toggle = new ToggleDisplay();
|
||||
toggle.text = string.Empty;
|
||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
||||
return toggle;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var toggle = element as ToggleDisplay;
|
||||
toggle.userData = data;
|
||||
var tableData = data as ElementTableData;
|
||||
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 通过标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(70);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("通过", "通过", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var button = new Button();
|
||||
button.text = "通过";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.SetEnabled(false);
|
||||
return button;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
Button button = element as Button;
|
||||
var elementTableData = data as ElementTableData;
|
||||
if (elementTableData.Element.Passes)
|
||||
{
|
||||
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||
button.text = "通过";
|
||||
}
|
||||
else
|
||||
{
|
||||
button.style.backgroundColor = new StyleColor(new Color32(137, 0, 0, 255));
|
||||
button.text = "失败";
|
||||
}
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("通过");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 白名单标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(70);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = true;
|
||||
var column = new TableColumn("白名单", "白名单", columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
Button button = new Button();
|
||||
button.text = "白名单";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.clickable.clickedWithEventInfo += OnClickWhitListButton;
|
||||
return button;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
Button button = element as Button;
|
||||
button.userData = data;
|
||||
var elementTableData = data as ElementTableData;
|
||||
if (elementTableData.Element.IsWhiteList)
|
||||
button.style.backgroundColor = new StyleColor(new Color32(56, 147, 58, 255));
|
||||
else
|
||||
button.style.backgroundColor = new StyleColor(new Color32(100, 100, 100, 255));
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("白名单");
|
||||
headerElement.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
}
|
||||
|
||||
// 选中标题
|
||||
{
|
||||
var columnStyle = new ColumnStyle(20);
|
||||
columnStyle.Stretchable = false;
|
||||
columnStyle.Searchable = false;
|
||||
columnStyle.Sortable = false;
|
||||
var column = new TableColumn("选中框", string.Empty, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var toggle = new Toggle();
|
||||
toggle.text = string.Empty;
|
||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
toggle.RegisterValueChangedCallback((evt) => { OnSelectToggleValueChange(toggle, evt); });
|
||||
return toggle;
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var toggle = element as Toggle;
|
||||
toggle.userData = data;
|
||||
var tableData = data as ElementTableData;
|
||||
toggle.SetValueWithoutNotify(tableData.Element.IsSelected);
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// 自定义标题栏
|
||||
foreach (var header in _reportCombiner.Headers)
|
||||
{
|
||||
var columnStyle = new ColumnStyle(header.Width, header.MinWidth, header.MaxWidth);
|
||||
columnStyle.Stretchable = header.Stretchable;
|
||||
columnStyle.Searchable = header.Searchable;
|
||||
columnStyle.Sortable = header.Sortable;
|
||||
columnStyle.Counter = header.Counter;
|
||||
columnStyle.Units = header.Units;
|
||||
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
var objectFiled = new ObjectField();
|
||||
return objectFiled;
|
||||
}
|
||||
else
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
}
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
var objectFiled = element as ObjectField;
|
||||
objectFiled.value = (UnityEngine.Object)cell.GetDisplayObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
}
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
}
|
||||
|
||||
// 填充数据源
|
||||
_sourceDatas = new List<ITableData>(_reportCombiner.Elements.Count);
|
||||
foreach (var element in _reportCombiner.Elements)
|
||||
{
|
||||
var tableData = new ElementTableData();
|
||||
tableData.Element = element;
|
||||
|
||||
// 固定标题
|
||||
tableData.AddButtonCell("眼睛框");
|
||||
tableData.AddCell(new PassesBtnCell("通过", element));
|
||||
tableData.AddCell(new WhiteListBtnCell("白名单", element));
|
||||
tableData.AddButtonCell("选中框");
|
||||
|
||||
// 自定义标题
|
||||
foreach (var scanInfo in element.ScanInfos)
|
||||
{
|
||||
var header = _reportCombiner.GetHeader(scanInfo.HeaderTitle);
|
||||
if (header.HeaderType == EHeaderType.AssetPath)
|
||||
{
|
||||
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
tableData.AddAssetObjectCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.LongValue)
|
||||
{
|
||||
long value = Convert.ToInt64(scanInfo.ScanInfo);
|
||||
tableData.AddLongValueCell(scanInfo.HeaderTitle, value);
|
||||
}
|
||||
else if (header.HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
double value = Convert.ToDouble(scanInfo.ScanInfo);
|
||||
tableData.AddDoubleValueCell(scanInfo.HeaderTitle, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(header.HeaderType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
_sourceDatas.Add(tableData);
|
||||
}
|
||||
_elementTableView.itemsSource = _sourceDatas;
|
||||
}
|
||||
private void RebuildView()
|
||||
{
|
||||
if (_reportCombiner == null)
|
||||
return;
|
||||
|
||||
string searchKeyword = _searchField.value;
|
||||
|
||||
// 搜索匹配
|
||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyword);
|
||||
|
||||
// 开关匹配
|
||||
foreach (var tableData in _sourceDatas)
|
||||
{
|
||||
var elementTableData = tableData as ElementTableData;
|
||||
if (_elementVisibleState == false && elementTableData.Element.Hidden)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
if (_passesVisibleState == false && elementTableData.Element.Passes)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
if (_whiteListVisibleState == false && elementTableData.Element.IsWhiteList)
|
||||
{
|
||||
tableData.Visible = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 重建视图
|
||||
_elementTableView.RebuildView();
|
||||
}
|
||||
|
||||
private void OnClickTableViewItem(PointerDownEvent evt, ITableData tableData)
|
||||
{
|
||||
// 双击后检视对应的资源
|
||||
if (evt.clickCount == 2)
|
||||
{
|
||||
foreach (var cell in tableData.Cells)
|
||||
{
|
||||
if (cell is AssetPathCell assetPathCell)
|
||||
{
|
||||
if (assetPathCell.PingAssetObject())
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
RebuildView();
|
||||
}
|
||||
private void OnSelectToggleValueChange(Toggle toggle, ChangeEvent<bool> e)
|
||||
{
|
||||
// 处理自身
|
||||
toggle.SetValueWithoutNotify(e.newValue);
|
||||
|
||||
// 记录数据
|
||||
var elementTableData = toggle.userData as ElementTableData;
|
||||
elementTableData.Element.IsSelected = e.newValue;
|
||||
|
||||
// 处理多选目标
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.IsSelected = e.newValue;
|
||||
}
|
||||
|
||||
// 重绘视图
|
||||
RebuildView();
|
||||
}
|
||||
private void OnDisplayToggleValueChange(ToggleDisplay toggle, ChangeEvent<bool> e)
|
||||
{
|
||||
// 处理自身
|
||||
toggle.SetValueWithoutNotify(e.newValue);
|
||||
|
||||
// 记录数据
|
||||
var elementTableData = toggle.userData as ElementTableData;
|
||||
elementTableData.Element.Hidden = e.newValue;
|
||||
|
||||
// 处理多选目标
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
if (selectElement != null)
|
||||
selectElement.Element.Hidden = e.newValue;
|
||||
}
|
||||
|
||||
// 重绘视图
|
||||
RebuildView();
|
||||
}
|
||||
private void OnClickWhitListButton(EventBase evt)
|
||||
{
|
||||
// 刷新点击的按钮
|
||||
Button button = evt.target as Button;
|
||||
var elementTableData = button.userData as ElementTableData;
|
||||
elementTableData.Element.IsWhiteList = !elementTableData.Element.IsWhiteList;
|
||||
|
||||
// 刷新框选的按钮
|
||||
var selectedItems = _elementTableView.selectedItems;
|
||||
if (selectedItems.Count() > 1)
|
||||
{
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.IsWhiteList = selectElement.Element.IsWhiteList;
|
||||
}
|
||||
}
|
||||
|
||||
RebuildView();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4048f85b9ff1f424a89a9d6109e6faaf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||
<ui:Button text="Fix Select" display-tooltip-when-elided="true" name="FixSelectButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Fix All" display-tooltip-when-elided="true" name="FixAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Export Select" display-tooltip-when-elided="true" name="ExportFilesButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text=" Multi-Import" display-tooltip-when-elided="true" name="MultiImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Import" display-tooltip-when-elided="true" name="SingleImportButton" style="width: 100px; background-color: rgb(56, 147, 58);" />
|
||||
</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:Label text="标题" display-tooltip-when-elided="true" name="ReportTitle" style="height: 16px; -unity-font-style: bold; -unity-text-align: middle-center;" />
|
||||
<ui:Label text="说明" display-tooltip-when-elided="true" name="ReportDesc" style="-unity-text-align: upper-left; -unity-font-style: bold; background-color: rgb(42, 42, 42); min-height: 50px; border-top-left-radius: 3px; border-bottom-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; white-space: normal;" />
|
||||
</ui:VisualElement>
|
||||
<uie:Toolbar name="Toolbar" style="display: flex; flex-direction: row;">
|
||||
<ui:Button text="显示隐藏元素" display-tooltip-when-elided="true" name="ShowHiddenButton" style="width: 100px;" />
|
||||
<ui:Button text="显示通过元素" display-tooltip-when-elided="true" name="PassesVisibleButton" style="width: 100px;" />
|
||||
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="AssetGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b87fc70b750616849942173af3bdfd90
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
31
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs
Normal file
31
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public enum EHeaderType
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源路径
|
||||
/// </summary>
|
||||
AssetPath,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象
|
||||
/// </summary>
|
||||
AssetObject,
|
||||
|
||||
/// <summary>
|
||||
/// 字符串
|
||||
/// </summary>
|
||||
StringValue,
|
||||
|
||||
/// <summary>
|
||||
/// 整数数值
|
||||
/// </summary>
|
||||
LongValue,
|
||||
|
||||
/// <summary>
|
||||
/// 浮点数数值
|
||||
/// </summary>
|
||||
DoubleValue,
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/EHeaderType.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97cd7d0d616708e42bc53ed7d88718c9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
88
Assets/YooAsset/Editor/AssetArtReporter/ReportElement.cs
Normal file
88
Assets/YooAsset/Editor/AssetArtReporter/ReportElement.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportElement
|
||||
{
|
||||
/// <summary>
|
||||
/// GUID(白名单存储对象)
|
||||
/// </summary>
|
||||
public string GUID;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描是否通过
|
||||
/// </summary>
|
||||
public bool Passes = true;
|
||||
|
||||
/// <summary>
|
||||
/// 反馈的信息列表
|
||||
/// </summary>
|
||||
public List<ReportScanInfo> ScanInfos = new List<ReportScanInfo>();
|
||||
|
||||
|
||||
public ReportElement(string guid)
|
||||
{
|
||||
GUID = guid;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, string value)
|
||||
{
|
||||
var reportScanInfo = new ReportScanInfo(headerTitle, value);
|
||||
ScanInfos.Add(reportScanInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, long value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加扫描信息
|
||||
/// </summary>
|
||||
public void AddScanInfo(string headerTitle, double value)
|
||||
{
|
||||
AddScanInfo(headerTitle, value.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取扫描信息
|
||||
/// </summary>
|
||||
public ReportScanInfo GetScanInfo(string headerTitle)
|
||||
{
|
||||
foreach (var scanInfo in ScanInfos)
|
||||
{
|
||||
if (scanInfo.HeaderTitle == headerTitle)
|
||||
return scanInfo;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportScanInfo)} : {headerTitle}");
|
||||
return null;
|
||||
}
|
||||
|
||||
#region 临时字段
|
||||
/// <summary>
|
||||
/// 是否在列表里选中
|
||||
/// </summary>
|
||||
public bool IsSelected { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否在白名单里
|
||||
/// </summary>
|
||||
public bool IsWhiteList { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否隐藏元素
|
||||
/// </summary>
|
||||
public bool Hidden { set; get; }
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d61f7ee1a8215bf438071055f0a9cb09
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
154
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs
Normal file
154
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs
Normal file
@@ -0,0 +1,154 @@
|
||||
using System;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportHeader
|
||||
{
|
||||
public const int MaxValue = 8388608;
|
||||
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string HeaderTitle;
|
||||
|
||||
/// <summary>
|
||||
/// 标题宽度
|
||||
/// </summary>
|
||||
public int Width;
|
||||
|
||||
/// <summary>
|
||||
/// 单元列最小宽度
|
||||
/// </summary>
|
||||
public int MinWidth = 50;
|
||||
|
||||
/// <summary>
|
||||
/// 单元列最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = MaxValue;
|
||||
|
||||
/// <summary>
|
||||
/// 可伸缩选项
|
||||
/// </summary>
|
||||
public bool Stretchable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 可搜索选项
|
||||
/// </summary>
|
||||
public bool Searchable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 可排序选项
|
||||
/// </summary>
|
||||
public bool Sortable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 统计数量
|
||||
/// </summary>
|
||||
public bool Counter = false;
|
||||
|
||||
/// <summary>
|
||||
/// 展示单位
|
||||
/// </summary>
|
||||
public string Units = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
public EHeaderType HeaderType = EHeaderType.StringValue;
|
||||
|
||||
|
||||
public ReportHeader(string headerTitle, int width)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public ReportHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
|
||||
public ReportHeader SetMinWidth(int value)
|
||||
{
|
||||
MinWidth = value;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetMaxWidth(int value)
|
||||
{
|
||||
MaxWidth = value;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetStretchable()
|
||||
{
|
||||
Stretchable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetSearchable()
|
||||
{
|
||||
Searchable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetSortable()
|
||||
{
|
||||
Sortable = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetCounter()
|
||||
{
|
||||
Counter = true;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetUnits(string units)
|
||||
{
|
||||
Units = units;
|
||||
return this;
|
||||
}
|
||||
public ReportHeader SetHeaderType(EHeaderType value)
|
||||
{
|
||||
HeaderType = value;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测数值有效性
|
||||
/// </summary>
|
||||
public void CheckValueValid(string value)
|
||||
{
|
||||
if (HeaderType == EHeaderType.AssetPath)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.AssetObject)
|
||||
{
|
||||
string guid = AssetDatabase.AssetPathToGUID(value);
|
||||
if (string.IsNullOrEmpty(guid))
|
||||
throw new Exception($"{HeaderTitle} value is invalid asset object : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.DoubleValue)
|
||||
{
|
||||
if (double.TryParse(value, out double doubleValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid double value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.LongValue)
|
||||
{
|
||||
if (long.TryParse(value, out long longValue) == false)
|
||||
throw new Exception($"{HeaderTitle} value is invalid long value : {value}");
|
||||
}
|
||||
else if (HeaderType == EHeaderType.StringValue)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(HeaderType.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/ReportHeader.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3be8b45a77bb720478379c26da3aa68a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
26
Assets/YooAsset/Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
26
Assets/YooAsset/Editor/AssetArtReporter/ReportScanInfo.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ReportScanInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
public string HeaderTitle;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描反馈的信息
|
||||
/// </summary>
|
||||
public string ScanInfo;
|
||||
|
||||
public ReportScanInfo(string headerTitle, string scanInfo)
|
||||
{
|
||||
HeaderTitle = headerTitle;
|
||||
ScanInfo = scanInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 02caa7ae84ee8294a8904a5aaed420ee
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
118
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs
Normal file
118
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class ScanReport
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件签名(自动填写)
|
||||
/// </summary>
|
||||
public string FileSign;
|
||||
|
||||
/// <summary>
|
||||
/// 文件版本(自动填写)
|
||||
/// </summary>
|
||||
public string FileVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 模式类型(自动填写)
|
||||
/// </summary>
|
||||
public string SchemaType;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器GUID(自动填写)
|
||||
/// </summary>
|
||||
public string ScannerGUID;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 报告名称
|
||||
/// </summary>
|
||||
public string ReportName;
|
||||
|
||||
/// <summary>
|
||||
/// 报告介绍
|
||||
/// </summary>
|
||||
public string ReportDesc;
|
||||
|
||||
/// <summary>
|
||||
/// 报告的标题列表
|
||||
/// </summary>
|
||||
public List<ReportHeader> ReportHeaders = new List<ReportHeader>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描的元素列表
|
||||
/// </summary>
|
||||
public List<ReportElement> ReportElements = new List<ReportElement>();
|
||||
|
||||
|
||||
public ScanReport(string reportName, string reportDesc)
|
||||
{
|
||||
ReportName = reportName;
|
||||
ReportDesc = reportDesc;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加标题
|
||||
/// </summary>
|
||||
public ReportHeader AddHeader(string headerTitle, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
var reportHeader = new ReportHeader(headerTitle, width, minWidth, maxWidth);
|
||||
ReportHeaders.Add(reportHeader);
|
||||
return reportHeader;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测错误
|
||||
/// </summary>
|
||||
public void CheckError()
|
||||
{
|
||||
// 检测标题
|
||||
Dictionary<string, ReportHeader> headerMap = new Dictionary<string, ReportHeader>();
|
||||
foreach (var header in ReportHeaders)
|
||||
{
|
||||
string headerTitle = header.HeaderTitle;
|
||||
if (headerMap.ContainsKey(headerTitle))
|
||||
throw new Exception($"The header title {headerTitle} already exists !");
|
||||
else
|
||||
headerMap.Add(headerTitle, header);
|
||||
}
|
||||
|
||||
// 检测扫描元素
|
||||
HashSet<string> elementMap = new HashSet<string>();
|
||||
foreach (var element in ReportElements)
|
||||
{
|
||||
if (string.IsNullOrEmpty(element.GUID))
|
||||
throw new Exception($"The report element GUID is null or empty !");
|
||||
|
||||
if (elementMap.Contains(element.GUID))
|
||||
throw new Exception($"The report element GUID already exists ! {element.GUID}");
|
||||
else
|
||||
elementMap.Add(element.GUID);
|
||||
|
||||
foreach (var scanInfo in element.ScanInfos)
|
||||
{
|
||||
if (headerMap.ContainsKey(scanInfo.HeaderTitle) == false)
|
||||
throw new Exception($"The report element header {scanInfo.HeaderTitle} is missing !");
|
||||
|
||||
// 检测数值有效性
|
||||
var header = headerMap[scanInfo.HeaderTitle];
|
||||
header.CheckValueValid(scanInfo.ScanInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtReporter/ScanReport.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 650e3e4af4ede2a4eb2471c30e7820bb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
221
Assets/YooAsset/Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
221
Assets/YooAsset/Editor/AssetArtReporter/ScanReportCombiner.cs
Normal file
@@ -0,0 +1,221 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源扫描报告合并器
|
||||
/// 说明:相同类型的报告可以合并查看
|
||||
/// </summary>
|
||||
public class ScanReportCombiner
|
||||
{
|
||||
/// <summary>
|
||||
/// 模式类型
|
||||
/// </summary>
|
||||
public string SchemaType { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告标题
|
||||
/// </summary>
|
||||
public string ReportTitle { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告介绍
|
||||
/// </summary>
|
||||
public string ReportDesc { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 标题列表
|
||||
/// </summary>
|
||||
public List<ReportHeader> Headers = new List<ReportHeader>();
|
||||
|
||||
/// <summary>
|
||||
/// 扫描结果
|
||||
/// </summary>
|
||||
public readonly List<ReportElement> Elements = new List<ReportElement>(10000);
|
||||
private readonly Dictionary<string, ScanReport> _combines = new Dictionary<string, ScanReport>(100);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 合并报告文件
|
||||
/// 注意:模式不同的报告文件会合并失败!
|
||||
/// </summary>
|
||||
public bool Combine(ScanReport scanReport)
|
||||
{
|
||||
if (string.IsNullOrEmpty(scanReport.SchemaType))
|
||||
{
|
||||
Debug.LogError("Scan report schema type is null or empty !");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(SchemaType))
|
||||
{
|
||||
SchemaType = scanReport.SchemaType;
|
||||
ReportTitle = scanReport.ReportName;
|
||||
ReportDesc = scanReport.ReportDesc;
|
||||
Headers = scanReport.ReportHeaders;
|
||||
}
|
||||
|
||||
if (SchemaType != scanReport.SchemaType)
|
||||
{
|
||||
Debug.LogWarning($"Scan report has different schema type!{scanReport.SchemaType} != {SchemaType}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_combines.ContainsKey(scanReport.ScannerGUID))
|
||||
{
|
||||
Debug.LogWarning($"Scan report has already existed : {scanReport.ScannerGUID}");
|
||||
return false;
|
||||
}
|
||||
|
||||
_combines.Add(scanReport.ScannerGUID, scanReport);
|
||||
CombineInternal(scanReport);
|
||||
return true;
|
||||
}
|
||||
private void CombineInternal(ScanReport scanReport)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
List<ReportElement> elements = scanReport.ReportElements;
|
||||
|
||||
// 设置白名单
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (scanner.CheckWhiteList(element.GUID))
|
||||
element.IsWhiteList = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 添加到集合
|
||||
Elements.AddRange(elements);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的标题类
|
||||
/// </summary>
|
||||
public ReportHeader GetHeader(string headerTitle)
|
||||
{
|
||||
foreach (var header in Headers)
|
||||
{
|
||||
if (header.HeaderTitle == headerTitle)
|
||||
return header;
|
||||
}
|
||||
|
||||
UnityEngine.Debug.LogWarning($"Not found {nameof(ReportHeader)} : {headerTitle}");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出选中文件
|
||||
/// </summary>
|
||||
public void ExportFiles(string exportFolderPath)
|
||||
{
|
||||
if (string.IsNullOrEmpty(exportFolderPath))
|
||||
return;
|
||||
|
||||
foreach (var element in Elements)
|
||||
{
|
||||
if (element.IsSelected)
|
||||
{
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(element.GUID);
|
||||
if (string.IsNullOrEmpty(assetPath) == false)
|
||||
{
|
||||
string destPath = Path.Combine(exportFolderPath, assetPath);
|
||||
EditorTools.CopyFile(assetPath, destPath, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存改变数据
|
||||
/// </summary>
|
||||
public void SaveChange()
|
||||
{
|
||||
// 存储白名单
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
var scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
List<string> whiteList = new List<string>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.IsWhiteList)
|
||||
whiteList.Add(element.GUID);
|
||||
}
|
||||
whiteList.Sort();
|
||||
scanner.WhiteList = whiteList;
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复所有元素
|
||||
/// 注意:排除白名单和隐藏元素
|
||||
/// </summary>
|
||||
public void FixAll()
|
||||
{
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.Passes || element.IsWhiteList || element.Hidden)
|
||||
continue;
|
||||
fixList.Add(element);
|
||||
}
|
||||
FixInternal(scannerGUID, fixList);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修复选定元素
|
||||
/// 注意:包含白名单和隐藏元素
|
||||
/// </summary>
|
||||
public void FixSelect()
|
||||
{
|
||||
foreach (var scanReport in _combines.Values)
|
||||
{
|
||||
string scannerGUID = scanReport.ScannerGUID;
|
||||
var elements = scanReport.ReportElements;
|
||||
|
||||
List<ReportElement> fixList = new List<ReportElement>(elements.Count);
|
||||
foreach (var element in elements)
|
||||
{
|
||||
if (element.Passes)
|
||||
continue;
|
||||
if (element.IsSelected)
|
||||
fixList.Add(element);
|
||||
}
|
||||
FixInternal(scannerGUID, fixList);
|
||||
}
|
||||
}
|
||||
|
||||
private void FixInternal(string scannerGUID, List<ReportElement> fixList)
|
||||
{
|
||||
AssetArtScanner scanner = AssetArtScannerSettingData.Setting.GetScanner(scannerGUID);
|
||||
if (scanner != null)
|
||||
{
|
||||
var schema = scanner.LoadSchema();
|
||||
if (schema != null)
|
||||
{
|
||||
schema.FixResult(fixList);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8524c3deb9b27fe4e8e63f15b9ffaaa3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
54
Assets/YooAsset/Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
54
Assets/YooAsset/Editor/AssetArtReporter/ScanReportConfig.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScanReportConfig
|
||||
{
|
||||
/// <summary>
|
||||
/// 导入JSON报告文件
|
||||
/// </summary>
|
||||
public static ScanReport ImportJsonConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
string jsonData = FileUtility.ReadAllText(filePath);
|
||||
ScanReport report = JsonUtility.FromJson<ScanReport>(jsonData);
|
||||
|
||||
// 检测配置文件的签名
|
||||
if (report.FileSign != ScannerDefine.ReportFileSign)
|
||||
throw new Exception($"导入的报告文件无法识别 : {filePath}");
|
||||
|
||||
// 检测报告文件的版本
|
||||
if (report.FileVersion != ScannerDefine.ReportFileVersion)
|
||||
throw new Exception($"报告文件的版本不匹配 : {report.FileVersion} != {ScannerDefine.ReportFileVersion}");
|
||||
|
||||
// 检测标题数和内容是否匹配
|
||||
foreach (var element in report.ReportElements)
|
||||
{
|
||||
if (element.ScanInfos.Count != report.ReportHeaders.Count)
|
||||
{
|
||||
throw new Exception($"报告的标题数和内容不匹配!");
|
||||
}
|
||||
}
|
||||
|
||||
return report;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出JSON报告文件
|
||||
/// </summary>
|
||||
public static void ExportJsonConfig(string savePath, ScanReport scanReport)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
string json = JsonUtility.ToJson(scanReport, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 694cf47ade54f2b4fa6e618c1310c476
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64b064347ca7a404494a996b072e2e29
|
||||
guid: 9bc1ecc3b72dfc34782fb6926d679f92
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
13
Assets/YooAsset/Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
13
Assets/YooAsset/Editor/AssetArtScanner/AssetArtCollector.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtCollector
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描目录
|
||||
/// </summary>
|
||||
public string CollectPath = string.Empty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e7252b59455e5c45af0041ccd24b234
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
132
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
132
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScanner.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
[Serializable]
|
||||
public class AssetArtScanner
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器GUID
|
||||
/// </summary>
|
||||
public string ScannerGUID = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器名称
|
||||
/// </summary>
|
||||
public string ScannerName = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器描述
|
||||
/// </summary>
|
||||
public string ScannerDesc = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描模式
|
||||
/// 注意:文件路径或文件GUID
|
||||
/// </summary>
|
||||
public string ScannerSchema = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 存储目录
|
||||
/// </summary>
|
||||
public string SaveDirectory = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 收集列表
|
||||
/// </summary>
|
||||
public List<AssetArtCollector> Collectors = new List<AssetArtCollector>();
|
||||
|
||||
/// <summary>
|
||||
/// 白名单
|
||||
/// </summary>
|
||||
public List<string> WhiteList = new List<string>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 检测关键字匹配
|
||||
/// </summary>
|
||||
public bool CheckKeyword(string keyword)
|
||||
{
|
||||
if (ScannerName.Contains(keyword) || ScannerDesc.Contains(keyword))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否在白名单里
|
||||
/// </summary>
|
||||
public bool CheckWhiteList(string guid)
|
||||
{
|
||||
return WhiteList.Contains(guid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检测配置错误
|
||||
/// </summary>
|
||||
public void CheckConfigError()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerName))
|
||||
throw new Exception($"Scanner name is null or empty !");
|
||||
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
throw new Exception($"Scanner {ScannerName} schema is null !");
|
||||
|
||||
if (string.IsNullOrEmpty(SaveDirectory) == false)
|
||||
{
|
||||
if (Directory.Exists(SaveDirectory) == false)
|
||||
throw new Exception($"Scanner {ScannerName} save directory is invalid : {SaveDirectory}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加载扫描模式实例
|
||||
/// </summary>
|
||||
public ScannerSchema LoadSchema()
|
||||
{
|
||||
if (string.IsNullOrEmpty(ScannerSchema))
|
||||
return null;
|
||||
|
||||
string filePath;
|
||||
if (ScannerSchema.StartsWith("Assets/"))
|
||||
{
|
||||
filePath = ScannerSchema;
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = ScannerSchema;
|
||||
filePath = AssetDatabase.GUIDToAssetPath(guid);
|
||||
}
|
||||
|
||||
var schema = AssetDatabase.LoadMainAssetAtPath(filePath) as ScannerSchema;
|
||||
if (schema == null)
|
||||
Debug.LogWarning($"Failed load scanner schema : {filePath}");
|
||||
return schema;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 运行扫描器生成报告类
|
||||
/// </summary>
|
||||
public ScanReport RunScanner()
|
||||
{
|
||||
if (Collectors.Count == 0)
|
||||
Debug.LogWarning($"Scanner {ScannerName} collector is empty !");
|
||||
|
||||
ScannerSchema schema = LoadSchema();
|
||||
if (schema == null)
|
||||
throw new Exception($"Failed to load schema : {ScannerSchema}");
|
||||
|
||||
var report = schema.RunScanner(this);
|
||||
report.FileSign = ScannerDefine.ReportFileSign;
|
||||
report.FileVersion = ScannerDefine.ReportFileVersion;
|
||||
report.SchemaType = schema.GetType().FullName;
|
||||
report.ScannerGUID = ScannerGUID;
|
||||
return report;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c63683b07b7a2454b93539ae6b9f32ea
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerConfig
|
||||
{
|
||||
public class ConfigWrapper
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件签名
|
||||
/// </summary>
|
||||
public string FileSign;
|
||||
|
||||
/// <summary>
|
||||
/// 文件版本
|
||||
/// </summary>
|
||||
public string FileVersion;
|
||||
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入JSON配置文件
|
||||
/// </summary>
|
||||
public static void ImportJsonConfig(string filePath)
|
||||
{
|
||||
if (File.Exists(filePath) == false)
|
||||
throw new FileNotFoundException(filePath);
|
||||
|
||||
string json = FileUtility.ReadAllText(filePath);
|
||||
ConfigWrapper setting = JsonUtility.FromJson<ConfigWrapper>(json);
|
||||
|
||||
// 检测配置文件的签名
|
||||
if (setting.FileSign != ScannerDefine.SettingFileSign)
|
||||
throw new Exception($"导入的配置文件无法识别 : {filePath}");
|
||||
|
||||
// 检测配置文件的版本
|
||||
if (setting.FileVersion != ScannerDefine.SettingFileVersion)
|
||||
throw new Exception($"配置文件的版本不匹配 : {setting.FileVersion} != {ScannerDefine.SettingFileVersion}");
|
||||
|
||||
// 检测配置合法性
|
||||
HashSet<string> scanGUIDs = new HashSet<string>();
|
||||
foreach (var sacnner in setting.Scanners)
|
||||
{
|
||||
if (scanGUIDs.Contains(sacnner.ScannerGUID))
|
||||
{
|
||||
throw new Exception($"Scanner {sacnner.ScannerName} GUID is existed : {sacnner.ScannerGUID} ");
|
||||
}
|
||||
else
|
||||
{
|
||||
scanGUIDs.Add(sacnner.ScannerGUID);
|
||||
}
|
||||
}
|
||||
|
||||
AssetArtScannerSettingData.Setting.Scanners = setting.Scanners;
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导出JSON配置文件
|
||||
/// </summary>
|
||||
public static void ExportJsonConfig(string savePath)
|
||||
{
|
||||
if (File.Exists(savePath))
|
||||
File.Delete(savePath);
|
||||
|
||||
ConfigWrapper wrapper = new ConfigWrapper();
|
||||
wrapper.FileSign = ScannerDefine.SettingFileSign;
|
||||
wrapper.FileVersion = ScannerDefine.SettingFileVersion;
|
||||
wrapper.Scanners = AssetArtScannerSettingData.Setting.Scanners;
|
||||
|
||||
string json = JsonUtility.ToJson(wrapper, true);
|
||||
FileUtility.WriteAllText(savePath, json);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bed1ef72d1c03e848a41d5ea115e9870
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using NUnit.Framework.Constraints;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSetting : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 扫描器列表
|
||||
/// </summary>
|
||||
public List<AssetArtScanner> Scanners = new List<AssetArtScanner>();
|
||||
|
||||
/// <summary>
|
||||
/// 开始扫描
|
||||
/// </summary>
|
||||
public ScannerResult BeginScan(string scannerGUID)
|
||||
{
|
||||
try
|
||||
{
|
||||
// 获取扫描器配置
|
||||
var scanner = GetScanner(scannerGUID);
|
||||
if (scanner == null)
|
||||
throw new Exception($"Invalid scanner GUID : {scannerGUID}");
|
||||
|
||||
// 检测配置合法性
|
||||
scanner.CheckConfigError();
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定的扫描器
|
||||
/// </summary>
|
||||
public AssetArtScanner GetScanner(string scannerGUID)
|
||||
{
|
||||
foreach (var scanner in Scanners)
|
||||
{
|
||||
if (scanner.ScannerGUID == scannerGUID)
|
||||
return scanner;
|
||||
}
|
||||
|
||||
Debug.LogWarning($"Not found scanner : {scannerGUID}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84df5e62e3f1b6746a1263e076b003e1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerSettingData
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置数据是否被修改
|
||||
/// </summary>
|
||||
public static bool IsDirty { private set; get; } = false;
|
||||
|
||||
|
||||
static AssetArtScannerSettingData()
|
||||
{
|
||||
}
|
||||
|
||||
private static AssetArtScannerSetting _setting = null;
|
||||
public static AssetArtScannerSetting Setting
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_setting == null)
|
||||
_setting = SettingLoader.LoadSettingData<AssetArtScannerSetting>();
|
||||
return _setting;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储配置文件
|
||||
/// </summary>
|
||||
public static void SaveFile()
|
||||
{
|
||||
if (Setting != null)
|
||||
{
|
||||
IsDirty = false;
|
||||
EditorUtility.SetDirty(Setting);
|
||||
AssetDatabase.SaveAssets();
|
||||
Debug.Log($"{nameof(AssetArtScannerSetting)}.asset is saved!");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有数据
|
||||
/// </summary>
|
||||
public static void ClearAll()
|
||||
{
|
||||
Setting.Scanners.Clear();
|
||||
SaveFile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll()
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描所有项
|
||||
/// </summary>
|
||||
public static void ScanAll(string keyword)
|
||||
{
|
||||
foreach (var scanner in Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(keyword) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(keyword) == false)
|
||||
continue;
|
||||
}
|
||||
|
||||
var scanResult = Setting.BeginScan(scanner.ScannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError($"{scanner.ScannerName} failed : {scanResult.ErrorInfo}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扫描单项
|
||||
/// </summary>
|
||||
public static ScannerResult Scan(string scannerGUID)
|
||||
{
|
||||
var scanResult = Setting.BeginScan(scannerGUID);
|
||||
if (scanResult.Succeed == false)
|
||||
{
|
||||
Debug.LogError(scanResult.ErrorInfo);
|
||||
}
|
||||
return scanResult;
|
||||
}
|
||||
|
||||
// 扫描器编辑相关
|
||||
public static AssetArtScanner CreateScanner(string name, string desc)
|
||||
{
|
||||
AssetArtScanner scanner = new AssetArtScanner();
|
||||
scanner.ScannerGUID = System.Guid.NewGuid().ToString();
|
||||
scanner.ScannerName = name;
|
||||
scanner.ScannerDesc = desc;
|
||||
Setting.Scanners.Add(scanner);
|
||||
IsDirty = true;
|
||||
return scanner;
|
||||
}
|
||||
public static void RemoveScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (Setting.Scanners.Remove(scanner))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove scanner : {scanner.ScannerName}");
|
||||
}
|
||||
}
|
||||
public static void ModifyScanner(AssetArtScanner scanner)
|
||||
{
|
||||
if (scanner != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
|
||||
// 资源收集编辑相关
|
||||
public static void CreateCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
scanner.Collectors.Add(collector);
|
||||
IsDirty = true;
|
||||
}
|
||||
public static void RemoveCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner.Collectors.Remove(collector))
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Failed remove collector : {collector.CollectPath}");
|
||||
}
|
||||
}
|
||||
public static void ModifyCollector(AssetArtScanner scanner, AssetArtCollector collector)
|
||||
{
|
||||
if (scanner != null && collector != null)
|
||||
{
|
||||
IsDirty = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fda10f23f6f36bf498b54323fe4f680b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
549
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
549
Assets/YooAsset/Editor/AssetArtScanner/AssetArtScannerWindow.cs
Normal file
@@ -0,0 +1,549 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetArtScannerWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetArt Scanner", false, 301)]
|
||||
public static void OpenWindow()
|
||||
{
|
||||
AssetArtScannerWindow window = GetWindow<AssetArtScannerWindow>("AssetArt Scanner", true, WindowsDefine.DockedWindowTypes);
|
||||
window.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private Button _saveButton;
|
||||
private ListView _scannerListView;
|
||||
private ToolbarSearchField _scannerSearchField;
|
||||
private VisualElement _scannerContentContainer;
|
||||
private VisualElement _inspectorContainer;
|
||||
private Label _schemaGuideTxt;
|
||||
private TextField _scannerNameTxt;
|
||||
private TextField _scannerDescTxt;
|
||||
private ObjectField _scannerSchemaField;
|
||||
private ObjectField _outputFolderField;
|
||||
private ScrollView _collectorScrollView;
|
||||
|
||||
private int _lastModifyScannerIndex = 0;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
Undo.undoRedoPerformed -= RefreshWindow;
|
||||
Undo.undoRedoPerformed += RefreshWindow;
|
||||
|
||||
try
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<AssetArtScannerWindow>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 导入导出按钮
|
||||
var exportBtn = root.Q<Button>("ExportButton");
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_clicked;
|
||||
|
||||
// 配置保存按钮
|
||||
_saveButton = root.Q<Button>("SaveButton");
|
||||
_saveButton.clicked += SaveBtn_clicked;
|
||||
|
||||
// 扫描按钮
|
||||
var scanAllBtn = root.Q<Button>("ScanAllButton");
|
||||
scanAllBtn.clicked += ScanAllBtn_clicked;
|
||||
var scanBtn = root.Q<Button>("ScanBtn");
|
||||
scanBtn.clicked += ScanBtn_clicked;
|
||||
|
||||
// 扫描列表相关
|
||||
_scannerListView = root.Q<ListView>("ScannerListView");
|
||||
_scannerListView.makeItem = MakeScannerListViewItem;
|
||||
_scannerListView.bindItem = BindScannerListViewItem;
|
||||
#if UNITY_2022_3_OR_NEWER
|
||||
_scannerListView.selectionChanged += ScannerListView_onSelectionChange;
|
||||
#elif UNITY_2020_1_OR_NEWER
|
||||
_scannerListView.onSelectionChange += ScannerListView_onSelectionChange;
|
||||
#else
|
||||
_scannerListView.onSelectionChanged += ScannerListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 扫描列表过滤
|
||||
_scannerSearchField = root.Q<ToolbarSearchField>("ScannerSearchField");
|
||||
_scannerSearchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 扫描器添加删除按钮
|
||||
var scannerAddContainer = root.Q("ScannerAddContainer");
|
||||
{
|
||||
var addBtn = scannerAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddScannerBtn_clicked;
|
||||
var removeBtn = scannerAddContainer.Q<Button>("RemoveBtn");
|
||||
removeBtn.clicked += RemoveScannerBtn_clicked;
|
||||
}
|
||||
|
||||
// 扫描器容器
|
||||
_scannerContentContainer = root.Q("ScannerContentContainer");
|
||||
|
||||
// 检视界面容器
|
||||
_inspectorContainer = root.Q("InspectorContainer");
|
||||
|
||||
// 扫描器指南
|
||||
_schemaGuideTxt = root.Q<Label>("SchemaUserGuide");
|
||||
|
||||
// 扫描器名称
|
||||
_scannerNameTxt = root.Q<TextField>("ScannerName");
|
||||
_scannerNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerName = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描器备注
|
||||
_scannerDescTxt = root.Q<TextField>("ScannerDesc");
|
||||
_scannerDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
selectScanner.ScannerDesc = evt.newValue;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
});
|
||||
|
||||
// 扫描模式
|
||||
_scannerSchemaField = root.Q<ObjectField>("ScanSchema");
|
||||
_scannerSchemaField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
selectScanner.ScannerSchema = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
});
|
||||
|
||||
// 存储目录
|
||||
_outputFolderField = root.Q<ObjectField>("OutputFolder");
|
||||
_outputFolderField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner != null)
|
||||
{
|
||||
if (evt.newValue == null)
|
||||
{
|
||||
selectScanner.SaveDirectory = string.Empty;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
string assetPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
if (AssetDatabase.IsValidFolder(assetPath))
|
||||
{
|
||||
selectScanner.SaveDirectory = assetPath;
|
||||
AssetArtScannerSettingData.ModifyScanner(selectScanner);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Select asset object not folder ! {assetPath}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 收集列表相关
|
||||
_collectorScrollView = root.Q<ScrollView>("CollectorScrollView");
|
||||
_collectorScrollView.style.height = new Length(100, LengthUnit.Percent);
|
||||
_collectorScrollView.viewDataKey = "scrollView";
|
||||
|
||||
// 收集器创建按钮
|
||||
var collectorAddContainer = root.Q("CollectorAddContainer");
|
||||
{
|
||||
var addBtn = collectorAddContainer.Q<Button>("AddBtn");
|
||||
addBtn.clicked += AddCollectorBtn_clicked;
|
||||
}
|
||||
|
||||
// 刷新窗体
|
||||
RefreshWindow();
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
}
|
||||
public void OnDestroy()
|
||||
{
|
||||
// 注意:清空所有撤销操作
|
||||
Undo.ClearAll();
|
||||
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
if (_saveButton != null)
|
||||
{
|
||||
if (AssetArtScannerSettingData.IsDirty)
|
||||
{
|
||||
if (_saveButton.enabledSelf == false)
|
||||
_saveButton.SetEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_saveButton.enabledSelf)
|
||||
_saveButton.SetEnabled(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshWindow()
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFolderPanel("Export JSON", "Assets/");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ExportJsonConfig($"{resultPath}/AssetArtScannerConfig.json");
|
||||
}
|
||||
}
|
||||
private void ImportBtn_clicked()
|
||||
{
|
||||
string resultPath = EditorTools.OpenFilePath("Import JSON", "Assets/", "json");
|
||||
if (resultPath != null)
|
||||
{
|
||||
AssetArtScannerConfig.ImportJsonConfig(resultPath);
|
||||
RefreshWindow();
|
||||
}
|
||||
}
|
||||
private void SaveBtn_clicked()
|
||||
{
|
||||
AssetArtScannerSettingData.SaveFile();
|
||||
}
|
||||
private void ScanAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始全面扫描!", "Yes", "No"))
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
AssetArtScannerSettingData.ScanAll(searchKeyWord);
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("全面扫描已经取消");
|
||||
}
|
||||
}
|
||||
private void ScanBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
ScannerResult scannerResult = AssetArtScannerSettingData.Scan(selectScanner.ScannerGUID);
|
||||
if (scannerResult.Succeed)
|
||||
{
|
||||
// 自动打开报告界面
|
||||
scannerResult.OpenReportWindow();
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_lastModifyScannerIndex = 0;
|
||||
RefreshWindow();
|
||||
}
|
||||
|
||||
// 分组列表相关
|
||||
private void FillScannerListViewData()
|
||||
{
|
||||
_scannerListView.Clear();
|
||||
_scannerListView.ClearSelection();
|
||||
|
||||
var filterItems = FilterScanners();
|
||||
if (AssetArtScannerSettingData.Setting.Scanners.Count == filterItems.Count)
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = true;
|
||||
#endif
|
||||
_scannerListView.itemsSource = AssetArtScannerSettingData.Setting.Scanners;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
else
|
||||
{
|
||||
#if UNITY_2020_3_OR_NEWER
|
||||
_scannerListView.reorderable = false;
|
||||
#endif
|
||||
_scannerListView.itemsSource = filterItems;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
|
||||
if (_lastModifyScannerIndex >= 0 && _lastModifyScannerIndex < _scannerListView.itemsSource.Count)
|
||||
{
|
||||
_scannerListView.selectedIndex = _lastModifyScannerIndex;
|
||||
}
|
||||
}
|
||||
private List<AssetArtScanner> FilterScanners()
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
List<AssetArtScanner> result = new List<AssetArtScanner>(AssetArtScannerSettingData.Setting.Scanners.Count);
|
||||
|
||||
// 过滤列表
|
||||
foreach (var scanner in AssetArtScannerSettingData.Setting.Scanners)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (scanner.CheckKeyword(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(scanner);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
private VisualElement MakeScannerListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.height = 20f;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindScannerListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<AssetArtScanner> sourceList = _scannerListView.itemsSource as List<AssetArtScanner>;
|
||||
var scanner = sourceList[index];
|
||||
var textField1 = element.Q<Label>("Label1");
|
||||
if (string.IsNullOrEmpty(scanner.ScannerDesc))
|
||||
textField1.text = scanner.ScannerName;
|
||||
else
|
||||
textField1.text = $"{scanner.ScannerName} ({scanner.ScannerDesc})";
|
||||
}
|
||||
private void ScannerListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
{
|
||||
_scannerContentContainer.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
_scannerContentContainer.visible = true;
|
||||
_lastModifyScannerIndex = _scannerListView.selectedIndex;
|
||||
_scannerNameTxt.SetValueWithoutNotify(selectScanner.ScannerName);
|
||||
_scannerDescTxt.SetValueWithoutNotify(selectScanner.ScannerDesc);
|
||||
|
||||
// 显示检视面板
|
||||
var scanSchema = selectScanner.LoadSchema();
|
||||
RefreshInspector(scanSchema);
|
||||
|
||||
// 设置Schema对象
|
||||
if (scanSchema == null)
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(null);
|
||||
_schemaGuideTxt.text = string.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
_scannerSchemaField.SetValueWithoutNotify(scanSchema);
|
||||
_schemaGuideTxt.text = scanSchema.GetUserGuide();
|
||||
}
|
||||
|
||||
// 显示存储目录
|
||||
DefaultAsset saveFolder = AssetDatabase.LoadAssetAtPath<DefaultAsset>(selectScanner.SaveDirectory);
|
||||
if (saveFolder == null)
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
_outputFolderField.SetValueWithoutNotify(saveFolder);
|
||||
}
|
||||
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void AddScannerBtn_clicked()
|
||||
{
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddScanner");
|
||||
AssetArtScannerSettingData.CreateScanner("Default Scanner", string.Empty);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
private void RemoveScannerBtn_clicked()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveScanner");
|
||||
AssetArtScannerSettingData.RemoveScanner(selectScanner);
|
||||
FillScannerListViewData();
|
||||
}
|
||||
|
||||
// 收集列表相关
|
||||
private void FillCollectorViewData()
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
// 填充数据
|
||||
_collectorScrollView.Clear();
|
||||
for (int i = 0; i < selectScanner.Collectors.Count; i++)
|
||||
{
|
||||
VisualElement element = MakeCollectorListViewItem();
|
||||
BindCollectorListViewItem(element, i);
|
||||
_collectorScrollView.Add(element);
|
||||
}
|
||||
}
|
||||
private VisualElement MakeCollectorListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
|
||||
VisualElement elementTop = new VisualElement();
|
||||
elementTop.style.flexDirection = FlexDirection.Row;
|
||||
element.Add(elementTop);
|
||||
|
||||
VisualElement elementSpace = new VisualElement();
|
||||
elementSpace.style.flexDirection = FlexDirection.Column;
|
||||
element.Add(elementSpace);
|
||||
|
||||
// Top VisualElement
|
||||
{
|
||||
var button = new Button();
|
||||
button.name = "Button1";
|
||||
button.text = "-";
|
||||
button.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
button.style.flexGrow = 0f;
|
||||
elementTop.Add(button);
|
||||
}
|
||||
{
|
||||
var objectField = new ObjectField();
|
||||
objectField.name = "ObjectField1";
|
||||
objectField.label = "Collector";
|
||||
objectField.objectType = typeof(UnityEngine.Object);
|
||||
objectField.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
objectField.style.flexGrow = 1f;
|
||||
elementTop.Add(objectField);
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
}
|
||||
|
||||
// Space VisualElement
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.height = 10;
|
||||
elementSpace.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindCollectorListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var selectScanner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectScanner == null)
|
||||
return;
|
||||
|
||||
var collector = selectScanner.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
removeBtn.clicked += () =>
|
||||
{
|
||||
RemoveCollectorBtn_clicked(collector);
|
||||
};
|
||||
|
||||
// Collector Path
|
||||
var objectField1 = element.Q<ObjectField>("ObjectField1");
|
||||
objectField1.SetValueWithoutNotify(collectObject);
|
||||
objectField1.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetArtScannerSettingData.ModifyCollector(selectScanner, collector);
|
||||
});
|
||||
}
|
||||
private void AddCollectorBtn_clicked()
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow AddCollector");
|
||||
AssetArtCollector collector = new AssetArtCollector();
|
||||
AssetArtScannerSettingData.CreateCollector(selectSacnner, collector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
private void RemoveCollectorBtn_clicked(AssetArtCollector selectCollector)
|
||||
{
|
||||
var selectSacnner = _scannerListView.selectedItem as AssetArtScanner;
|
||||
if (selectSacnner == null)
|
||||
return;
|
||||
if (selectCollector == null)
|
||||
return;
|
||||
|
||||
Undo.RecordObject(AssetArtScannerSettingData.Setting, "YooAsset.AssetArtScannerWindow RemoveCollector");
|
||||
AssetArtScannerSettingData.RemoveCollector(selectSacnner, selectCollector);
|
||||
FillCollectorViewData();
|
||||
}
|
||||
|
||||
// 属性面板相关
|
||||
private void RefreshInspector(ScannerSchema scanSchema)
|
||||
{
|
||||
if (scanSchema == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
var inspector = scanSchema.CreateInspector();
|
||||
if (inspector == null)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (inspector.Containner is VisualElement container)
|
||||
{
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, true);
|
||||
_inspectorContainer.Clear();
|
||||
_inspectorContainer.Add(container);
|
||||
_inspectorContainer.style.width = inspector.Width;
|
||||
_inspectorContainer.style.minWidth = inspector.MinWidth;
|
||||
_inspectorContainer.style.maxWidth = inspector.MaxWidth;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"{nameof(ScannerSchema)} inspector container is invalid !");
|
||||
UIElementsTools.SetElementVisible(_inspectorContainer, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bff583b32bbeb7e498920bfdc84dba90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,33 @@
|
||||
<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;">
|
||||
<ui:Button text="Save" display-tooltip-when-elided="true" name="SaveButton" 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="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
|
||||
<ui:Button text="Scan All" display-tooltip-when-elided="true" name="ScanAllButton" style="width: 80px; background-color: rgb(56, 147, 58);" />
|
||||
</uie:Toolbar>
|
||||
<ui:VisualElement name="ContentContainer" style="flex-grow: 1; flex-direction: row;">
|
||||
<ui:VisualElement name="ScannerListContainer" style="width: 250px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Scanner List" display-tooltip-when-elided="true" name="ScannerListTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 3px; border-right-width: 3px; border-top-width: 3px; border-bottom-width: 3px; font-size: 12px;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="ScannerSearchField" style="width: 230px;" />
|
||||
<ui:ListView focusable="true" name="ScannerListView" item-height="20" virtualization-method="DynamicHeight" reorder-mode="Animated" reorderable="true" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="ScannerAddContainer" style="justify-content: center; flex-direction: row; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="ScannerContentContainer" style="flex-grow: 1; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; min-width: 400px;">
|
||||
<ui:Label text="Scanner" display-tooltip-when-elided="true" name="ScannerContentTitle" style="-unity-text-align: upper-center; -unity-font-style: bold; font-size: 12px; border-top-width: 3px; border-right-width: 3px; border-bottom-width: 3px; border-left-width: 3px; background-color: rgb(89, 89, 89);" />
|
||||
<ui:Label display-tooltip-when-elided="true" name="SchemaUserGuide" style="-unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px; height: 40px;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Name" name="ScannerName" />
|
||||
<ui:TextField picking-mode="Ignore" label="Scanner Desc" name="ScannerDesc" />
|
||||
<uie:ObjectField label="Scanner Schema" name="ScanSchema" type="YooAsset.Editor.ScannerSchema, YooAsset.Editor" allow-scene-objects="false" />
|
||||
<uie:ObjectField label="Output Folder" name="OutputFolder" type="UnityEditor.DefaultAsset, UnityEditor.CoreModule" allow-scene-objects="false" />
|
||||
<ui:VisualElement name="CollectorAddContainer" style="height: 20px; flex-direction: row-reverse;">
|
||||
<ui:Button text="[ + ]" display-tooltip-when-elided="true" name="AddBtn" />
|
||||
<ui:Button text="Scan" display-tooltip-when-elided="true" name="ScanBtn" style="width: 60px;" />
|
||||
</ui:VisualElement>
|
||||
<ui:ScrollView name="CollectorScrollView" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
<ui:VisualElement name="InspectorContainer" style="flex-grow: 1; border-top-width: 5px; border-right-width: 5px; border-bottom-width: 5px; border-left-width: 5px; background-color: rgb(67, 67, 67);" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5bbb873a7bee2924a86c876b67bb2cb4
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
26
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs
Normal file
26
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerDefine
|
||||
{
|
||||
/// <summary>
|
||||
/// 报告文件签名
|
||||
/// </summary>
|
||||
public const string ReportFileSign = "596f6f4172745265706f7274";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件签名
|
||||
/// </summary>
|
||||
public const string SettingFileSign = "596f6f41727453657474696e67";
|
||||
|
||||
/// <summary>
|
||||
/// 报告文件的版本
|
||||
/// </summary>
|
||||
public const string ReportFileVersion = "1.0";
|
||||
|
||||
/// <summary>
|
||||
/// 配置文件的版本
|
||||
/// </summary>
|
||||
public const string SettingFileVersion = "1.0";
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerDefine.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed658bfc32cbfc44caf262a741a7c387
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
65
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs
Normal file
65
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成的报告文件路径
|
||||
/// </summary>
|
||||
public string ReprotFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告对象
|
||||
/// </summary>
|
||||
public ScanReport Report { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误信息
|
||||
/// </summary>
|
||||
public string ErrorInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误堆栈
|
||||
/// </summary>
|
||||
public string ErrorStack { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
public bool Succeed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(ErrorInfo))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ScannerResult(string error, string stack)
|
||||
{
|
||||
ErrorInfo = error;
|
||||
ErrorStack = stack;
|
||||
}
|
||||
public ScannerResult(string filePath, ScanReport report)
|
||||
{
|
||||
ReprotFilePath = filePath;
|
||||
Report = report;
|
||||
ErrorInfo = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 打开报告窗口
|
||||
/// </summary>
|
||||
public void OpenReportWindow()
|
||||
{
|
||||
if (Succeed)
|
||||
{
|
||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||
reproterWindow.ImportSingleReprotFile(Report);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerResult.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e10cdab189d80b142ad5903d12956c59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs
Normal file
32
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public abstract class ScannerSchema : ScriptableObject
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户指南信息
|
||||
/// </summary>
|
||||
public abstract string GetUserGuide();
|
||||
|
||||
/// <summary>
|
||||
/// 运行生成扫描报告
|
||||
/// </summary>
|
||||
public abstract ScanReport RunScanner(AssetArtScanner scanner);
|
||||
|
||||
/// <summary>
|
||||
/// 修复扫描结果
|
||||
/// </summary>
|
||||
public abstract void FixResult(List<ReportElement> fixList);
|
||||
|
||||
/// <summary>
|
||||
/// 创建检视面板
|
||||
/// </summary>
|
||||
public virtual SchemaInspector CreateInspector()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
11
Assets/YooAsset/Editor/AssetArtScanner/ScannerSchema.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eb6a587c72ccecc4ab6d386063cf0736
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
Assets/YooAsset/Editor/AssetArtScanner/SchemaInspector.cs
Normal file
45
Assets/YooAsset/Editor/AssetArtScanner/SchemaInspector.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class SchemaInspector
|
||||
{
|
||||
/// <summary>
|
||||
/// 检视界面的UI元素容器(UIElements元素)
|
||||
/// </summary>
|
||||
public object Containner { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面宽度
|
||||
/// </summary>
|
||||
public int Width = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最小宽度
|
||||
/// </summary>
|
||||
public int MinWidth = 250;
|
||||
|
||||
/// <summary>
|
||||
/// 检视界面最大宽度
|
||||
/// </summary>
|
||||
public int MaxWidth = 250;
|
||||
|
||||
public SchemaInspector(object containner)
|
||||
{
|
||||
Containner = containner;
|
||||
}
|
||||
public SchemaInspector(object containner, int width)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = width;
|
||||
MaxWidth = width;
|
||||
}
|
||||
public SchemaInspector(object containner, int width, int minWidth, int maxWidth)
|
||||
{
|
||||
Containner = containner;
|
||||
Width = width;
|
||||
MinWidth = minWidth;
|
||||
MaxWidth = maxWidth;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3440549fcb36bbf4c8c6da17fb858947
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -32,11 +32,12 @@ namespace YooAsset.Editor
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
|
||||
// 初始化日志
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
// 初始化日志系统
|
||||
string logFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/buildInfo.log";
|
||||
BuildLogger.InitLogger(enableLog, logFilePath);
|
||||
|
||||
// 执行构建流程
|
||||
Debug.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
var buildResult = BuildRunner.Run(buildPipeline, _buildContext);
|
||||
if (buildResult.Success)
|
||||
{
|
||||
@@ -50,6 +51,9 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
|
||||
// 关闭日志系统
|
||||
BuildLogger.Shuntdown();
|
||||
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public static string GetStreamingAssetsRoot()
|
||||
{
|
||||
return YooAssetSettingsData.GetYooEditorBuildinRoot();
|
||||
return YooAssetSettingsData.GetYooDefaultBuildinRoot();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,97 +6,122 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public static class AssetBundleBuilderSetting
|
||||
{
|
||||
// EBuildPipeline
|
||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
||||
// BuildPipelineName
|
||||
public static string GetPackageBuildPipeline(string packageName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
||||
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||
string defaultValue = EBuildPipeline.ScriptableBuildPipeline.ToString();
|
||||
return EditorPrefs.GetString(key, defaultValue);
|
||||
}
|
||||
public static void SetPackageBuildPipeline(string packageName, EBuildPipeline buildPipeline)
|
||||
public static void SetPackageBuildPipeline(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
||||
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||
EditorPrefs.SetString(key, buildPipeline);
|
||||
}
|
||||
|
||||
// ECompressOption
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, EBuildPipeline buildPipeline)
|
||||
public static ECompressOption GetPackageCompressOption(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
||||
}
|
||||
public static void SetPackageCompressOption(string packageName, EBuildPipeline buildPipeline, ECompressOption compressOption)
|
||||
public static void SetPackageCompressOption(string packageName, string buildPipeline, ECompressOption compressOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||
EditorPrefs.SetInt(key, (int)compressOption);
|
||||
}
|
||||
|
||||
// EFileNameStyle
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline)
|
||||
public static EFileNameStyle GetPackageFileNameStyle(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
||||
}
|
||||
public static void SetPackageFileNameStyle(string packageName, EBuildPipeline buildPipeline, EFileNameStyle fileNameStyle)
|
||||
public static void SetPackageFileNameStyle(string packageName, string buildPipeline, EFileNameStyle fileNameStyle)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||
}
|
||||
|
||||
// EBuildinFileCopyOption
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline)
|
||||
public static EBuildinFileCopyOption GetPackageBuildinFileCopyOption(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, EBuildPipeline buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
public static void SetPackageBuildinFileCopyOption(string packageName, string buildPipeline, EBuildinFileCopyOption buildinFileCopyOption)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||
}
|
||||
|
||||
// BuildFileCopyParams
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
||||
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
}
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline, string buildinFileCopyParams)
|
||||
public static void SetPackageBuildinFileCopyParams(string packageName, string buildPipeline, string buildinFileCopyParams)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||
}
|
||||
|
||||
// EncyptionClassName
|
||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
||||
// EncyptionServicesClassName
|
||||
public static string GetPackageEncyptionServicesClassName(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
return EditorPrefs.GetString(key, string.Empty);
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||
return EditorPrefs.GetString(key, $"{typeof(EncryptionNone).FullName}");
|
||||
}
|
||||
public static void SetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline, string encyptionClassName)
|
||||
public static void SetPackageEncyptionServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ManifestProcessServicesClassName
|
||||
public static string GetPackageManifestProcessServicesClassName(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
|
||||
return EditorPrefs.GetString(key, $"{typeof(ManifestProcessNone).FullName}");
|
||||
}
|
||||
public static void SetPackageManifestProcessServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestProcessServicesClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ManifestRestoreServicesClassName
|
||||
public static string GetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
|
||||
return EditorPrefs.GetString(key, $"{typeof(ManifestRestoreNone).FullName}");
|
||||
}
|
||||
public static void SetPackageManifestRestoreServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestRestoreServicesClassName";
|
||||
EditorPrefs.SetString(key, encyptionClassName);
|
||||
}
|
||||
|
||||
// ClearBuildCache
|
||||
public static bool GetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline)
|
||||
public static bool GetPackageClearBuildCache(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline, bool clearBuildCache)
|
||||
public static void SetPackageClearBuildCache(string packageName, string 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)
|
||||
public static bool GetPackageUseAssetDependencyDB(string packageName, string buildPipeline)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
return EditorPrefs.GetInt(key, 0) > 0;
|
||||
}
|
||||
public static void SetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline, bool useAssetDependencyDB)
|
||||
public static void SetPackageUseAssetDependencyDB(string packageName, string buildPipeline, bool useAssetDependencyDB)
|
||||
{
|
||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
private string _buildPackage;
|
||||
private EBuildPipeline _buildPipeline;
|
||||
private string _buildPipeline;
|
||||
|
||||
private Dictionary<string, Type> _viewClassDic = new Dictionary<string, Type>(10);
|
||||
|
||||
private Toolbar _toolbar;
|
||||
private ToolbarMenu _packageMenu;
|
||||
@@ -69,11 +71,29 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_pipelineMenu = new ToolbarMenu();
|
||||
_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.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
||||
_toolbar.Add(_pipelineMenu);
|
||||
|
||||
var viewerClassTypes = EditorTools.GetAssignableTypes(typeof(BuildPipelineViewerBase));
|
||||
foreach (var classType in viewerClassTypes)
|
||||
{
|
||||
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
||||
if (buildPipelineAttribute == null)
|
||||
{
|
||||
Debug.LogWarning($"The class {classType.FullName} need attribute {nameof(BuildPipelineAttribute)}");
|
||||
continue;
|
||||
}
|
||||
|
||||
string pipelineName = buildPipelineAttribute.PipelineName;
|
||||
if (_viewClassDic.ContainsKey(pipelineName))
|
||||
{
|
||||
Debug.LogWarning($"The pipeline has already exist : {pipelineName}");
|
||||
}
|
||||
else
|
||||
{
|
||||
_viewClassDic.Add(pipelineName, classType);
|
||||
_pipelineMenu.menu.AppendAction(pipelineName, PipelineMenuAction, PipelineMenuFun);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RefreshBuildPipelineView();
|
||||
@@ -91,28 +111,18 @@ namespace YooAsset.Editor
|
||||
|
||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||
_packageMenu.text = _buildPackage;
|
||||
_pipelineMenu.text = _buildPipeline.ToString();
|
||||
_pipelineMenu.text = _buildPipeline;
|
||||
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
||||
if (_viewClassDic.TryGetValue(_buildPipeline, out Type value))
|
||||
{
|
||||
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
||||
{
|
||||
var viewer = new BuiltinBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.ScriptableBuildPipeline)
|
||||
{
|
||||
var viewer = new ScriptableBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
||||
}
|
||||
else if (_buildPipeline == EBuildPipeline.RawFileBuildPipeline)
|
||||
{
|
||||
var viewer = new RawfileBuildpipelineViewer(_buildPackage, buildTarget, _container);
|
||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||
var viewer = Activator.CreateInstance(value) as BuildPipelineViewerBase;
|
||||
viewer.InitView(_buildPackage, _buildPipeline, buildTarget);
|
||||
viewer.CreateView(_container);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
||||
Debug.LogError($"Not found build pipeline : {_buildPipeline}");
|
||||
}
|
||||
}
|
||||
private List<string> GetBuildPackageNames()
|
||||
@@ -145,18 +155,16 @@ namespace YooAsset.Editor
|
||||
|
||||
private void PipelineMenuAction(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline != pipelineType)
|
||||
if (_buildPipeline != action.name)
|
||||
{
|
||||
_buildPipeline = pipelineType;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
||||
_buildPipeline = action.name;
|
||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, _buildPipeline);
|
||||
RefreshBuildPipelineView();
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||
{
|
||||
var pipelineType = (EBuildPipeline)action.userData;
|
||||
if (_buildPipeline == pipelineType)
|
||||
if (_buildPipeline == action.name)
|
||||
return DropdownMenuAction.Status.Checked;
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
|
||||
@@ -26,6 +26,7 @@ namespace YooAsset.Editor
|
||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||
buildParameters.UseAssetDependencyDB = true;
|
||||
|
||||
var pipeline = new EditorSimulateBuildPipeline();
|
||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
/// </summary>
|
||||
public string PackageFileCRC { set; get; }
|
||||
public uint PackageFileCRC { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 文件哈希值
|
||||
@@ -56,13 +56,13 @@ namespace YooAsset.Editor
|
||||
public string EncryptedFilePath { set; get; }
|
||||
#endregion
|
||||
|
||||
private readonly HashSet<string> _assetPaths = new HashSet<string>();
|
||||
private readonly Dictionary<string, BuildAssetInfo> _packAssetDic = new Dictionary<string, BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源列表
|
||||
/// 注意:不包含零依赖资源和冗余资源
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> MainAssets = new List<BuildAssetInfo>();
|
||||
public readonly List<BuildAssetInfo> AllPackAssets = new List<BuildAssetInfo>(100);
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名称
|
||||
@@ -86,51 +86,68 @@ namespace YooAsset.Editor
|
||||
public void PackAsset(BuildAssetInfo buildAsset)
|
||||
{
|
||||
string assetPath = buildAsset.AssetInfo.AssetPath;
|
||||
if (_assetPaths.Contains(assetPath))
|
||||
if (_packAssetDic.ContainsKey(assetPath))
|
||||
throw new System.Exception($"Should never get here ! Asset is existed : {assetPath}");
|
||||
|
||||
_assetPaths.Add(assetPath);
|
||||
MainAssets.Add(buildAsset);
|
||||
_packAssetDic.Add(assetPath, buildAsset);
|
||||
AllPackAssets.Add(buildAsset);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含指定资源
|
||||
/// </summary>
|
||||
public bool IsContainsAsset(string assetPath)
|
||||
public bool IsContainsPackAsset(string assetPath)
|
||||
{
|
||||
return _assetPaths.Contains(assetPath);
|
||||
return _packAssetDic.ContainsKey(assetPath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源路径列表
|
||||
/// </summary>
|
||||
public string[] GetAllMainAssetPaths()
|
||||
public string[] GetAllPackAssetPaths()
|
||||
{
|
||||
return MainAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源(包括零依赖资源和冗余资源)
|
||||
/// 获取构建的主资源信息
|
||||
/// </summary>
|
||||
public List<string> GetAllBuiltinAssetPaths()
|
||||
public BuildAssetInfo GetPackAssetInfo(string assetPath)
|
||||
{
|
||||
var packAssets = GetAllMainAssetPaths();
|
||||
List<string> result = new List<string>(packAssets);
|
||||
foreach (var buildAsset in MainAssets)
|
||||
if (_packAssetDic.TryGetValue(assetPath, out BuildAssetInfo value))
|
||||
{
|
||||
if (buildAsset.AllDependAssetInfos == null)
|
||||
continue;
|
||||
foreach (var dependAssetInfo in buildAsset.AllDependAssetInfos)
|
||||
return value;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Can not found pack asset info {assetPath} in bundle : {BundleName}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包内部所有资产
|
||||
/// </summary>
|
||||
public List<AssetInfo> GetBundleContents()
|
||||
{
|
||||
Dictionary<string, AssetInfo> result = new Dictionary<string, AssetInfo>(AllPackAssets.Count);
|
||||
foreach (var packAsset in AllPackAssets)
|
||||
{
|
||||
result.Add(packAsset.AssetInfo.AssetPath, packAsset.AssetInfo);
|
||||
if (packAsset.AllDependAssetInfos != null)
|
||||
{
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
foreach (var dependAssetInfo in packAsset.AllDependAssetInfos)
|
||||
{
|
||||
if (result.Contains(dependAssetInfo.AssetInfo.AssetPath) == false)
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
// 注意:依赖资源里只添加零依赖资源和冗余资源
|
||||
if (dependAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
string dependAssetPath = dependAssetInfo.AssetInfo.AssetPath;
|
||||
if (result.ContainsKey(dependAssetPath) == false)
|
||||
result.Add(dependAssetPath, dependAssetInfo.AssetInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return result.Values.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -142,7 +159,7 @@ namespace YooAsset.Editor
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllMainAssetPaths();
|
||||
build.assetNames = GetAllPackAssetPaths();
|
||||
return build;
|
||||
}
|
||||
|
||||
@@ -151,7 +168,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public BuildAssetInfo[] GetAllManifestAssetInfos()
|
||||
{
|
||||
return MainAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
return AllPackAssets.Where(t => t.CollectorType == ECollectorType.MainAssetCollector).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -13,11 +13,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private readonly Dictionary<string, BuildBundleInfo> _bundleInfoDic = new Dictionary<string, BuildBundleInfo>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 图集资源集合
|
||||
/// </summary>
|
||||
public readonly List<BuildAssetInfo> SpriteAtlasAssetList = new List<BuildAssetInfo>(10000);
|
||||
|
||||
/// <summary>
|
||||
/// 未被依赖的资源列表
|
||||
/// </summary>
|
||||
public readonly List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>(1000);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参与构建的资源总数
|
||||
/// 说明:包括主动收集的资源以及其依赖的所有资源
|
||||
@@ -60,6 +65,12 @@ namespace YooAsset.Editor
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
|
||||
// 统计所有的精灵图集
|
||||
if (assetInfo.AssetInfo.IsSpriteAtlas())
|
||||
{
|
||||
SpriteAtlasAssetList.Add(assetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -96,14 +107,14 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建着色器信息类
|
||||
/// 创建空的资源包
|
||||
/// </summary>
|
||||
public void CreateShadersBundleInfo(string shadersBundleName)
|
||||
public void CreateEmptyBundleInfo(string bundleName)
|
||||
{
|
||||
if (IsContainsBundle(shadersBundleName) == false)
|
||||
if (IsContainsBundle(bundleName) == false)
|
||||
{
|
||||
var shaderBundleInfo = new BuildBundleInfo(shadersBundleName);
|
||||
_bundleInfoDic.Add(shadersBundleName, shaderBundleInfo);
|
||||
var bundleInfo = new BuildBundleInfo(bundleName);
|
||||
_bundleInfoDic.Add(bundleName, bundleInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace YooAsset.Editor
|
||||
|
||||
/// <summary>
|
||||
/// 使用资源依赖缓存数据库
|
||||
/// 说明:开启此项可以极大提高资源收集速度
|
||||
/// 说明:开启此项可以极大提高资源收集速度!
|
||||
/// </summary>
|
||||
public bool UseAssetDependencyDB = false;
|
||||
|
||||
@@ -67,6 +67,12 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableSharePackRule = false;
|
||||
|
||||
/// <summary>
|
||||
/// 对单独引用的共享资源进行独立打包
|
||||
/// 说明:关闭该选项单独引用的共享资源将会构建到引用它的资源包内!
|
||||
/// </summary>
|
||||
public bool SingleReferencedPackAlone = true;
|
||||
|
||||
/// <summary>
|
||||
/// 验证构建结果
|
||||
/// </summary>
|
||||
@@ -92,6 +98,15 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public IEncryptionServices EncryptionServices;
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单加密服务类
|
||||
/// </summary>
|
||||
public IManifestProcessServices ManifestProcessServices;
|
||||
|
||||
/// <summary>
|
||||
/// 资源清单解密服务类
|
||||
/// </summary>
|
||||
public IManifestRestoreServices ManifestRestoreServices;
|
||||
|
||||
private string _pipelineOutputDirectory = string.Empty;
|
||||
private string _packageOutputDirectory = string.Empty;
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateCatalog
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成内置资源记录文件
|
||||
/// </summary>
|
||||
internal void CreateCatalogFile(BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string buildinRootDirectory = buildParametersContext.GetBuildinRootDirectory();
|
||||
string buildPackageName = buildParametersContext.Parameters.PackageName;
|
||||
var manifestServices = buildParametersContext.Parameters.ManifestRestoreServices;
|
||||
CatalogTools.CreateCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||
|
||||
// 刷新目录
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d2c835e5e40ca34d93480587c8125df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -30,8 +31,9 @@ namespace YooAsset.Editor
|
||||
|
||||
// 创建新补丁清单
|
||||
PackageManifest manifest = new PackageManifest();
|
||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
||||
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
manifest.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
@@ -43,18 +45,22 @@ namespace YooAsset.Editor
|
||||
manifest.AssetList = CreatePackageAssetList(buildMapContext);
|
||||
manifest.BundleList = CreatePackageBundleList(buildMapContext);
|
||||
|
||||
// 处理资源清单的ID数据
|
||||
ProcessPacakgeIDs(manifest);
|
||||
// 1. 处理资源清单的资源对象
|
||||
ProcessPacakgeAsset(manifest);
|
||||
|
||||
// 处理资源包的依赖列表
|
||||
// 2. 处理资源包的依赖列表
|
||||
if (processBundleDepends)
|
||||
ProcessBundleDepends(context, manifest);
|
||||
|
||||
// 处理资源包的标签集合
|
||||
// 3. 处理资源包的标签集合
|
||||
if (processBundleTags)
|
||||
ProcessBundleTags(manifest);
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
// 4. 处理内置资源包
|
||||
if (processBundleDepends)
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
|
||||
// 创建资源清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -62,22 +68,18 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
// 创建资源清单二进制文件
|
||||
string packageHash;
|
||||
string packagePath;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(filePath, manifest);
|
||||
packageHash = HashUtility.FileCRC32(filePath);
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(filePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
context.SetContextObject(manifestContext);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestProcessServices);
|
||||
packageHash = HashUtility.FileCRC32(packagePath);
|
||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单哈希文件
|
||||
// 创建资源清单哈希文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -85,13 +87,21 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单版本文件
|
||||
// 创建资源清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
FileUtility.WriteAllText(filePath, buildParameters.PackageVersion);
|
||||
BuildLogger.Log($"Create package manifest version file: {filePath}");
|
||||
}
|
||||
|
||||
// 填充上下文
|
||||
{
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,7 +147,7 @@ namespace YooAsset.Editor
|
||||
packageAsset.AssetPath = assetInfo.AssetInfo.AssetPath;
|
||||
packageAsset.AssetGUID = buildMapContext.Command.IncludeAssetGUID ? assetInfo.AssetInfo.AssetGUID : string.Empty;
|
||||
packageAsset.AssetTags = assetInfo.AssetTags.ToArray();
|
||||
packageAsset.BundleNameInEditor = assetInfo.BundleName;
|
||||
packageAsset.TempDataInEditor = assetInfo;
|
||||
result.Add(packageAsset);
|
||||
}
|
||||
}
|
||||
@@ -165,9 +175,9 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 处理资源清单的ID数据
|
||||
/// 处理资源清单的资源对象列表
|
||||
/// </summary>
|
||||
private void ProcessPacakgeIDs(PackageManifest manifest)
|
||||
private void ProcessPacakgeAsset(PackageManifest manifest)
|
||||
{
|
||||
// 注意:优先缓存资源包索引
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
@@ -176,10 +186,19 @@ namespace YooAsset.Editor
|
||||
_cachedBundleIndexIDs.Add(bundleName, index);
|
||||
}
|
||||
|
||||
// 记录资源对象所属的资源包ID
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
string bundleName = packageAsset.BundleNameInEditor;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(bundleName);
|
||||
var assetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.BundleID = GetCachedBundleIndexID(assetInfo.BundleName);
|
||||
}
|
||||
|
||||
// 记录资源对象依赖的资源包ID集合
|
||||
// 注意:依赖关系非引擎构建结果里查询!
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var mainAssetInfo = packageAsset.TempDataInEditor as BuildAssetInfo;
|
||||
packageAsset.DependBundleIDs = GetAssetDependBundleIDs(mainAssetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,15 +211,18 @@ namespace YooAsset.Editor
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
int mainBundleID = GetCachedBundleIndexID(packageBundle.BundleName);
|
||||
var depends = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(depends.Length);
|
||||
foreach (var dependBundleName in depends)
|
||||
string[] dependNames = GetBundleDepends(context, packageBundle.BundleName);
|
||||
List<int> dependIDs = new List<int>(dependNames.Length);
|
||||
foreach (var dependName in dependNames)
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependBundleName);
|
||||
if (bundleID != mainBundleID)
|
||||
dependIDs.Add(bundleID);
|
||||
int dependBundleID = GetCachedBundleIndexID(dependName);
|
||||
if (dependBundleID != mainBundleID)
|
||||
dependIDs.Add(dependBundleID);
|
||||
}
|
||||
packageBundle.DependIDs = dependIDs.ToArray();
|
||||
|
||||
// 排序并填充数据
|
||||
dependIDs.Sort();
|
||||
packageBundle.DependBundleIDs = dependIDs.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -209,23 +231,27 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
private void ProcessBundleTags(PackageManifest manifest)
|
||||
{
|
||||
foreach (var packageBundle in manifest.BundleList)
|
||||
{
|
||||
packageBundle.Tags = Array.Empty<string>();
|
||||
}
|
||||
|
||||
// 将主资源的标签信息传染给其依赖的资源包集合
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
var assetTags = packageAsset.AssetTags;
|
||||
int bundleID = packageAsset.BundleID;
|
||||
CacheBundleTags(bundleID, assetTags);
|
||||
|
||||
var packageBundle = manifest.BundleList[bundleID];
|
||||
if (packageBundle.DependIDs != null)
|
||||
if (packageAsset.DependBundleIDs != null)
|
||||
{
|
||||
foreach (var dependBundleID in packageBundle.DependIDs)
|
||||
foreach (var dependBundleID in packageAsset.DependBundleIDs)
|
||||
{
|
||||
CacheBundleTags(dependBundleID, assetTags);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 将缓存的资源标签赋值给资源包
|
||||
for (int index = 0; index < manifest.BundleList.Count; index++)
|
||||
{
|
||||
var packageBundle = manifest.BundleList[index];
|
||||
@@ -264,5 +290,116 @@ namespace YooAsset.Editor
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否包含该资源包的索引ID
|
||||
/// </summary>
|
||||
private bool ContainsCachedBundleIndexID(string bundleName)
|
||||
{
|
||||
return _cachedBundleIndexIDs.ContainsKey(bundleName);
|
||||
}
|
||||
|
||||
#region YOOASSET_LEGACY_DEPENDENCY
|
||||
private void ProcessBuiltinBundleDependency(BuildContext context, PackageManifest manifest)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
ManifestTools.InitManifest(manifest);
|
||||
|
||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||
// 注意:该步骤依赖前面的操作!
|
||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
|
||||
if (buildResultContext != null)
|
||||
{
|
||||
ProcessBuiltinBundleReference(manifest, buildResultContext.BuiltinShadersBundleName);
|
||||
ProcessBuiltinBundleReference(manifest, buildResultContext.MonoScriptsBundleName);
|
||||
|
||||
var buildParametersContext = context.TryGetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
if (buildParameters is ScriptableBuildParameters scriptableBuildParameters)
|
||||
{
|
||||
if (scriptableBuildParameters.TrackSpriteAtlasDependencies)
|
||||
{
|
||||
// 注意:检测是否开启图集模式
|
||||
// 说明:需要记录主资源对象对图集的依赖关系!
|
||||
if (EditorSettings.spritePackerMode != SpritePackerMode.Disabled)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
foreach (var spriteAtlasAsset in buildMapContext.SpriteAtlasAssetList)
|
||||
{
|
||||
string spriteAtlasBundleName = spriteAtlasAsset.BundleName;
|
||||
ProcessBuiltinBundleReference(manifest, spriteAtlasBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void ProcessBuiltinBundleReference(PackageManifest manifest, string builtinBundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(builtinBundleName))
|
||||
return;
|
||||
|
||||
// 查询内置资源包是否存在
|
||||
if (ContainsCachedBundleIndexID(builtinBundleName) == false)
|
||||
return;
|
||||
|
||||
// 获取内置资源包
|
||||
int builtinBundleID = GetCachedBundleIndexID(builtinBundleName);
|
||||
var builtinPackageBundle = manifest.BundleList[builtinBundleID];
|
||||
|
||||
// 更新依赖资源包ID集合
|
||||
HashSet<int> cacheBundleIDs = new HashSet<int>(builtinPackageBundle.ReferenceBundleIDs);
|
||||
HashSet<string> tempTags = new HashSet<string>();
|
||||
foreach (var packageAsset in manifest.AssetList)
|
||||
{
|
||||
if (cacheBundleIDs.Contains(packageAsset.BundleID))
|
||||
{
|
||||
if (packageAsset.DependBundleIDs.Contains(builtinBundleID) == false)
|
||||
{
|
||||
var tempBundleIDs = new List<int>(packageAsset.DependBundleIDs);
|
||||
tempBundleIDs.Add(builtinBundleID);
|
||||
packageAsset.DependBundleIDs = tempBundleIDs.ToArray();
|
||||
}
|
||||
|
||||
foreach (var tag in packageAsset.AssetTags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 更新内置资源包的标签集合
|
||||
foreach (var tag in builtinPackageBundle.Tags)
|
||||
{
|
||||
if (tempTags.Contains(tag) == false)
|
||||
tempTags.Add(tag);
|
||||
}
|
||||
builtinPackageBundle.Tags = tempTags.ToArray();
|
||||
}
|
||||
private int[] GetAssetDependBundleIDs(BuildAssetInfo mainAssetInfo)
|
||||
{
|
||||
HashSet<int> result = new HashSet<int>();
|
||||
int mainBundleID = GetCachedBundleIndexID(mainAssetInfo.BundleName);
|
||||
foreach (var dependAssetInfo in mainAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
if (dependAssetInfo.HasBundleName())
|
||||
{
|
||||
int bundleID = GetCachedBundleIndexID(dependAssetInfo.BundleName);
|
||||
if (mainBundleID != bundleID)
|
||||
{
|
||||
if (result.Contains(bundleID) == false)
|
||||
result.Add(bundleID);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 排序并返回数据
|
||||
List<int> listResult = new List<int>(result);
|
||||
listResult.Sort();
|
||||
return listResult.ToArray();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -18,11 +18,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 概述信息
|
||||
{
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
UnityEditor.PackageManager.PackageInfo packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssembly(typeof(BuildReport).Assembly);
|
||||
if (packageInfo != null)
|
||||
buildReport.Summary.YooVersion = packageInfo.version;
|
||||
#endif
|
||||
buildReport.Summary.YooVersion = EditorTools.GetPackageManagerYooVersion();
|
||||
buildReport.Summary.UnityVersion = UnityEngine.Application.unityVersion;
|
||||
buildReport.Summary.BuildDate = DateTime.Now.ToString();
|
||||
buildReport.Summary.BuildSeconds = BuildRunner.TotalSeconds;
|
||||
@@ -36,38 +32,40 @@ namespace YooAsset.Editor
|
||||
// 收集器配置
|
||||
buildReport.Summary.UniqueBundleName = buildMapContext.Command.UniqueBundleName;
|
||||
buildReport.Summary.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||
buildReport.Summary.SupportExtensionless = buildMapContext.Command.SupportExtensionless;
|
||||
buildReport.Summary.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||
buildReport.Summary.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.GetType().FullName;
|
||||
buildReport.Summary.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
buildReport.Summary.IgnoreRuleName = buildMapContext.Command.IgnoreRule.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))
|
||||
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.EncryptionServicesClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
buildReport.Summary.ManifestProcessServicesClassName = buildParameters.ManifestProcessServices == null ? "null" : buildParameters.ManifestProcessServices.GetType().FullName;
|
||||
buildReport.Summary.ManifestRestoreServicesClassName = buildParameters.ManifestRestoreServices == null ? "null" : buildParameters.ManifestRestoreServices.GetType().FullName;
|
||||
|
||||
if (buildParameters is BuiltinBuildParameters)
|
||||
{
|
||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else if (buildParameters.BuildPipeline == nameof(ScriptableBuildPipeline))
|
||||
else if (buildParameters is ScriptableBuildParameters)
|
||||
{
|
||||
var scriptableBuildParameters = buildParameters as ScriptableBuildParameters;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
}
|
||||
else
|
||||
{
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.CompressOption = ECompressOption.Uncompressed;
|
||||
buildReport.Summary.DisableWriteTypeTree = false;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = false;
|
||||
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||
buildReport.Summary.BuiltinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
|
||||
buildReport.Summary.MonoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
|
||||
}
|
||||
|
||||
// 构建结果
|
||||
@@ -91,7 +89,8 @@ namespace YooAsset.Editor
|
||||
reportAssetInfo.AssetGUID = AssetDatabase.AssetPathToGUID(packageAsset.AssetPath);
|
||||
reportAssetInfo.MainBundleName = mainBundle.BundleName;
|
||||
reportAssetInfo.MainBundleSize = mainBundle.FileSize;
|
||||
reportAssetInfo.DependAssets = GetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||
reportAssetInfo.DependAssets = GetAssetDependAssets(buildMapContext, mainBundle.BundleName, packageAsset.AssetPath);
|
||||
reportAssetInfo.DependBundles = GetAssetDependBundles(manifest, packageAsset);
|
||||
buildReport.AssetInfos.Add(reportAssetInfo);
|
||||
}
|
||||
|
||||
@@ -107,8 +106,9 @@ namespace YooAsset.Editor
|
||||
reportBundleInfo.FileSize = packageBundle.FileSize;
|
||||
reportBundleInfo.Encrypted = packageBundle.Encrypted;
|
||||
reportBundleInfo.Tags = packageBundle.Tags;
|
||||
reportBundleInfo.DependBundles = GetDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.AllBuiltinAssets = GetAllBuiltinAssets(buildMapContext, packageBundle.BundleName);
|
||||
reportBundleInfo.DependBundles = GetBundleDependBundles(manifest, packageBundle);
|
||||
reportBundleInfo.ReferenceBundles = GetBundleReferenceBundles(manifest, packageBundle);
|
||||
reportBundleInfo.BundleContents = GetBundleContents(buildMapContext, packageBundle.BundleName);
|
||||
buildReport.BundleInfos.Add(reportBundleInfo);
|
||||
}
|
||||
|
||||
@@ -123,12 +123,28 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的所有资源包
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// </summary>
|
||||
private List<string> GetDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
private List<AssetInfo> GetAssetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependIDs.Length);
|
||||
foreach (int index in packageBundle.DependIDs)
|
||||
List<AssetInfo> result = new List<AssetInfo>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
var assetInfo = bundleInfo.GetPackAssetInfo(assetPath);
|
||||
foreach (var dependAssetInfo in assetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetInfo);
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetAssetDependBundles(PackageManifest manifest, PackageAsset packageAsset)
|
||||
{
|
||||
List<string> dependBundles = new List<string>(packageAsset.DependBundleIDs.Length);
|
||||
foreach (int index in packageAsset.DependBundleIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
@@ -138,42 +154,42 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源对象依赖的其它所有资源
|
||||
/// 获取资源包依赖的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetDependAssets(BuildMapContext buildMapContext, string bundleName, string assetPath)
|
||||
private List<string> GetBundleDependBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> result = new List<string>();
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> dependBundles = new List<string>(packageBundle.DependBundleIDs.Length);
|
||||
foreach (int index in packageBundle.DependBundleIDs)
|
||||
{
|
||||
BuildAssetInfo findAssetInfo = null;
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
{
|
||||
if (buildAsset.AssetInfo.AssetPath == assetPath)
|
||||
{
|
||||
findAssetInfo = buildAsset;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (findAssetInfo == null)
|
||||
{
|
||||
throw new Exception($"Should never get here ! Not found asset {assetPath} in bunlde {bundleName}");
|
||||
}
|
||||
foreach (var dependAssetInfo in findAssetInfo.AllDependAssetInfos)
|
||||
{
|
||||
result.Add(dependAssetInfo.AssetInfo.AssetPath);
|
||||
}
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
dependBundles.Add(dependBundleName);
|
||||
}
|
||||
result.Sort();
|
||||
return result;
|
||||
dependBundles.Sort();
|
||||
return dependBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取该资源包内的所有资源
|
||||
/// 获取引用该资源包的资源包集合
|
||||
/// </summary>
|
||||
private List<string> GetAllBuiltinAssets(BuildMapContext buildMapContext, string bundleName)
|
||||
private List<string> GetBundleReferenceBundles(PackageManifest manifest, PackageBundle packageBundle)
|
||||
{
|
||||
List<string> referenceBundles = new List<string>(packageBundle.ReferenceBundleIDs.Count);
|
||||
foreach (int index in packageBundle.ReferenceBundleIDs)
|
||||
{
|
||||
string dependBundleName = manifest.BundleList[index].BundleName;
|
||||
referenceBundles.Add(dependBundleName);
|
||||
}
|
||||
referenceBundles.Sort();
|
||||
return referenceBundles;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取资源包内部所有资产
|
||||
/// </summary>
|
||||
private List<AssetInfo> GetBundleContents(BuildMapContext buildMapContext, string bundleName)
|
||||
{
|
||||
var bundleInfo = buildMapContext.GetBundleInfo(bundleName);
|
||||
List<string> result = bundleInfo.GetAllBuiltinAssetPaths();
|
||||
List<AssetInfo> result = bundleInfo.GetBundleContents();
|
||||
result.Sort();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 1. 获取所有收集器收集的资源
|
||||
bool useAssetDependencyDB = buildParameters.UseAssetDependencyDB;
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.GetPackageAssets(simulateBuild, useAssetDependencyDB, packageName);
|
||||
var collectResult = AssetBundleCollectorSettingData.Setting.BeginCollect(packageName, simulateBuild, useAssetDependencyDB);
|
||||
List<CollectAssetInfo> allCollectAssets = collectResult.CollectAssets;
|
||||
|
||||
// 2. 剔除未被引用的依赖项资源
|
||||
@@ -109,15 +109,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
if (buildAssetInfo.HasBundleName() == false)
|
||||
{
|
||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||
if (packRuleResult.IsValid())
|
||||
{
|
||||
string shareBundleName = packRuleResult.GetShareBundleName(collectResult.Command.PackageName, collectResult.Command.UniqueBundleName);
|
||||
buildAssetInfo.SetBundleName(shareBundleName);
|
||||
}
|
||||
ProcessingPackShareBundle(buildParameters, collectResult.Command, buildAssetInfo);
|
||||
}
|
||||
}
|
||||
PostProcessPackShareBundle();
|
||||
PostProcessPackShareBundle(buildParameters, collectResult.Command, allBuildAssetInfos);
|
||||
}
|
||||
|
||||
// 8. 记录关键信息
|
||||
@@ -209,21 +204,38 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 共享资源打包后置处理
|
||||
/// 共享资源打包机制
|
||||
/// </summary>
|
||||
protected virtual void PostProcessPackShareBundle()
|
||||
protected virtual void ProcessingPackShareBundle(BuildParameters buildParameters, CollectCommand command, BuildAssetInfo buildAssetInfo)
|
||||
{
|
||||
}
|
||||
PackRuleResult packRuleResult = GetShareBundleName(buildAssetInfo);
|
||||
if (packRuleResult.IsValid() == false)
|
||||
return;
|
||||
|
||||
/// <summary>
|
||||
/// 获取共享资源包名称
|
||||
/// </summary>
|
||||
protected virtual PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||
// 处理单个引用的共享资源
|
||||
if (buildAssetInfo.GetReferenceBundleCount() <= 1)
|
||||
{
|
||||
if (buildParameters.SingleReferencedPackAlone == false)
|
||||
return;
|
||||
}
|
||||
|
||||
// 设置共享资源包名
|
||||
string shareBundleName = packRuleResult.GetShareBundleName(command.PackageName, command.UniqueBundleName);
|
||||
buildAssetInfo.SetBundleName(shareBundleName);
|
||||
}
|
||||
private PackRuleResult GetShareBundleName(BuildAssetInfo buildAssetInfo)
|
||||
{
|
||||
string bundleName = Path.GetDirectoryName(buildAssetInfo.AssetInfo.AssetPath);
|
||||
PackRuleResult result = new PackRuleResult(bundleName, DefaultPackRule.AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 共享资源打包后置处理
|
||||
/// </summary>
|
||||
protected virtual void PostProcessPackShareBundle(BuildParameters buildParameters, CollectCommand command, Dictionary<string, BuildAssetInfo> allBuildAssetInfos)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ namespace YooAsset.Editor
|
||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateCatalog_BBP : TaskCreateCatalog, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8fe3d00b03dc9c64a96b7acfdf99b54c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 从文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
@@ -41,6 +46,8 @@ namespace YooAsset.Editor
|
||||
|
||||
if (ClearBuildCacheFiles)
|
||||
opt |= BuildAssetBundleOptions.ForceRebuildAssetBundle; //Force rebuild the asset bundles
|
||||
if (StripUnityVersion)
|
||||
opt |= BuildAssetBundleOptions.AssetBundleStripUnityVersion; //Removes the Unity Version number in the Archive File & Serialized File headers
|
||||
if (DisableWriteTypeTree)
|
||||
opt |= BuildAssetBundleOptions.DisableWriteTypeTree; //Do not include type information within the asset bundle (don't write type tree).
|
||||
if (IgnoreTypeTreeChanges)
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateReport_BBP(),
|
||||
new TaskCreatePackage_BBP(),
|
||||
new TaskCopyBuildinFiles_BBP(),
|
||||
new TaskCreateCatalog_BBP()
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace YooAsset.Editor
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return GetFilePathTempHash(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
return "00000000"; //8位
|
||||
return 0;
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
@@ -45,7 +45,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
long tempSize = 0;
|
||||
|
||||
var assetPaths = bundleInfo.GetAllMainAssetPaths();
|
||||
var assetPaths = bundleInfo.GetAllPackAssetPaths();
|
||||
foreach (var assetPath in assetPaths)
|
||||
{
|
||||
long size = FileUtility.GetFileSize(assetPath);
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace YooAsset.Editor
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
string dest = $"{pipelineOutputDirectory}/{bundleInfo.BundleName}";
|
||||
foreach (var buildAsset in bundleInfo.MainAssets)
|
||||
foreach (var buildAsset in bundleInfo.AllPackAssets)
|
||||
{
|
||||
EditorTools.CopyFile(buildAsset.AssetInfo.AssetPath, dest, true);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateCatalog_RFBP : TaskCreateCatalog, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 563771ecaff17ee498b5fda7c1132e62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -27,7 +27,7 @@ namespace YooAsset.Editor
|
||||
// 注意:原生文件资源包只能包含一个原生文件
|
||||
foreach (var bundleInfo in buildMapContext.Collection)
|
||||
{
|
||||
if (bundleInfo.MainAssets.Count != 1)
|
||||
if (bundleInfo.AllPackAssets.Count != 1)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.NotSupportMultipleRawAsset, $"The bundle does not support multiple raw asset : {bundleInfo.BundleName}");
|
||||
throw new Exception(message);
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace YooAsset.Editor
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
new TaskCreateCatalog_RFBP()
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ namespace YooAsset.Editor
|
||||
public class BuildResultContext : IContextObject
|
||||
{
|
||||
public IBundleBuildResults Results;
|
||||
public string BuiltinShadersBundleName;
|
||||
public string MonoScriptsBundleName;
|
||||
}
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
@@ -27,7 +29,9 @@ namespace YooAsset.Editor
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
var buildParameters = scriptableBuildParameters.GetBundleBuildParameters();
|
||||
var taskList = SBPBuildTasks.Create(buildMapContext.Command.ShadersBundleName, null);
|
||||
string builtinShadersBundleName = scriptableBuildParameters.BuiltinShadersBundleName;
|
||||
string monoScriptsBundleName = scriptableBuildParameters.MonoScriptsBundleName;
|
||||
var taskList = SBPBuildTasks.Create(builtinShadersBundleName, monoScriptsBundleName);
|
||||
ReturnCode exitCode = ContentPipeline.BuildAssetBundles(buildParameters, buildContent, out buildResults, taskList);
|
||||
if (exitCode < 0)
|
||||
{
|
||||
@@ -35,18 +39,24 @@ namespace YooAsset.Editor
|
||||
throw new Exception(message);
|
||||
}
|
||||
|
||||
// 创建着色器信息
|
||||
// 说明:解决因为着色器资源包导致验证失败。
|
||||
// 说明:解决因为特殊资源包导致验证失败。
|
||||
// 例如:当项目里没有着色器,如果有依赖内置着色器就会验证失败。
|
||||
string shadersBundleName = buildMapContext.Command.ShadersBundleName;
|
||||
if (buildResults.BundleInfos.ContainsKey(shadersBundleName))
|
||||
if (string.IsNullOrEmpty(builtinShadersBundleName) == false)
|
||||
{
|
||||
buildMapContext.CreateShadersBundleInfo(shadersBundleName);
|
||||
if (buildResults.BundleInfos.ContainsKey(builtinShadersBundleName))
|
||||
buildMapContext.CreateEmptyBundleInfo(builtinShadersBundleName);
|
||||
}
|
||||
if (string.IsNullOrEmpty(monoScriptsBundleName) == false)
|
||||
{
|
||||
if (buildResults.BundleInfos.ContainsKey(monoScriptsBundleName))
|
||||
buildMapContext.CreateEmptyBundleInfo(monoScriptsBundleName);
|
||||
}
|
||||
|
||||
BuildLogger.Log("UnityEngine build success!");
|
||||
BuildResultContext buildResultContext = new BuildResultContext();
|
||||
buildResultContext.Results = buildResults;
|
||||
buildResultContext.BuiltinShadersBundleName = builtinShadersBundleName;
|
||||
buildResultContext.MonoScriptsBundleName = monoScriptsBundleName;
|
||||
context.SetContextObject(buildResultContext);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class TaskCreateCatalog_SBP : TaskCreateCatalog, IBuildTask
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||
{
|
||||
CreateCatalogFile(buildParametersContext);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8241b1eb8e22874b84d279dae9bbd1b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var buildParameters = buildParametersContext.Parameters;
|
||||
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 检测基础构建参数
|
||||
buildParametersContext.CheckBuildParameters();
|
||||
@@ -50,6 +50,13 @@ namespace YooAsset.Editor
|
||||
{
|
||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
||||
}
|
||||
|
||||
// 检测内置着色器资源包名称
|
||||
if (string.IsNullOrEmpty(buildParameters.BuiltinShadersBundleName))
|
||||
{
|
||||
string warning = BuildLogger.GetErrorMessage(ErrorCode.BuiltinShadersBundleNameIsNull, $"Builtin shaders bundle name is null. It will cause resource redundancy !");
|
||||
BuildLogger.Warning(warning);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,10 +45,10 @@ namespace YooAsset.Editor
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
{
|
||||
public static class SBPBuildTasks
|
||||
{
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName, string unityMonoScriptsBundleName)
|
||||
public static IList<IBuildTask> Create(string builtInShaderBundleName, string monoScriptsBundleName)
|
||||
{
|
||||
var buildTasks = new List<IBuildTask>();
|
||||
|
||||
@@ -30,8 +30,8 @@ namespace UnityEditor.Build.Pipeline.Tasks
|
||||
buildTasks.Add(new StripUnusedSpriteSources());
|
||||
if (string.IsNullOrEmpty(builtInShaderBundleName) == false)
|
||||
buildTasks.Add(new CreateBuiltInShadersBundle(builtInShaderBundleName));
|
||||
if (string.IsNullOrEmpty(unityMonoScriptsBundleName) == false)
|
||||
buildTasks.Add(new CreateMonoScriptBundle(unityMonoScriptsBundleName));
|
||||
if (string.IsNullOrEmpty(monoScriptsBundleName) == false)
|
||||
buildTasks.Add(new CreateMonoScriptBundle(monoScriptsBundleName));
|
||||
buildTasks.Add(new PostDependencyCallback());
|
||||
|
||||
// Packing
|
||||
|
||||
@@ -14,16 +14,26 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 从文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
public bool DisableWriteTypeTree = false;
|
||||
|
||||
/// <summary>
|
||||
/// 忽略类型树变化
|
||||
/// 忽略类型树变化(无效参数)
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 自动建立资源对象对图集的依赖关系
|
||||
/// </summary>
|
||||
public bool TrackSpriteAtlasDependencies = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成代码防裁剪配置
|
||||
@@ -41,6 +51,17 @@ namespace YooAsset.Editor
|
||||
public int CacheServerPort;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// </summary>
|
||||
public string BuiltinShadersBundleName;
|
||||
|
||||
/// <summary>
|
||||
/// Mono脚本资源包名称
|
||||
/// </summary>
|
||||
public string MonoScriptsBundleName;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取可编程构建管线的构建参数
|
||||
/// </summary>
|
||||
@@ -59,8 +80,10 @@ namespace YooAsset.Editor
|
||||
else
|
||||
throw new System.NotImplementedException(CompressOption.ToString());
|
||||
|
||||
if (StripUnityVersion)
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.StripUnityVersion; // Build Flag to indicate the Unity Version should not be written to the serialized file.
|
||||
if (DisableWriteTypeTree)
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree; //Do not include type information within the built content.
|
||||
|
||||
buildParams.UseCache = true;
|
||||
buildParams.CacheServerHost = CacheServerHost;
|
||||
|
||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateReport_SBP(),
|
||||
new TaskCreatePackage_SBP(),
|
||||
new TaskCopyBuildinFiles_SBP(),
|
||||
new TaskCreateCatalog_SBP()
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
private readonly Dictionary<System.Type, IContextObject> _contextObjects = new Dictionary<System.Type, IContextObject>();
|
||||
|
||||
/// <summary>
|
||||
/// 清空所有情景对象
|
||||
/// 清空所有上下文对象
|
||||
/// </summary>
|
||||
public void ClearAllContext()
|
||||
{
|
||||
@@ -17,7 +17,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置情景对象
|
||||
/// 设置上下文对象
|
||||
/// </summary>
|
||||
public void SetContextObject(IContextObject contextObject)
|
||||
{
|
||||
@@ -32,7 +32,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取情景对象
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T GetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
@@ -46,5 +46,21 @@ namespace YooAsset.Editor
|
||||
throw new Exception($"Not found context object : {type}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取上下文对象
|
||||
/// </summary>
|
||||
public T TryGetContextObject<T>() where T : IContextObject
|
||||
{
|
||||
var type = typeof(T);
|
||||
if (_contextObjects.TryGetValue(type, out IContextObject contextObject))
|
||||
{
|
||||
return (T)contextObject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,37 +2,100 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.Text;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal static class BuildLogger
|
||||
{
|
||||
private static bool _enableLog = true;
|
||||
private const int MAX_LOG_BUFFER_SIZE = 1024 * 1024 * 2; //2MB
|
||||
|
||||
public static void InitLogger(bool enableLog)
|
||||
private static bool _enableLog = true;
|
||||
private static string _logFilePath;
|
||||
|
||||
private static readonly object _lockObj = new object();
|
||||
private static readonly StringBuilder _logBuilder = new StringBuilder(MAX_LOG_BUFFER_SIZE);
|
||||
|
||||
/// <summary>
|
||||
/// 初始化日志系统
|
||||
/// </summary>
|
||||
public static void InitLogger(bool enableLog, string logFilePath)
|
||||
{
|
||||
_enableLog = enableLog;
|
||||
_logFilePath = logFilePath;
|
||||
_logBuilder.Clear();
|
||||
|
||||
if (_enableLog)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_logFilePath))
|
||||
throw new Exception("Log file path is null or empty !");
|
||||
|
||||
Debug.Log($"Logger initialized at {DateTime.Now:yyyy-MM-dd HH:mm:ss}");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭日志系统
|
||||
/// </summary>
|
||||
public static void Shuntdown()
|
||||
{
|
||||
if (_enableLog)
|
||||
{
|
||||
lock (_lockObj)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (File.Exists(_logFilePath))
|
||||
File.Delete(_logFilePath);
|
||||
|
||||
FileUtility.CreateFileDirectory(_logFilePath);
|
||||
File.WriteAllText(_logFilePath, _logBuilder.ToString(), Encoding.UTF8);
|
||||
_logBuilder.Clear();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogError($"Failed to write log file: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void Log(string message)
|
||||
{
|
||||
if (_enableLog)
|
||||
{
|
||||
WriteLog("INFO", message);
|
||||
Debug.Log(message);
|
||||
}
|
||||
}
|
||||
public static void Warning(string message)
|
||||
{
|
||||
Debug.LogWarning(message);
|
||||
if (_enableLog)
|
||||
{
|
||||
WriteLog("WARN", message);
|
||||
Debug.LogWarning(message);
|
||||
}
|
||||
}
|
||||
public static void Error(string message)
|
||||
{
|
||||
Debug.LogError(message);
|
||||
if (_enableLog)
|
||||
{
|
||||
WriteLog("ERROR", message);
|
||||
Debug.LogError(message);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetErrorMessage(ErrorCode code, string message)
|
||||
{
|
||||
return $"[ErrorCode{(int)code}] {message}";
|
||||
}
|
||||
|
||||
private static void WriteLog(string level, string message)
|
||||
{
|
||||
lock (_lockObj)
|
||||
{
|
||||
string logEntry = $"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} [{level}] {message}";
|
||||
_logBuilder.AppendLine(logEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string ErrorInfo;
|
||||
|
||||
/// <summary>
|
||||
/// 构建失败的堆栈
|
||||
/// </summary>
|
||||
public string ErrorStack;
|
||||
|
||||
/// <summary>
|
||||
/// 输出的补丁包目录
|
||||
/// </summary>
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace YooAsset.Editor
|
||||
EditorTools.ClearProgressBar();
|
||||
buildResult.FailedTask = task.GetType().Name;
|
||||
buildResult.ErrorInfo = e.ToString();
|
||||
buildResult.ErrorStack = e.StackTrace;
|
||||
buildResult.Success = false;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ namespace YooAsset.Editor
|
||||
BuildPipelineIsNullOrEmpty = 116,
|
||||
BuildBundleTypeIsUnknown = 117,
|
||||
RecommendScriptBuildPipeline = 130,
|
||||
BuiltinShadersBundleNameIsNull = 131,
|
||||
|
||||
// TaskGetBuildMap
|
||||
RemoveInvalidTags = 200,
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class ManifestProcessNone : IManifestProcessServices
|
||||
{
|
||||
byte[] IManifestProcessServices.ProcessManifest(byte[] fileData)
|
||||
{
|
||||
return fileData;
|
||||
}
|
||||
}
|
||||
|
||||
public class ManifestRestoreNone : IManifestRestoreServices
|
||||
{
|
||||
byte[] IManifestRestoreServices.RestoreManifest(byte[] fileData)
|
||||
{
|
||||
return fileData;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 446513b0ea9f5d445ade0cfb09c5073b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,13 @@
|
||||
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public interface IBuildPipeline
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行构建任务
|
||||
/// </summary>
|
||||
BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public class BuildPipelineAttribute : Attribute
|
||||
{
|
||||
public string PipelineName;
|
||||
|
||||
public BuildPipelineAttribute(string name)
|
||||
{
|
||||
this.PipelineName = name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90d865a5cede7ae43a5fdabdc20af0fd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,211 +12,269 @@ namespace YooAsset.Editor
|
||||
{
|
||||
internal abstract class BuildPipelineViewerBase
|
||||
{
|
||||
private const int StyleWidth = 400;
|
||||
private const int LabelMinWidth = 180;
|
||||
protected const int StyleWidth = 400;
|
||||
protected const int LabelMinWidth = 190;
|
||||
|
||||
protected readonly string PackageName;
|
||||
protected readonly BuildTarget BuildTarget;
|
||||
protected readonly EBuildPipeline BuildPipeline;
|
||||
protected TemplateContainer Root;
|
||||
protected string PackageName { private set; get; }
|
||||
protected string PipelineName { private set; get; }
|
||||
protected BuildTarget BuildTarget { private set; get; }
|
||||
|
||||
private TextField _buildOutputField;
|
||||
private TextField _buildVersionField;
|
||||
private PopupField<Enum> _buildModeField;
|
||||
private PopupField<Type> _encryptionField;
|
||||
private EnumField _compressionField;
|
||||
private EnumField _outputNameStyleField;
|
||||
private EnumField _copyBuildinFileOptionField;
|
||||
private TextField _copyBuildinFileTagsField;
|
||||
private Toggle _clearBuildCacheToggle;
|
||||
private Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
public BuildPipelineViewerBase(string packageName, EBuildPipeline buildPipeline, BuildTarget buildTarget, VisualElement parent)
|
||||
/// <summary>
|
||||
/// 初始化视图
|
||||
/// </summary>
|
||||
public void InitView(string packageName, string pipelineName, BuildTarget buildTarget)
|
||||
{
|
||||
PackageName = packageName;
|
||||
PipelineName = pipelineName;
|
||||
BuildTarget = buildTarget;
|
||||
BuildPipeline = buildPipeline;
|
||||
|
||||
CreateView(parent);
|
||||
RefreshView();
|
||||
}
|
||||
private void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuildPipelineViewerBase>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
_buildOutputField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
_buildOutputField.SetEnabled(false);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
_buildVersionField.style.width = StyleWidth;
|
||||
_buildVersionField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||
|
||||
// 加密方法
|
||||
{
|
||||
var encryptionContainer = Root.Q("EncryptionContainer");
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
if (encryptionClassTypes.Count > 0)
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
int defaultIndex = encryptionClassTypes.FindIndex(x => x.FullName.Equals(encyptionClassName));
|
||||
if (defaultIndex < 0)
|
||||
defaultIndex = 0;
|
||||
_encryptionField = new PopupField<Type>(encryptionClassTypes, defaultIndex);
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
_encryptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageEncyptionClassName(PackageName, BuildPipeline, _encryptionField.value.FullName);
|
||||
});
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
else
|
||||
{
|
||||
_encryptionField = new PopupField<Type>();
|
||||
_encryptionField.label = "Encryption";
|
||||
_encryptionField.style.width = StyleWidth;
|
||||
encryptionContainer.Add(_encryptionField);
|
||||
}
|
||||
}
|
||||
|
||||
// 压缩方式选项
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
_compressionField.Init(compressOption);
|
||||
_compressionField.SetValueWithoutNotify(compressOption);
|
||||
_compressionField.style.width = StyleWidth;
|
||||
_compressionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, BuildPipeline, (ECompressOption)_compressionField.value);
|
||||
});
|
||||
|
||||
// 输出文件名称样式
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
_outputNameStyleField.Init(fileNameStyle);
|
||||
_outputNameStyleField.SetValueWithoutNotify(fileNameStyle);
|
||||
_outputNameStyleField.style.width = StyleWidth;
|
||||
_outputNameStyleField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, BuildPipeline, (EFileNameStyle)_outputNameStyleField.value);
|
||||
});
|
||||
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
_copyBuildinFileOptionField.Init(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
_copyBuildinFileOptionField.style.width = StyleWidth;
|
||||
_copyBuildinFileOptionField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, BuildPipeline, (EBuildinFileCopyOption)_copyBuildinFileOptionField.value);
|
||||
RefreshView();
|
||||
});
|
||||
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
_copyBuildinFileTagsField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
_copyBuildinFileTagsField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, BuildPipeline, _copyBuildinFileTagsField.value);
|
||||
});
|
||||
|
||||
// 清理构建缓存
|
||||
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");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void RefreshView()
|
||||
{
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
bool tagsFiledVisible = buildinFileCopyOption == EBuildinFileCopyOption.ClearAndCopyByTags || buildinFileCopyOption == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
_copyBuildinFileTagsField.visible = tagsFiledVisible;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] 打包已经取消");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建任务
|
||||
/// 创建视图
|
||||
/// </summary>
|
||||
protected abstract void ExecuteBuild();
|
||||
public abstract void CreateView(VisualElement parent);
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建版本
|
||||
/// 获取默认版本
|
||||
/// </summary>
|
||||
protected string GetPackageVersion()
|
||||
protected virtual string GetDefaultPackageVersion()
|
||||
{
|
||||
return _buildVersionField.value;
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建加密类实例
|
||||
/// 创建资源包加密服务类实例
|
||||
/// </summary>
|
||||
protected IEncryptionServices CreateEncryptionInstance()
|
||||
protected IEncryptionServices CreateEncryptionServicesInstance()
|
||||
{
|
||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
||||
var className = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, PipelineName);
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||
if (classType != null)
|
||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
private string GetDefaultPackageVersion()
|
||||
/// <summary>
|
||||
/// 创建资源清单加密服务类实例
|
||||
/// </summary>
|
||||
protected IManifestProcessServices CreateManifestProcessServicesInstance()
|
||||
{
|
||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
||||
var className = AssetBundleBuilderSetting.GetPackageManifestProcessServicesClassName(PackageName, PipelineName);
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestProcessServices));
|
||||
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||
if (classType != null)
|
||||
return (IManifestProcessServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建资源清单解密服务类实例
|
||||
/// </summary>
|
||||
protected IManifestRestoreServices CreateManifestRestoreServicesInstance()
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageManifestRestoreServicesClassName(PackageName, PipelineName);
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestRestoreServices));
|
||||
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||
if (classType != null)
|
||||
return (IManifestRestoreServices)Activator.CreateInstance(classType);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
#region UI元素通用处理方法
|
||||
protected void SetBuildOutputField(TextField textField)
|
||||
{
|
||||
// 输出目录
|
||||
string defaultOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
textField.SetValueWithoutNotify(defaultOutputRoot);
|
||||
textField.SetEnabled(false);
|
||||
UIElementsTools.SetElementLabelMinWidth(textField, LabelMinWidth);
|
||||
}
|
||||
protected void SetBuildVersionField(TextField textField)
|
||||
{
|
||||
// 构建版本
|
||||
textField.style.width = StyleWidth;
|
||||
textField.SetValueWithoutNotify(GetDefaultPackageVersion());
|
||||
UIElementsTools.SetElementLabelMinWidth(textField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCompressionField(EnumField enumField)
|
||||
{
|
||||
// 压缩方式选项
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||
enumField.Init(compressOption);
|
||||
enumField.SetValueWithoutNotify(compressOption);
|
||||
enumField.style.width = StyleWidth;
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageCompressOption(PackageName, PipelineName, (ECompressOption)enumField.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetOutputNameStyleField(EnumField enumField)
|
||||
{
|
||||
// 输出文件名称样式
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
enumField.Init(fileNameStyle);
|
||||
enumField.SetValueWithoutNotify(fileNameStyle);
|
||||
enumField.style.width = StyleWidth;
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageFileNameStyle(PackageName, PipelineName, (EFileNameStyle)enumField.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuildinFileOptionField(EnumField enumField, TextField tagField)
|
||||
{
|
||||
// 首包文件拷贝选项
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
enumField.Init(buildinFileCopyOption);
|
||||
enumField.SetValueWithoutNotify(buildinFileCopyOption);
|
||||
enumField.style.width = StyleWidth;
|
||||
enumField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyOption(PackageName, PipelineName, (EBuildinFileCopyOption)enumField.value);
|
||||
|
||||
// 设置内置资源标签显隐
|
||||
SetCopyBuildinFileTagsVisible(tagField);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(enumField, LabelMinWidth);
|
||||
}
|
||||
protected void SetCopyBuildinFileTagsVisible(TextField tagField)
|
||||
{
|
||||
var option = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
tagField.visible = option == EBuildinFileCopyOption.ClearAndCopyByTags || option == EBuildinFileCopyOption.OnlyCopyByTags;
|
||||
}
|
||||
protected void SetCopyBuildinFileTagsField(TextField textField)
|
||||
{
|
||||
// 首包文件拷贝参数
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
textField.SetValueWithoutNotify(buildinFileCopyParams);
|
||||
textField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageBuildinFileCopyParams(PackageName, PipelineName, textField.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(textField, LabelMinWidth);
|
||||
}
|
||||
protected void SetClearBuildCacheToggle(Toggle toggle)
|
||||
{
|
||||
// 清理构建缓存
|
||||
bool clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
toggle.SetValueWithoutNotify(clearBuildCache);
|
||||
toggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageClearBuildCache(PackageName, PipelineName, toggle.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(toggle, LabelMinWidth);
|
||||
}
|
||||
protected void SetUseAssetDependencyDBToggle(Toggle toggle)
|
||||
{
|
||||
// 使用资源依赖数据库
|
||||
bool useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
toggle.SetValueWithoutNotify(useAssetDependencyDB);
|
||||
toggle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageUseAssetDependencyDB(PackageName, PipelineName, toggle.value);
|
||||
});
|
||||
UIElementsTools.SetElementLabelMinWidth(toggle, LabelMinWidth);
|
||||
}
|
||||
protected PopupField<Type> CreateEncryptionServicesField(VisualElement container)
|
||||
{
|
||||
// 资源包加密服务类
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||
if (classTypes.Count > 0)
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, PipelineName);
|
||||
int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className));
|
||||
if (defaultIndex < 0)
|
||||
defaultIndex = 0;
|
||||
var popupField = new PopupField<Type>(classTypes, defaultIndex);
|
||||
popupField.label = "Encryption Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
popupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageEncyptionServicesClassName(PackageName, PipelineName, popupField.value.FullName);
|
||||
});
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
else
|
||||
{
|
||||
var popupField = new PopupField<Type>();
|
||||
popupField.label = "Encryption Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
}
|
||||
protected PopupField<Type> CreateManifestProcessServicesField(VisualElement container)
|
||||
{
|
||||
// 资源清单加密服务类
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestProcessServices));
|
||||
if (classTypes.Count > 0)
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageManifestProcessServicesClassName(PackageName, PipelineName);
|
||||
int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className));
|
||||
if (defaultIndex < 0)
|
||||
defaultIndex = 0;
|
||||
var popupField = new PopupField<Type>(classTypes, defaultIndex);
|
||||
popupField.label = "Manifest Process Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
popupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageManifestProcessServicesClassName(PackageName, PipelineName, popupField.value.FullName);
|
||||
});
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
else
|
||||
{
|
||||
var popupField = new PopupField<Type>();
|
||||
popupField.label = "Manifest Process Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
}
|
||||
protected PopupField<Type> CreateManifestRestoreServicesField(VisualElement container)
|
||||
{
|
||||
// 资源清单加密服务类
|
||||
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestRestoreServices));
|
||||
if (classTypes.Count > 0)
|
||||
{
|
||||
var className = AssetBundleBuilderSetting.GetPackageManifestRestoreServicesClassName(PackageName, PipelineName);
|
||||
int defaultIndex = classTypes.FindIndex(x => x.FullName.Equals(className));
|
||||
if (defaultIndex < 0)
|
||||
defaultIndex = 0;
|
||||
var popupField = new PopupField<Type>(classTypes, defaultIndex);
|
||||
popupField.label = "Manifest Restore Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
popupField.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
AssetBundleBuilderSetting.SetPackageManifestRestoreServicesClassName(PackageName, PipelineName, popupField.value.FullName);
|
||||
});
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
else
|
||||
{
|
||||
var popupField = new PopupField<Type>();
|
||||
popupField.label = "Manifest Restore Services";
|
||||
popupField.style.width = StyleWidth;
|
||||
container.Add(popupField);
|
||||
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||
return popupField;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user