mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-14 19:40:47 +00:00
Compare commits
284 Commits
2.3.2-prev
...
2.3.18
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4b6a8ca406 | ||
|
|
c8e45a6cae | ||
|
|
1fbc9d26a6 | ||
|
|
abb087b02e | ||
|
|
aeaf03011f | ||
|
|
78d24ad3a6 | ||
|
|
aab2c4625e | ||
|
|
079ef75605 | ||
|
|
75881b55f6 | ||
|
|
2020c7d508 | ||
|
|
088d939346 | ||
|
|
fa50e91c9f | ||
|
|
2e7b992a4b | ||
|
|
29fbbd97ff | ||
|
|
abb150e33f | ||
|
|
78e20f434e | ||
|
|
304222b788 | ||
|
|
101236db8a | ||
|
|
37de007b3f | ||
|
|
d570ba8d74 | ||
|
|
2a956099ae | ||
|
|
74037a5a29 | ||
|
|
861f850a32 | ||
|
|
8b1b5f988a | ||
|
|
efafd1173f | ||
|
|
03e49ff1fb | ||
|
|
ea34be1f00 | ||
|
|
831a9981e3 | ||
|
|
9de4aaa658 | ||
|
|
3579a23bd5 | ||
|
|
c865ddc7f2 | ||
|
|
0bde506aec | ||
|
|
15005b3d30 | ||
|
|
4caf733ac6 | ||
|
|
014b17f5cb | ||
|
|
f3ebda0c04 | ||
|
|
5602addaca | ||
|
|
c4ae67aa8e | ||
|
|
bbcc3bf971 | ||
|
|
8b0e75b9b3 | ||
|
|
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 |
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,616 @@
|
||||
|
||||
All notable changes to this package will be documented in this file.
|
||||
|
||||
## [2.3.18] - 2025-12-04
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#676) 修复了UniTask扩展包的编译报错。
|
||||
- (#684) 修复了资源配置窗口Group列表数量过多的时候,添加和删除按钮会变小的问题。
|
||||
- (#700) [**严重**] 修复了小游戏扩展库的下载器再失败后重试逻辑不起效的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#683) 新增了内置文件系统类初始化参数:UNPACK_FILE_SYSTEM_ROOT
|
||||
|
||||
```csharp
|
||||
class FileSystemParametersDefine
|
||||
{
|
||||
// 指定解压文件的根目录
|
||||
public const string UNPACK_FILE_SYSTEM_ROOT = "UNPACK_FILE_SYSTEM_ROOT";
|
||||
}
|
||||
```
|
||||
|
||||
- (#682) 原生文件构建管线新增构建参数:IncludePathInHash
|
||||
|
||||
```csharp
|
||||
class RawFileBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件哈希值计算包含路径信息
|
||||
/// </summary>
|
||||
public bool IncludePathInHash = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#671) 新增扩展工具,可以生成空的包裹内置资源目录文件。
|
||||
|
||||
```csharp
|
||||
public class CreateEmptyCatalogWindow : EditorWindow
|
||||
```
|
||||
|
||||
- (#694) 新增资源清理方式:ClearBundleFilesByLocations
|
||||
|
||||
```csharp
|
||||
public enum EFileClearMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理指定地址的文件
|
||||
/// 说明:需要指定参数,可选:string, string[], List<string>
|
||||
/// </summary>
|
||||
ClearBundleFilesByLocations,
|
||||
}
|
||||
```
|
||||
|
||||
## [2.3.17] - 2025-10-30
|
||||
|
||||
**非常重要**:修复了#627优化导致的资源清单CRC值为空的问题。
|
||||
|
||||
该问题会导致下载的损坏文件验证通过。
|
||||
|
||||
影响范围:v2.3.15版本,v2.3.16版本。
|
||||
|
||||
**非常重要**:(#661) 修复了Package销毁过程中,遇到正在加载的AssetBundle会导致无法卸载的问题。
|
||||
|
||||
该问题是偶现,引擎会提示AssetBundle已经加载,无法加载新的文件,导致资源对象加载失败!
|
||||
|
||||
影响范围:所有版本!
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#645) 修复了着色器变种收集工具,在极端情况下变种收集不完整的问题。
|
||||
- (#646) 修复了EditorSimulateMode模式下开启模拟下载tag不生效的问题。
|
||||
- (#667) 修复了所有编辑器窗口针对中文IME的输入问题。
|
||||
- (#670) 修复了Catalog文件生成过程中白名单未考虑自定义清单前缀名。
|
||||
|
||||
### Improvements
|
||||
|
||||
- 重构并统一了资源清单的反序列化逻辑。
|
||||
- (#650) 解决互相依赖的资源包无法卸载的问题。需要开启宏定义:YOOASSET_EXPERIMENTAL
|
||||
- (#655) 优化了初始化的时候,缓存文件搜索效率。安卓平台性能提升1倍,IOS平台性能提升3倍。
|
||||
|
||||
### Added
|
||||
|
||||
- (#643) 新增构建参数,可以节省资源清单运行时内存
|
||||
|
||||
```csharp
|
||||
class ScriptableBuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#648) 新增初始化参数,可以自动释放引用计数为零的资源包
|
||||
|
||||
```csharp
|
||||
class InitializeParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 当资源引用计数为零的时候自动释放资源包
|
||||
/// </summary>
|
||||
public bool AutoUnloadBundleWhenUnused = false;
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 程序集宏定义代码转移到扩展工程。参考MacroSupport文件夹。
|
||||
|
||||
## [2.3.16] - 2025-09-17
|
||||
|
||||
### Improvements
|
||||
|
||||
- (#638) 优化了Provider加载机制,引用计数为零时自动挂起!
|
||||
|
||||
### Fixed
|
||||
|
||||
- (#644) [**严重**] 修复了2.3.15版本,资产量巨大的情况下,编辑器下模拟模式初始化耗时很久的问题。
|
||||
|
||||
### Added
|
||||
|
||||
- (#639) 新增了文件系统参数:VIRTUAL_DOWNLOAD_MODE 和 VIRTUAL_DOWNLOAD_SPEED
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟远端资源下载,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载模式
|
||||
/// </summary>
|
||||
public bool VirtualDownloadMode { private set; get; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// 模拟虚拟下载的网速(单位:字节)
|
||||
/// </summary>
|
||||
public int VirtualDownloadSpeed { private set; get; } = 1024;
|
||||
}
|
||||
```
|
||||
|
||||
- (#640) 新增了文件系统参数:VIRTUAL_WEBGL_MODE
|
||||
|
||||
编辑器下不需要构建AB,也可以模拟小游戏开发环境,等同真机运行环境。
|
||||
|
||||
```csharp
|
||||
class DefaultEditorFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 模拟WebGL平台模式
|
||||
/// </summary>
|
||||
public bool VirtualWebGLMode { private set; get; } = false;
|
||||
}
|
||||
```
|
||||
|
||||
- (#642) 新增了文件系统参数:DOWNLOAD_WATCH_DOG_TIME
|
||||
|
||||
监控时间范围内,如果没有接收到任何下载数据,那么直接终止任务!
|
||||
|
||||
```csharp
|
||||
class DefaultCacheFIleSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// 自定义参数:下载任务的看门狗机制监控时间
|
||||
/// </summary>
|
||||
public int DownloadWatchDogTime { private set; get; } = int.MaxValue;
|
||||
}
|
||||
```
|
||||
|
||||
### Changed
|
||||
|
||||
- 下载器参数timeout移除。
|
||||
|
||||
可以使用文件系统的看门狗机制代替。
|
||||
|
||||
- (#632) IFilterRule接口变动。
|
||||
|
||||
收集器可以指定搜寻的资源类型,在收集目录资产量巨大的情况下,可以极大加快打包速度!
|
||||
|
||||
```csharp
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
|
||||
## [2.3.15] - 2025-09-09
|
||||
|
||||
**重要**:升级了资源清单版本,不兼容老版本。建议重新提审安装包。
|
||||
|
||||
### 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
|
||||
|
||||
@@ -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
|
||||
@@ -97,7 +97,7 @@ namespace YooAsset.Editor
|
||||
private Button _passesVisibleBtn;
|
||||
private Label _titleLabel;
|
||||
private Label _descLabel;
|
||||
private TableView _elementTableView;
|
||||
private TableViewer _elementTableView;
|
||||
|
||||
private ScanReportCombiner _reportCombiner;
|
||||
private string _lastestOpenFolder;
|
||||
@@ -152,7 +152,7 @@ namespace YooAsset.Editor
|
||||
_descLabel = root.Q<Label>("ReportDesc");
|
||||
|
||||
// 列表相关
|
||||
_elementTableView = root.Q<TableView>("TopTableView");
|
||||
_elementTableView = root.Q<TableViewer>("TopTableView");
|
||||
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
||||
|
||||
_lastestOpenFolder = EditorTools.GetProjectPath();
|
||||
@@ -196,6 +196,32 @@ namespace YooAsset.Editor
|
||||
}
|
||||
}
|
||||
|
||||
/// <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");
|
||||
@@ -235,14 +261,14 @@ namespace YooAsset.Editor
|
||||
catch (System.Exception e)
|
||||
{
|
||||
_reportCombiner = null;
|
||||
_titleLabel.text = "导入报告失败!";
|
||||
_titleLabel.text = "Failed to import report!";
|
||||
_descLabel.text = e.Message;
|
||||
UnityEngine.Debug.LogError(e.StackTrace);
|
||||
}
|
||||
}
|
||||
private void FixAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复全部资源(排除白名单和隐藏元素)", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("Info", "Fix all resources (excluding whitelist and hidden elements)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixAll();
|
||||
@@ -250,7 +276,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void FixSelectBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", "修复勾选资源(包含白名单和隐藏元素)", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("Info", "Fix selected resources (including whitelist and hidden elements)", "Yes", "No"))
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
_reportCombiner.FixSelect();
|
||||
@@ -276,7 +302,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void ExportFilesBtn_clicked()
|
||||
{
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("导入所有选中资源", EditorTools.GetProjectPath(), string.Empty);
|
||||
string selectFolderPath = EditorUtility.OpenFolderPanel("Export all selected resources", EditorTools.GetProjectPath(), string.Empty);
|
||||
if (string.IsNullOrEmpty(selectFolderPath) == false)
|
||||
{
|
||||
if (_reportCombiner != null)
|
||||
@@ -326,7 +352,7 @@ namespace YooAsset.Editor
|
||||
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
||||
column.MakeCell = () =>
|
||||
{
|
||||
var toggle = new DisplayToggle();
|
||||
var toggle = new ToggleDisplay();
|
||||
toggle.text = string.Empty;
|
||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
||||
@@ -334,11 +360,10 @@ namespace YooAsset.Editor
|
||||
};
|
||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||
{
|
||||
var toggle = element as DisplayToggle;
|
||||
var toggle = element as ToggleDisplay;
|
||||
toggle.userData = data;
|
||||
var tableData = data as ElementTableData;
|
||||
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
||||
toggle.RefreshIcon();
|
||||
};
|
||||
_elementTableView.AddColumn(column);
|
||||
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
||||
@@ -442,18 +467,36 @@ namespace YooAsset.Editor
|
||||
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 = () =>
|
||||
{
|
||||
var label = new Label();
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
return label;
|
||||
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) =>
|
||||
{
|
||||
var infoLabel = element as Label;
|
||||
infoLabel.text = (string)cell.GetDisplayObject();
|
||||
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);
|
||||
}
|
||||
@@ -479,6 +522,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
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);
|
||||
@@ -577,10 +624,8 @@ namespace YooAsset.Editor
|
||||
// 重绘视图
|
||||
RebuildView();
|
||||
}
|
||||
private void OnDisplayToggleValueChange(DisplayToggle toggle, ChangeEvent<bool> e)
|
||||
private void OnDisplayToggleValueChange(ToggleDisplay toggle, ChangeEvent<bool> e)
|
||||
{
|
||||
toggle.RefreshIcon();
|
||||
|
||||
// 处理自身
|
||||
toggle.SetValueWithoutNotify(e.newValue);
|
||||
|
||||
@@ -593,7 +638,8 @@ namespace YooAsset.Editor
|
||||
foreach (var selectedItem in selectedItems)
|
||||
{
|
||||
var selectElement = selectedItem as ElementTableData;
|
||||
selectElement.Element.Hidden = e.newValue;
|
||||
if (selectElement != null)
|
||||
selectElement.Element.Hidden = e.newValue;
|
||||
}
|
||||
|
||||
// 重绘视图
|
||||
|
||||
@@ -17,6 +17,6 @@
|
||||
<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.TableView name="TopTableView" />
|
||||
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -8,6 +8,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
AssetPath,
|
||||
|
||||
/// <summary>
|
||||
/// 资源对象
|
||||
/// </summary>
|
||||
AssetObject,
|
||||
|
||||
/// <summary>
|
||||
/// 字符串
|
||||
/// </summary>
|
||||
|
||||
@@ -43,6 +43,16 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool Sortable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 统计数量
|
||||
/// </summary>
|
||||
public bool Counter = false;
|
||||
|
||||
/// <summary>
|
||||
/// 展示单位
|
||||
/// </summary>
|
||||
public string Units = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 数值类型
|
||||
/// </summary>
|
||||
@@ -89,6 +99,16 @@ namespace YooAsset.Editor
|
||||
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;
|
||||
@@ -106,6 +126,12 @@ namespace YooAsset.Editor
|
||||
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)
|
||||
|
||||
@@ -32,21 +32,14 @@ namespace YooAsset.Editor
|
||||
|
||||
// 开始扫描工作
|
||||
ScanReport report = scanner.RunScanner();
|
||||
|
||||
// 检测报告合法性
|
||||
report.CheckError();
|
||||
|
||||
// 保存扫描结果
|
||||
string saveDirectory = scanner.SaveDirectory;
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{scanner.ScannerName}_{scanner.ScannerDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, report);
|
||||
return new ScannerResult(filePath, report);
|
||||
// 返回扫描结果
|
||||
return new ScannerResult(report);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return new ScannerResult(e.Message);
|
||||
return new ScannerResult(e.Message, e.StackTrace);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -240,7 +240,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void ScanAllBtn_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("提示", $"开始全面扫描!", "Yes", "No"))
|
||||
if (EditorUtility.DisplayDialog("Info", $"Start full scan!", "Yes", "No"))
|
||||
{
|
||||
string searchKeyWord = _scannerSearchField.value;
|
||||
AssetArtScannerSettingData.ScanAll(searchKeyWord);
|
||||
@@ -248,7 +248,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("全面扫描已经取消");
|
||||
Debug.LogWarning("Full scan has been canceled.");
|
||||
}
|
||||
}
|
||||
private void ScanBtn_clicked()
|
||||
@@ -294,6 +294,11 @@ namespace YooAsset.Editor
|
||||
_scannerListView.itemsSource = filterItems;
|
||||
_scannerListView.Rebuild();
|
||||
}
|
||||
|
||||
if (_lastModifyScannerIndex >= 0 && _lastModifyScannerIndex < _scannerListView.itemsSource.Count)
|
||||
{
|
||||
_scannerListView.selectedIndex = _lastModifyScannerIndex;
|
||||
}
|
||||
}
|
||||
private List<AssetArtScanner> FilterScanners()
|
||||
{
|
||||
|
||||
@@ -3,11 +3,6 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class ScannerResult
|
||||
{
|
||||
/// <summary>
|
||||
/// 生成的报告文件路径
|
||||
/// </summary>
|
||||
public string ReprotFilePath { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 报告对象
|
||||
/// </summary>
|
||||
@@ -18,6 +13,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string ErrorInfo { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误堆栈
|
||||
/// </summary>
|
||||
public string ErrorStack { private set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否成功
|
||||
/// </summary>
|
||||
@@ -33,15 +33,14 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
|
||||
public ScannerResult(string error)
|
||||
public ScannerResult(string error, string stack)
|
||||
{
|
||||
ErrorInfo = error;
|
||||
ErrorStack = stack;
|
||||
}
|
||||
public ScannerResult(string filePath, ScanReport report)
|
||||
public ScannerResult(ScanReport report)
|
||||
{
|
||||
ReprotFilePath = filePath;
|
||||
Report = report;
|
||||
ErrorInfo = string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -52,8 +51,22 @@ namespace YooAsset.Editor
|
||||
if (Succeed)
|
||||
{
|
||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||
reproterWindow.ImportSingleReprotFile(ReprotFilePath);
|
||||
reproterWindow.ImportSingleReprotFile(Report);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存报告文件
|
||||
/// </summary>
|
||||
public void SaveReportFile(string saveDirectory)
|
||||
{
|
||||
if (Report == null)
|
||||
throw new System.Exception("Scan report is invalid !");
|
||||
|
||||
if (string.IsNullOrEmpty(saveDirectory))
|
||||
saveDirectory = "Assets/";
|
||||
string filePath = $"{saveDirectory}/{Report.ReportName}_{Report.ReportDesc}.json";
|
||||
ScanReportConfig.ExportJsonConfig(filePath, Report);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -32,8 +32,9 @@ namespace YooAsset.Editor
|
||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||
_buildContext.SetContextObject(buildParametersContext);
|
||||
|
||||
// 初始化日志
|
||||
BuildLogger.InitLogger(enableLog);
|
||||
// 初始化日志系统
|
||||
string logFilePath = $"{buildParametersContext.GetPipelineOutputDirectory()}/buildInfo.log";
|
||||
BuildLogger.InitLogger(enableLog, logFilePath);
|
||||
|
||||
// 执行构建流程
|
||||
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||
@@ -50,6 +51,9 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Error(buildResult.ErrorInfo);
|
||||
}
|
||||
|
||||
// 关闭日志系统
|
||||
BuildLogger.Shuntdown();
|
||||
|
||||
return buildResult;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
/// 文件哈希值
|
||||
@@ -106,7 +106,27 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string[] GetAllPackAssetPaths()
|
||||
{
|
||||
return AllPackAssets.Select(t => t.AssetInfo.AssetPath).ToArray();
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.AssetInfo.AssetPath);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取构建的资源可寻址列表
|
||||
/// </summary>
|
||||
public string[] GetAllPackAssetAddress()
|
||||
{
|
||||
List<string> results = new List<string>(AllPackAssets.Count);
|
||||
for (int i = 0; i < AllPackAssets.Count; i++)
|
||||
{
|
||||
var packAsset = AllPackAssets[i];
|
||||
results.Add(packAsset.Address);
|
||||
}
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -153,13 +173,15 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 创建AssetBundleBuild类
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild()
|
||||
public UnityEditor.AssetBundleBuild CreatePipelineBuild(bool replaceAssetPathWithAddress)
|
||||
{
|
||||
// 注意:我们不再支持AssetBundle的变种机制
|
||||
AssetBundleBuild build = new AssetBundleBuild();
|
||||
build.assetBundleName = BundleName;
|
||||
build.assetBundleVariant = string.Empty;
|
||||
build.assetNames = GetAllPackAssetPaths();
|
||||
if (replaceAssetPathWithAddress)
|
||||
build.addressableNames = GetAllPackAssetAddress();
|
||||
return build;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,11 @@ 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>
|
||||
@@ -60,6 +65,12 @@ namespace YooAsset.Editor
|
||||
newBundleInfo.PackAsset(assetInfo);
|
||||
_bundleInfoDic.Add(bundleName, newBundleInfo);
|
||||
}
|
||||
|
||||
// 统计所有的精灵图集
|
||||
if (assetInfo.AssetInfo.IsSpriteAtlas())
|
||||
{
|
||||
SpriteAtlasAssetList.Add(assetInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -85,12 +96,12 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 获取构建管线里需要的数据
|
||||
/// </summary>
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds()
|
||||
public UnityEditor.AssetBundleBuild[] GetPipelineBuilds(bool replaceAssetPathWithAddres)
|
||||
{
|
||||
List<UnityEditor.AssetBundleBuild> builds = new List<UnityEditor.AssetBundleBuild>(_bundleInfoDic.Count);
|
||||
foreach (var bundleInfo in _bundleInfoDic.Values)
|
||||
{
|
||||
builds.Add(bundleInfo.CreatePipelineBuild());
|
||||
builds.Add(bundleInfo.CreatePipelineBuild(replaceAssetPathWithAddres));
|
||||
}
|
||||
return builds.ToArray();
|
||||
}
|
||||
|
||||
@@ -98,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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56ea224b45d314e4a86b558404e9b6c8
|
||||
guid: 2d2c835e5e40ca34d93480587c8125df
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -18,7 +19,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 创建补丁清单文件到输出目录
|
||||
/// </summary>
|
||||
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, BuildContext context)
|
||||
protected void CreateManifestFile(bool processBundleDepends, bool processBundleTags, bool replaceAssetPathWithAddress, BuildContext context)
|
||||
{
|
||||
var buildMapContext = context.GetContextObject<BuildMapContext>();
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
@@ -30,10 +31,12 @@ 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.ReplaceAssetPathWithAddress = replaceAssetPathWithAddress;
|
||||
manifest.OutputNameStyle = (int)buildParameters.FileNameStyle;
|
||||
manifest.BuildBundleType = buildParameters.BuildBundleType;
|
||||
manifest.BuildPipeline = buildParameters.BuildPipeline;
|
||||
@@ -56,9 +59,15 @@ namespace YooAsset.Editor
|
||||
|
||||
// 4. 处理内置资源包
|
||||
if (processBundleDepends)
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
manifest.Initialize();
|
||||
|
||||
// 创建补丁清单文本文件
|
||||
ProcessBuiltinBundleDependency(context, manifest);
|
||||
}
|
||||
|
||||
|
||||
// 创建资源清单文本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -66,18 +75,18 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单二进制文件
|
||||
// 创建资源清单二进制文件
|
||||
string packageHash;
|
||||
string packagePath;
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||
ManifestTools.SerializeToBinary(packagePath, manifest);
|
||||
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,7 +94,7 @@ namespace YooAsset.Editor
|
||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||
}
|
||||
|
||||
// 创建补丁清单版本文件
|
||||
// 创建资源清单版本文件
|
||||
{
|
||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||
@@ -97,7 +106,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
ManifestContext manifestContext = new ManifestContext();
|
||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestRestoreServices);
|
||||
context.SetContextObject(manifestContext);
|
||||
}
|
||||
}
|
||||
@@ -303,15 +312,34 @@ namespace YooAsset.Editor
|
||||
// 注意:如果是可编程构建管线,需要补充内置资源包
|
||||
// 注意:该步骤依赖前面的操作!
|
||||
var buildResultContext = context.TryGetContextObject<TaskBuilding_SBP.BuildResultContext>();
|
||||
|
||||
if (buildResultContext != null)
|
||||
{
|
||||
// 注意:初始化资源清单建立引用关系
|
||||
ManifestTools.InitManifest(manifest);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.BuiltinShadersBundleName);
|
||||
ProcessBuiltinBundleReference(context, manifest, buildResultContext.MonoScriptsBundleName);
|
||||
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(BuildContext context, PackageManifest manifest, string builtinBundleName)
|
||||
private void ProcessBuiltinBundleReference(PackageManifest manifest, string builtinBundleName)
|
||||
{
|
||||
if (string.IsNullOrEmpty(builtinBundleName))
|
||||
return;
|
||||
|
||||
@@ -32,6 +32,7 @@ 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.AutoCollectShaders = buildMapContext.Command.AutoCollectShaders;
|
||||
@@ -43,13 +44,17 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
||||
buildReport.Summary.EncryptionClassName = buildParameters.EncryptionServices == null ? "null" : buildParameters.EncryptionServices.GetType().FullName;
|
||||
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.CompressOption = builtinBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = builtinBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = builtinBuildParameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.ReplaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||
}
|
||||
else if (buildParameters is ScriptableBuildParameters)
|
||||
{
|
||||
@@ -57,6 +62,7 @@ namespace YooAsset.Editor
|
||||
buildReport.Summary.CompressOption = scriptableBuildParameters.CompressOption;
|
||||
buildReport.Summary.DisableWriteTypeTree = scriptableBuildParameters.DisableWriteTypeTree;
|
||||
buildReport.Summary.IgnoreTypeTreeChanges = scriptableBuildParameters.IgnoreTypeTreeChanges;
|
||||
buildReport.Summary.ReplaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||
buildReport.Summary.WriteLinkXML = scriptableBuildParameters.WriteLinkXML;
|
||||
buildReport.Summary.CacheServerHost = scriptableBuildParameters.CacheServerHost;
|
||||
buildReport.Summary.CacheServerPort = scriptableBuildParameters.CacheServerPort;
|
||||
|
||||
@@ -44,9 +44,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
bundleInfo.PackageUnityHash = GetUnityHash(bundleInfo, context);
|
||||
bundleInfo.PackageUnityCRC = GetUnityCRC(bundleInfo, context);
|
||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, buildParametersContext);
|
||||
bundleInfo.PackageFileHash = GetBundleFileHash(bundleInfo, context);
|
||||
bundleInfo.PackageFileCRC = GetBundleFileCRC(bundleInfo, context);
|
||||
bundleInfo.PackageFileSize = GetBundleFileSize(bundleInfo, context);
|
||||
}
|
||||
|
||||
// 4.更新补丁包输出的文件路径
|
||||
@@ -62,8 +62,8 @@ namespace YooAsset.Editor
|
||||
|
||||
protected abstract string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext);
|
||||
protected abstract string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
protected abstract long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context);
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,8 @@ namespace YooAsset.Editor
|
||||
// 开始构建
|
||||
string pipelineOutputDirectory = buildParametersContext.GetPipelineOutputDirectory();
|
||||
BuildAssetBundleOptions buildOptions = builtinBuildParameters.GetBundleBuildOptions();
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, buildMapContext.GetPipelineBuilds(), buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
var bundleBuilds = buildMapContext.GetPipelineBuilds(builtinBuildParameters.ReplaceAssetPathWithAddress);
|
||||
AssetBundleManifest unityManifest = BuildPipeline.BuildAssetBundles(pipelineOutputDirectory, bundleBuilds, buildOptions, buildParametersContext.Parameters.BuildTarget);
|
||||
if (unityManifest == null)
|
||||
{
|
||||
string message = BuildLogger.GetErrorMessage(ErrorCode.UnityEngineBuildFailed, "UnityEngine build failed !");
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 69f62f6b4185d06498f96aa272e9b926
|
||||
guid: 8fe3d00b03dc9c64a96b7acfdf99b54c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -11,7 +11,10 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(true, true, context);
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var builtinBuildParameters = buildParametersContext.Parameters as BuiltinBuildParameters;
|
||||
bool replaceAssetPathWithAddress = builtinBuildParameters.ReplaceAssetPathWithAddress;
|
||||
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -40,17 +40,17 @@ namespace YooAsset.Editor
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
|
||||
@@ -12,6 +12,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||
|
||||
/// <summary>
|
||||
/// 从文件头里剥离Unity版本信息
|
||||
/// </summary>
|
||||
public bool StripUnityVersion = false;
|
||||
|
||||
/// <summary>
|
||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||
/// </summary>
|
||||
@@ -22,6 +27,12 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool IgnoreTypeTreeChanges = true;
|
||||
|
||||
/// <summary>
|
||||
/// 使用可寻址地址代替资源路径
|
||||
/// 说明:开启此项可以节省运行时清单占用的内存!
|
||||
/// </summary>
|
||||
public bool ReplaceAssetPathWithAddress = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取内置构建管线的构建选项
|
||||
@@ -41,6 +52,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;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, false, context);
|
||||
CreateManifestFile(false, true, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -19,16 +19,16 @@ namespace YooAsset.Editor
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return GetFilePathTempHash(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return "00000000"; //8位
|
||||
return 0;
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return GetBundleTempSize(bundleInfo);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 94254ab8e4496214884c11a891c131c6
|
||||
guid: 563771ecaff17ee498b5fda7c1132e62
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
@@ -9,7 +9,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(false, true, context);
|
||||
CreateManifestFile(false, true, false, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -15,27 +15,55 @@ namespace YooAsset.Editor
|
||||
|
||||
protected override string GetUnityHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
|
||||
if (rawFileBuildParameters.IncludePathInHash)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return GetFileMD5IncludePath(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
}
|
||||
protected override uint GetUnityCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var rawFileBuildParameters = buildParametersContext.Parameters as RawFileBuildParameters;
|
||||
if (rawFileBuildParameters.IncludePathInHash)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return GetFileMD5IncludePath(filePath);
|
||||
}
|
||||
else
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
}
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
}
|
||||
|
||||
private string GetFileMD5IncludePath(string filePath)
|
||||
{
|
||||
string pathHash = HashUtility.StringMD5(filePath.ToLowerInvariant());
|
||||
string contentHash = HashUtility.FileMD5(filePath);
|
||||
string combined = pathHash + contentHash;
|
||||
return HashUtility.StringMD5(combined);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,5 +6,9 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class RawFileBuildParameters : BuildParameters
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件哈希值计算包含路径信息
|
||||
/// </summary>
|
||||
public bool IncludePathInHash = false;
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
||||
new TaskCreateReport_RFBP(),
|
||||
new TaskCreatePackage_RFBP(),
|
||||
new TaskCopyBuildinFiles_RFBP(),
|
||||
new TaskCreateCatalog_RFBP()
|
||||
};
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ namespace YooAsset.Editor
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
|
||||
// 构建内容
|
||||
var buildContent = new BundleBuildContent(buildMapContext.GetPipelineBuilds());
|
||||
var bundleBuilds = buildMapContext.GetPipelineBuilds(scriptableBuildParameters.ReplaceAssetPathWithAddress);
|
||||
var buildContent = new BundleBuildContent(bundleBuilds);
|
||||
|
||||
// 开始构建
|
||||
IBundleBuildResults buildResults;
|
||||
|
||||
@@ -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:
|
||||
@@ -13,7 +13,10 @@ namespace YooAsset.Editor
|
||||
|
||||
void IBuildTask.Run(BuildContext context)
|
||||
{
|
||||
CreateManifestFile(true, true, context);
|
||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||
var scriptableBuildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||
bool replaceAssetPathWithAddress = scriptableBuildParameters.ReplaceAssetPathWithAddress;
|
||||
CreateManifestFile(true, true, replaceAssetPathWithAddress, context);
|
||||
}
|
||||
|
||||
protected override string[] GetBundleDepends(BuildContext context, string bundleName)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -40,17 +40,17 @@ namespace YooAsset.Editor
|
||||
throw new Exception(message);
|
||||
}
|
||||
}
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override string GetBundleFileHash(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileMD5(filePath);
|
||||
}
|
||||
protected override string GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override uint GetBundleFileCRC(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return HashUtility.FileCRC32(filePath);
|
||||
return HashUtility.FileCRC32Value(filePath);
|
||||
}
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildParametersContext buildParametersContext)
|
||||
protected override long GetBundleFileSize(BuildBundleInfo bundleInfo, BuildContext context)
|
||||
{
|
||||
string filePath = bundleInfo.PackageSourceFilePath;
|
||||
return FileUtility.GetFileSize(filePath);
|
||||
|
||||
@@ -14,16 +14,32 @@ 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 ReplaceAssetPathWithAddress = false;
|
||||
|
||||
/// <summary>
|
||||
/// 自动建立资源对象对图集的依赖关系
|
||||
/// </summary>
|
||||
public bool TrackSpriteAtlasDependencies = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 生成代码防裁剪配置
|
||||
@@ -70,8 +86,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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5280dfac6a481ee429c769ba5688c9d2
|
||||
guid: e2e1fae9b05cc554e9ebfee01f2b9333
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,135 @@
|
||||
#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
|
||||
{
|
||||
[BuildPipelineAttribute(nameof(EBuildPipeline.BuiltinBuildPipeline))]
|
||||
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
protected TemplateContainer Root;
|
||||
protected TextField _buildOutputField;
|
||||
protected TextField _buildVersionField;
|
||||
protected PopupField<Type> _encryptionServicesField;
|
||||
protected PopupField<Type> _manifestProcessServicesField;
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _compressionField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
public override void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<BuiltinBuildPipelineViewer>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
SetBuildOutputField(_buildOutputField);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
SetBuildVersionField(_buildVersionField);
|
||||
|
||||
// 服务类
|
||||
var popupContainer = Root.Q("PopupContainer");
|
||||
_encryptionServicesField = CreateEncryptionServicesField(popupContainer);
|
||||
_manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
|
||||
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
|
||||
|
||||
// 压缩方式选项
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
SetCompressionField(_compressionField);
|
||||
|
||||
// 输出文件名称样式
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
SetClearBuildCacheToggle(_clearBuildCacheToggle);
|
||||
|
||||
// 使用资源依赖数据库
|
||||
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
SetUseAssetDependencyDBToggle(_useAssetDependencyDBToggle);
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] Packaging has been canceled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
|
||||
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -4,7 +4,7 @@
|
||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||
<ui:VisualElement name="EncryptionContainer" style="height: 24px;" />
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 86d0df373d425b449a3bbc42b4b2e5bb
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,57 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class BuiltinBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public BuiltinBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.BuiltinBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
|
||||
BuiltinBuildParameters buildParameters = new BuiltinBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
BuiltinBuildPipeline pipeline = new BuiltinBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 275b87293edc6634f9d72387851dbbdf
|
||||
guid: 33b6cb215b1d7bb4888cb3455b500399
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
@@ -0,0 +1,85 @@
|
||||
#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
|
||||
{
|
||||
[BuildPipelineAttribute(nameof(EBuildPipeline.EditorSimulateBuildPipeline))]
|
||||
internal class EditorSimulateBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
protected TemplateContainer Root;
|
||||
protected TextField _buildOutputField;
|
||||
protected TextField _buildVersionField;
|
||||
|
||||
public override void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<EditorSimulateBuildPipelineViewer>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
SetBuildOutputField(_buildOutputField);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
SetBuildVersionField(_buildVersionField);
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] Packaging has been canceled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
|
||||
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
|
||||
EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 90cc4546b2b8afe4e8c864c132a999a9
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,70 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class EditorSimulateBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public EditorSimulateBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
var compressionField = Root.Q<EnumField>("Compression");
|
||||
UIElementsTools.SetElementVisible(compressionField, false);
|
||||
|
||||
var encryptionContainer = Root.Q<VisualElement>("EncryptionContainer");
|
||||
UIElementsTools.SetElementVisible(encryptionContainer, false);
|
||||
|
||||
var fileNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
UIElementsTools.SetElementVisible(fileNameStyleField, false);
|
||||
|
||||
var copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
UIElementsTools.SetElementVisible(copyBuildinFileOptionField, false);
|
||||
|
||||
var copyBuildinFileParamField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
UIElementsTools.SetElementVisible(copyBuildinFileParamField, false);
|
||||
|
||||
var clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
UIElementsTools.SetElementVisible(clearBuildCacheToggle, false);
|
||||
|
||||
var useAssetDependencyToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
UIElementsTools.SetElementVisible(useAssetDependencyToggle, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
|
||||
EditorSimulateBuildParameters buildParameters = new EditorSimulateBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.VirtualBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
EditorSimulateBuildPipeline pipeline = new EditorSimulateBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56adb3acd233fe5468af213a4c41de6a
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,127 @@
|
||||
#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
|
||||
{
|
||||
[BuildPipelineAttribute(nameof(EBuildPipeline.RawFileBuildPipeline))]
|
||||
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
protected TemplateContainer Root;
|
||||
protected TextField _buildOutputField;
|
||||
protected TextField _buildVersionField;
|
||||
protected PopupField<Type> _encryptionServicesField;
|
||||
protected PopupField<Type> _manifestProcessServicesField;
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
public override void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<RawfileBuildpipelineViewer>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
SetBuildOutputField(_buildOutputField);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
SetBuildVersionField(_buildVersionField);
|
||||
|
||||
// 加密方法
|
||||
var popupContainer = Root.Q("PopupContainer");
|
||||
_encryptionServicesField = CreateEncryptionServicesField(popupContainer);
|
||||
_manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
|
||||
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
|
||||
|
||||
// 输出文件名称样式
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
SetClearBuildCacheToggle(_clearBuildCacheToggle);
|
||||
|
||||
// 使用资源依赖数据库
|
||||
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
SetUseAssetDependencyDBToggle(_useAssetDependencyDBToggle);
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] Packaging has been canceled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
|
||||
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -0,0 +1,10 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8ed3387ab250c814e9797164c9a4b89a
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||
@@ -1,56 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class RawfileBuildpipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public RawfileBuildpipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.RawFileBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
var compressionField = Root.Q<EnumField>("Compression");
|
||||
UIElementsTools.SetElementVisible(compressionField, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
|
||||
RawFileBuildParameters buildParameters = new RawFileBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.RawBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
RawFileBuildPipeline pipeline = new RawFileBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: be39d027dec0b2f41ab1dba7effb1a9c
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,157 @@
|
||||
#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
|
||||
{
|
||||
[BuildPipelineAttribute(nameof(EBuildPipeline.ScriptableBuildPipeline))]
|
||||
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
protected TemplateContainer Root;
|
||||
protected TextField _buildOutputField;
|
||||
protected TextField _buildVersionField;
|
||||
protected PopupField<Type> _encryptionServicesField;
|
||||
protected PopupField<Type> _manifestProcessServicesField;
|
||||
protected PopupField<Type> _manifestRestoreServicesField;
|
||||
protected EnumField _compressionField;
|
||||
protected EnumField _outputNameStyleField;
|
||||
protected EnumField _copyBuildinFileOptionField;
|
||||
protected TextField _copyBuildinFileTagsField;
|
||||
protected Toggle _clearBuildCacheToggle;
|
||||
protected Toggle _useAssetDependencyDBToggle;
|
||||
|
||||
public override void CreateView(VisualElement parent)
|
||||
{
|
||||
// 加载布局文件
|
||||
var visualAsset = UxmlLoader.LoadWindowUXML<ScriptableBuildPipelineViewer>();
|
||||
if (visualAsset == null)
|
||||
return;
|
||||
|
||||
Root = visualAsset.CloneTree();
|
||||
Root.style.flexGrow = 1f;
|
||||
parent.Add(Root);
|
||||
|
||||
// 输出目录
|
||||
_buildOutputField = Root.Q<TextField>("BuildOutput");
|
||||
SetBuildOutputField(_buildOutputField);
|
||||
|
||||
// 构建版本
|
||||
_buildVersionField = Root.Q<TextField>("BuildVersion");
|
||||
SetBuildVersionField(_buildVersionField);
|
||||
|
||||
// 加密方法
|
||||
var popupContainer = Root.Q("PopupContainer");
|
||||
_encryptionServicesField = CreateEncryptionServicesField(popupContainer);
|
||||
_manifestProcessServicesField = CreateManifestProcessServicesField(popupContainer);
|
||||
_manifestRestoreServicesField = CreateManifestRestoreServicesField(popupContainer);
|
||||
|
||||
// 压缩方式选项
|
||||
_compressionField = Root.Q<EnumField>("Compression");
|
||||
SetCompressionField(_compressionField);
|
||||
|
||||
// 输出文件名称样式
|
||||
_outputNameStyleField = Root.Q<EnumField>("FileNameStyle");
|
||||
SetOutputNameStyleField(_outputNameStyleField);
|
||||
|
||||
// 首包文件拷贝参数
|
||||
_copyBuildinFileTagsField = Root.Q<TextField>("CopyBuildinFileParam");
|
||||
SetCopyBuildinFileTagsField(_copyBuildinFileTagsField);
|
||||
SetCopyBuildinFileTagsVisible(_copyBuildinFileTagsField);
|
||||
|
||||
// 首包文件拷贝选项
|
||||
_copyBuildinFileOptionField = Root.Q<EnumField>("CopyBuildinFileOption");
|
||||
SetCopyBuildinFileOptionField(_copyBuildinFileOptionField, _copyBuildinFileTagsField);
|
||||
|
||||
// 清理构建缓存
|
||||
_clearBuildCacheToggle = Root.Q<Toggle>("ClearBuildCache");
|
||||
SetClearBuildCacheToggle(_clearBuildCacheToggle);
|
||||
|
||||
// 使用资源依赖数据库
|
||||
_useAssetDependencyDBToggle = Root.Q<Toggle>("UseAssetDependency");
|
||||
SetUseAssetDependencyDBToggle(_useAssetDependencyDBToggle);
|
||||
|
||||
// 构建按钮
|
||||
var buildButton = Root.Q<Button>("Build");
|
||||
buildButton.clicked += BuildButton_clicked;
|
||||
}
|
||||
private void BuildButton_clicked()
|
||||
{
|
||||
if (EditorUtility.DisplayDialog("Info", $"Start building resource package [{PackageName}]!", "Yes", "No"))
|
||||
{
|
||||
EditorTools.ClearUnityConsole();
|
||||
EditorApplication.delayCall += ExecuteBuild;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("[Build] Packaging has been canceled.");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected virtual void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, PipelineName);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, PipelineName);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, PipelineName);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, PipelineName);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, PipelineName);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, PipelineName);
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = PipelineName.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = _buildVersionField.value;
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||
buildParameters.ManifestProcessServices = CreateManifestProcessServicesInstance();
|
||||
buildParameters.ManifestRestoreServices = CreateManifestRestoreServicesInstance();
|
||||
buildParameters.BuiltinShadersBundleName = GetBuiltinShaderBundleName();
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
protected string GetBuiltinShaderBundleName()
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Mono脚本的资源包名称
|
||||
/// </summary>
|
||||
protected string GetMonoScriptsBundleName()
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateMonosPackRuleResult();
|
||||
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<ui:VisualElement name="BuildContainer">
|
||||
<ui:TextField picking-mode="Ignore" label="Build Output" name="BuildOutput" />
|
||||
<ui:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
||||
<ui:VisualElement name="PopupContainer" style="flex-grow: 1;" />
|
||||
<uie:EnumField label="Compression" value="Center" name="Compression" />
|
||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||
<ui:TextField picking-mode="Ignore" label="Copy Buildin File Param" name="CopyBuildinFileParam" />
|
||||
<ui:VisualElement name="ExtensionContainer" />
|
||||
<ui:Button text="Click Build" display-tooltip-when-elided="true" name="Build" style="height: 50px; background-color: rgb(40, 106, 42); margin-top: 10px;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
||||
@@ -1,70 +0,0 @@
|
||||
#if UNITY_2019_4_OR_NEWER
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEditor.UIElements;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class ScriptableBuildPipelineViewer : BuildPipelineViewerBase
|
||||
{
|
||||
public ScriptableBuildPipelineViewer(string packageName, BuildTarget buildTarget, VisualElement parent)
|
||||
: base(packageName, EBuildPipeline.ScriptableBuildPipeline, buildTarget, parent)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行构建
|
||||
/// </summary>
|
||||
protected override void ExecuteBuild()
|
||||
{
|
||||
var fileNameStyle = AssetBundleBuilderSetting.GetPackageFileNameStyle(PackageName, BuildPipeline);
|
||||
var buildinFileCopyOption = AssetBundleBuilderSetting.GetPackageBuildinFileCopyOption(PackageName, BuildPipeline);
|
||||
var buildinFileCopyParams = AssetBundleBuilderSetting.GetPackageBuildinFileCopyParams(PackageName, BuildPipeline);
|
||||
var compressOption = AssetBundleBuilderSetting.GetPackageCompressOption(PackageName, BuildPipeline);
|
||||
var clearBuildCache = AssetBundleBuilderSetting.GetPackageClearBuildCache(PackageName, BuildPipeline);
|
||||
var useAssetDependencyDB = AssetBundleBuilderSetting.GetPackageUseAssetDependencyDB(PackageName, BuildPipeline);
|
||||
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||
|
||||
ScriptableBuildParameters buildParameters = new ScriptableBuildParameters();
|
||||
buildParameters.BuildOutputRoot = AssetBundleBuilderHelper.GetDefaultBuildOutputRoot();
|
||||
buildParameters.BuildinFileRoot = AssetBundleBuilderHelper.GetStreamingAssetsRoot();
|
||||
buildParameters.BuildPipeline = BuildPipeline.ToString();
|
||||
buildParameters.BuildBundleType = (int)EBuildBundleType.AssetBundle;
|
||||
buildParameters.BuildTarget = BuildTarget;
|
||||
buildParameters.PackageName = PackageName;
|
||||
buildParameters.PackageVersion = GetPackageVersion();
|
||||
buildParameters.EnableSharePackRule = true;
|
||||
buildParameters.VerifyBuildingResult = true;
|
||||
buildParameters.FileNameStyle = fileNameStyle;
|
||||
buildParameters.BuildinFileCopyOption = buildinFileCopyOption;
|
||||
buildParameters.BuildinFileCopyParams = buildinFileCopyParams;
|
||||
buildParameters.CompressOption = compressOption;
|
||||
buildParameters.ClearBuildCacheFiles = clearBuildCache;
|
||||
buildParameters.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
buildParameters.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||
buildParameters.EncryptionServices = CreateEncryptionInstance();
|
||||
|
||||
ScriptableBuildPipeline pipeline = new ScriptableBuildPipeline();
|
||||
var buildResult = pipeline.Run(buildParameters, true);
|
||||
if (buildResult.Success)
|
||||
EditorUtility.RevealInFinder(buildResult.OutputPackageDirectory);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内置着色器资源包名称
|
||||
/// 注意:和自动收集的着色器资源包名保持一致!
|
||||
/// </summary>
|
||||
private string GetBuiltinShaderBundleName()
|
||||
{
|
||||
var uniqueBundleName = AssetBundleCollectorSettingData.Setting.UniqueBundleName;
|
||||
var packRuleResult = DefaultPackRule.CreateShadersPackRuleResult();
|
||||
return packRuleResult.GetBundleName(PackageName, uniqueBundleName);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -139,10 +139,17 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public List<CollectAssetInfo> GetAllCollectAssets(CollectCommand command, AssetBundleCollectorGroup group)
|
||||
{
|
||||
// 注意:模拟构建模式下只收集主资源
|
||||
if (command.SimulateBuild)
|
||||
bool ignoreStaticCollector = command.IsFlagSet(ECollectFlags.IgnoreStaticCollector);
|
||||
if (ignoreStaticCollector)
|
||||
{
|
||||
if (CollectorType != ECollectorType.MainAssetCollector)
|
||||
if (CollectorType == ECollectorType.StaticAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
bool ignoreDependCollector = command.IsFlagSet(ECollectFlags.IgnoreDependCollector);
|
||||
if (ignoreDependCollector)
|
||||
{
|
||||
if (CollectorType == ECollectorType.DependAssetCollector)
|
||||
return new List<CollectAssetInfo>();
|
||||
}
|
||||
|
||||
@@ -152,8 +159,10 @@ namespace YooAsset.Editor
|
||||
List<string> findAssets = new List<string>();
|
||||
if (AssetDatabase.IsValidFolder(CollectPath))
|
||||
{
|
||||
string collectDirectory = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(EAssetSearchType.All, collectDirectory);
|
||||
IFilterRule filterRuleInstance = AssetBundleCollectorSettingData.GetFilterRuleInstance(FilterRuleName);
|
||||
string findAssetType = filterRuleInstance.FindAssetType;
|
||||
string searchFolder = CollectPath;
|
||||
string[] findResult = EditorTools.FindAssets(findAssetType, searchFolder);
|
||||
findAssets.AddRange(findResult);
|
||||
}
|
||||
else
|
||||
@@ -259,15 +268,18 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||
{
|
||||
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
||||
tags.AddRange(temper);
|
||||
return tags;
|
||||
List<string> result = EditorTools.StringToStringList(AssetTags, ';');
|
||||
if (CollectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
List<string> temps = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||
result.AddRange(temps);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||
{
|
||||
// 注意:模拟构建模式下不需要收集依赖资源
|
||||
if (command.SimulateBuild)
|
||||
bool ignoreGetDependencies = command.IsFlagSet(ECollectFlags.IgnoreGetDependencies);
|
||||
if (ignoreGetDependencies)
|
||||
return new List<AssetInfo>();
|
||||
|
||||
string[] depends = command.AssetDependency.GetDependencies(mainAssetPath, true);
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
public class AssetBundleCollectorConfig
|
||||
{
|
||||
public const string ConfigVersion = "v2.1";
|
||||
public const string ConfigVersion = "v2025.8.28";
|
||||
|
||||
public const string XmlVersion = "Version";
|
||||
public const string XmlCommon = "Common";
|
||||
@@ -23,6 +23,7 @@ namespace YooAsset.Editor
|
||||
public const string XmlPackageName = "PackageName";
|
||||
public const string XmlPackageDesc = "PackageDesc";
|
||||
public const string XmlEnableAddressable = "AutoAddressable";
|
||||
public const string XmlSupportExtensionless = "SupportExtensionless";
|
||||
public const string XmlLocationToLower = "LocationToLower";
|
||||
public const string XmlIncludeAssetGUID = "IncludeAssetGUID";
|
||||
public const string XmlIgnoreRuleName = "IgnoreRuleName";
|
||||
@@ -99,6 +100,7 @@ namespace YooAsset.Editor
|
||||
package.PackageName = packageElement.GetAttribute(XmlPackageName);
|
||||
package.PackageDesc = packageElement.GetAttribute(XmlPackageDesc);
|
||||
package.EnableAddressable = packageElement.GetAttribute(XmlEnableAddressable) == "True" ? true : false;
|
||||
package.SupportExtensionless = packageElement.GetAttribute(XmlSupportExtensionless) == "True" ? true : false;
|
||||
package.LocationToLower = packageElement.GetAttribute(XmlLocationToLower) == "True" ? true : false;
|
||||
package.IncludeAssetGUID = packageElement.GetAttribute(XmlIncludeAssetGUID) == "True" ? true : false;
|
||||
package.IgnoreRuleName = packageElement.GetAttribute(XmlIgnoreRuleName);
|
||||
@@ -211,6 +213,7 @@ namespace YooAsset.Editor
|
||||
packageElement.SetAttribute(XmlPackageName, package.PackageName);
|
||||
packageElement.SetAttribute(XmlPackageDesc, package.PackageDesc);
|
||||
packageElement.SetAttribute(XmlEnableAddressable, package.EnableAddressable.ToString());
|
||||
packageElement.SetAttribute(XmlSupportExtensionless, package.SupportExtensionless.ToString());
|
||||
packageElement.SetAttribute(XmlLocationToLower, package.LocationToLower.ToString());
|
||||
packageElement.SetAttribute(XmlIncludeAssetGUID, package.IncludeAssetGUID.ToString());
|
||||
packageElement.SetAttribute(XmlIgnoreRuleName, package.IgnoreRuleName);
|
||||
@@ -275,6 +278,23 @@ namespace YooAsset.Editor
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
// v2.1 -> v2025.8.28
|
||||
if (configVersion == "v2.1")
|
||||
{
|
||||
// 读取包裹配置
|
||||
var packageNodeList = root.GetElementsByTagName(XmlPackage);
|
||||
foreach (var packageNode in packageNodeList)
|
||||
{
|
||||
XmlElement packageElement = packageNode as XmlElement;
|
||||
if (packageElement.HasAttribute(XmlSupportExtensionless) == false)
|
||||
packageElement.SetAttribute(XmlSupportExtensionless, "True");
|
||||
}
|
||||
|
||||
// 更新版本
|
||||
root.SetAttribute(XmlVersion, "v2025.8.28");
|
||||
return UpdateXmlConfig(xmlDoc);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableAddressable = false;
|
||||
|
||||
/// <summary>
|
||||
/// 支持无后缀名的资源定位地址
|
||||
/// </summary>
|
||||
public bool SupportExtensionless = true;
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
|
||||
@@ -111,6 +111,7 @@ namespace YooAsset.Editor
|
||||
command.UniqueBundleName = UniqueBundleName;
|
||||
command.UseAssetDependencyDB = useAssetDependencyDB;
|
||||
command.EnableAddressable = package.EnableAddressable;
|
||||
command.SupportExtensionless = package.SupportExtensionless;
|
||||
command.LocationToLower = package.LocationToLower;
|
||||
command.IncludeAssetGUID = package.IncludeAssetGUID;
|
||||
command.AutoCollectShaders = package.AutoCollectShaders;
|
||||
|
||||
@@ -265,7 +265,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private static string GetRuleDisplayName(string name, Type type)
|
||||
{
|
||||
var attribute = DisplayNameAttributeHelper.GetAttribute<DisplayNameAttribute>(type);
|
||||
var attribute = EditorTools.GetAttribute<DisplayNameAttribute>(type);
|
||||
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||
return attribute.DisplayName;
|
||||
else
|
||||
|
||||
@@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
||||
|
||||
private VisualElement _setting2Container;
|
||||
private Toggle _enableAddressableToogle;
|
||||
private Toggle _supportExtensionlessToogle;
|
||||
private Toggle _locationToLowerToogle;
|
||||
private Toggle _includeAssetGUIDToogle;
|
||||
private Toggle _autoCollectShadersToogle;
|
||||
@@ -131,6 +132,17 @@ namespace YooAsset.Editor
|
||||
RefreshWindow();
|
||||
}
|
||||
});
|
||||
_supportExtensionlessToogle = root.Q<Toggle>("SupportExtensionless");
|
||||
_supportExtensionlessToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
if (selectPackage != null)
|
||||
{
|
||||
selectPackage.SupportExtensionless = evt.newValue;
|
||||
AssetBundleCollectorSettingData.ModifyPackage(selectPackage);
|
||||
RefreshWindow();
|
||||
}
|
||||
});
|
||||
_locationToLowerToogle = root.Q<Toggle>("LocationToLower");
|
||||
_locationToLowerToogle.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
@@ -224,6 +236,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 包裹名称
|
||||
_packageNameTxt = root.Q<TextField>("PackageName");
|
||||
_packageNameTxt.isDelayed = true;
|
||||
_packageNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -237,6 +250,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 包裹备注
|
||||
_packageDescTxt = root.Q<TextField>("PackageDesc");
|
||||
_packageDescTxt.isDelayed = true;
|
||||
_packageDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -274,6 +288,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组名称
|
||||
_groupNameTxt = root.Q<TextField>("GroupName");
|
||||
_groupNameTxt.isDelayed = true;
|
||||
_groupNameTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -288,6 +303,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组备注
|
||||
_groupDescTxt = root.Q<TextField>("GroupDesc");
|
||||
_groupDescTxt.isDelayed = true;
|
||||
_groupDescTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -302,6 +318,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 分组的资源标签
|
||||
_groupTagsTxt = root.Q<TextField>("GroupTags");
|
||||
_groupTagsTxt.isDelayed = true;
|
||||
_groupTagsTxt.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
var selectPackage = _packageListView.selectedItem as AssetBundleCollectorPackage;
|
||||
@@ -487,6 +504,7 @@ namespace YooAsset.Editor
|
||||
_packageSettingsButton.SetEnabled(true);
|
||||
_packageSettingsButton.text = $"{packageSettingName} ({selectPackage.PackageName})";
|
||||
_enableAddressableToogle.SetValueWithoutNotify(selectPackage.EnableAddressable);
|
||||
_supportExtensionlessToogle.SetValueWithoutNotify(selectPackage.SupportExtensionless);
|
||||
_locationToLowerToogle.SetValueWithoutNotify(selectPackage.LocationToLower);
|
||||
_includeAssetGUIDToogle.SetValueWithoutNotify(selectPackage.IncludeAssetGUID);
|
||||
_autoCollectShadersToogle.SetValueWithoutNotify(selectPackage.AutoCollectShaders);
|
||||
@@ -762,6 +780,7 @@ namespace YooAsset.Editor
|
||||
elementTop.Add(objectField);
|
||||
var label = objectField.Q<Label>();
|
||||
label.style.minWidth = 63;
|
||||
UIElementsTools.SetObjectFieldShowPath(objectField);
|
||||
}
|
||||
|
||||
// Bottom VisualElement
|
||||
@@ -803,6 +822,7 @@ namespace YooAsset.Editor
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField0";
|
||||
textField.label = "User Data";
|
||||
textField.isDelayed = true;
|
||||
textField.style.width = 200;
|
||||
elementBottom.Add(textField);
|
||||
var label = textField.Q<Label>();
|
||||
@@ -812,6 +832,7 @@ namespace YooAsset.Editor
|
||||
var textField = new TextField();
|
||||
textField.name = "TextField1";
|
||||
textField.label = "Asset Tags";
|
||||
textField.isDelayed = true;
|
||||
textField.style.width = 100;
|
||||
textField.style.marginLeft = 20;
|
||||
textField.style.flexGrow = 1;
|
||||
@@ -830,7 +851,7 @@ namespace YooAsset.Editor
|
||||
var foldout = new Foldout();
|
||||
foldout.name = "Foldout1";
|
||||
foldout.value = false;
|
||||
foldout.text = "Main Assets";
|
||||
foldout.text = "Assets";
|
||||
elementFoldout.Add(foldout);
|
||||
}
|
||||
|
||||
@@ -851,8 +872,6 @@ namespace YooAsset.Editor
|
||||
|
||||
var collector = selectGroup.Collectors[index];
|
||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||
if (collectObject != null)
|
||||
collectObject.name = collector.CollectPath;
|
||||
|
||||
// 注意:非主资源收集器的标签栏需要被冻结
|
||||
var textTags = element.Q<TextField>("TextField1");
|
||||
@@ -865,11 +884,9 @@ namespace YooAsset.Editor
|
||||
var foldout = element.Q<Foldout>("Foldout1");
|
||||
foldout.RegisterValueChangedCallback(evt =>
|
||||
{
|
||||
if (evt.newValue)
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
else
|
||||
foldout.Clear();
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
});
|
||||
RefreshFoldoutName(foldout, collector.CollectorType);
|
||||
|
||||
// Remove Button
|
||||
var removeBtn = element.Q<Button>("Button1");
|
||||
@@ -885,13 +902,10 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
||||
objectField1.value.name = collector.CollectPath;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
});
|
||||
UIElementsTools.RefreshObjectFieldShowPath(objectField1);
|
||||
|
||||
// Collector Type
|
||||
var popupField0 = element.Q<PopupField<string>>("PopupField0");
|
||||
@@ -900,10 +914,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.CollectorType = EditorTools.NameToEnum<ECollectorType>(evt.newValue);
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
|
||||
if (collector.CollectorType == ECollectorType.MainAssetCollector)
|
||||
textTags.SetEnabled(true);
|
||||
@@ -922,10 +933,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.AddressRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -938,10 +946,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.PackRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
});
|
||||
|
||||
// Filter Rule
|
||||
@@ -953,10 +958,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
collector.FilterRuleName = evt.newValue.ClassName;
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
if (foldout.value)
|
||||
{
|
||||
RefreshFoldout(foldout, selectGroup, collector);
|
||||
}
|
||||
RefreshFoldoutContent(foldout, selectGroup, collector);
|
||||
});
|
||||
|
||||
// UserData
|
||||
@@ -977,61 +979,101 @@ namespace YooAsset.Editor
|
||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||
});
|
||||
}
|
||||
private void RefreshFoldout(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
private void RefreshFoldoutName(Foldout foldout, ECollectorType collectorType, int elementNumber = -1)
|
||||
{
|
||||
if (collectorType == ECollectorType.MainAssetCollector)
|
||||
{
|
||||
if (elementNumber >= 0)
|
||||
foldout.text = $"Main Assets ({elementNumber})";
|
||||
else
|
||||
foldout.text = $"Main Assets";
|
||||
}
|
||||
else if (collectorType == ECollectorType.StaticAssetCollector)
|
||||
{
|
||||
if (elementNumber >= 0)
|
||||
foldout.text = $"Static Assets ({elementNumber})";
|
||||
else
|
||||
foldout.text = $"Static Assets";
|
||||
}
|
||||
else if (collectorType == ECollectorType.DependAssetCollector)
|
||||
{
|
||||
if (elementNumber >= 0)
|
||||
foldout.text = $"Depend Assets ({elementNumber})";
|
||||
else
|
||||
foldout.text = $"Depend Assets";
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(collectorType.ToString());
|
||||
}
|
||||
}
|
||||
private void RefreshFoldoutContent(Foldout foldout, AssetBundleCollectorGroup group, AssetBundleCollector collector)
|
||||
{
|
||||
RefreshFoldoutName(foldout, collector.CollectorType);
|
||||
|
||||
// 折叠栏不可见
|
||||
if (foldout.value == false)
|
||||
{
|
||||
foldout.Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
// 清空旧元素
|
||||
foldout.Clear();
|
||||
|
||||
// 检测配置是否有效
|
||||
if (collector.IsValid() == false)
|
||||
{
|
||||
collector.CheckConfigError();
|
||||
return;
|
||||
}
|
||||
|
||||
if (collector.CollectorType == ECollectorType.MainAssetCollector || collector.CollectorType == ECollectorType.StaticAssetCollector)
|
||||
List<CollectAssetInfo> collectAssetInfos = null;
|
||||
|
||||
try
|
||||
{
|
||||
List<CollectAssetInfo> collectAssetInfos = null;
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
string packageName = _packageNameTxt.value;
|
||||
var command = new CollectCommand(packageName, ignoreRule);
|
||||
command.SetFlag(ECollectFlags.IgnoreGetDependencies, true);
|
||||
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||
command.EnableAddressable = _enableAddressableToogle.value;
|
||||
command.SupportExtensionless = _supportExtensionlessToogle.value;
|
||||
command.LocationToLower = _locationToLowerToogle.value;
|
||||
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
||||
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
||||
|
||||
try
|
||||
collector.CheckConfigError();
|
||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
|
||||
if (collectAssetInfos != null)
|
||||
{
|
||||
bool showAdress = false;
|
||||
if (_enableAddressableToogle.value && collector.CollectorType == ECollectorType.MainAssetCollector)
|
||||
showAdress = true;
|
||||
|
||||
RefreshFoldoutName(foldout, collector.CollectorType, collectAssetInfos.Count);
|
||||
foreach (var collectAsset in collectAssetInfos)
|
||||
{
|
||||
IIgnoreRule ignoreRule = AssetBundleCollectorSettingData.GetIgnoreRuleInstance(_ignoreRulePopupField.value.ClassName);
|
||||
string packageName = _packageNameTxt.value;
|
||||
var command = new CollectCommand(packageName, ignoreRule);
|
||||
command.SimulateBuild = true;
|
||||
command.UniqueBundleName = _uniqueBundleNameToogle.value;
|
||||
command.UseAssetDependencyDB = true;
|
||||
command.EnableAddressable = _enableAddressableToogle.value;
|
||||
command.LocationToLower = _locationToLowerToogle.value;
|
||||
command.IncludeAssetGUID = _includeAssetGUIDToogle.value;
|
||||
command.AutoCollectShaders = _autoCollectShadersToogle.value;
|
||||
VisualElement elementRow = new VisualElement();
|
||||
elementRow.style.flexDirection = FlexDirection.Row;
|
||||
foldout.Add(elementRow);
|
||||
|
||||
collector.CheckConfigError();
|
||||
collectAssetInfos = collector.GetAllCollectAssets(command, group);
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
Debug.LogError(e.ToString());
|
||||
}
|
||||
string showInfo = collectAsset.AssetInfo.AssetPath;
|
||||
if (showAdress)
|
||||
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
||||
|
||||
if (collectAssetInfos != null)
|
||||
{
|
||||
foreach (var collectAsset in collectAssetInfos)
|
||||
{
|
||||
VisualElement elementRow = new VisualElement();
|
||||
elementRow.style.flexDirection = FlexDirection.Row;
|
||||
foldout.Add(elementRow);
|
||||
|
||||
string showInfo = collectAsset.AssetInfo.AssetPath;
|
||||
if (_enableAddressableToogle.value)
|
||||
showInfo = $"[{collectAsset.Address}] {collectAsset.AssetInfo.AssetPath}";
|
||||
|
||||
var label = new Label();
|
||||
label.text = showInfo;
|
||||
label.style.width = 300;
|
||||
label.style.marginLeft = 0;
|
||||
label.style.flexGrow = 1;
|
||||
elementRow.Add(label);
|
||||
}
|
||||
var label = new Label();
|
||||
label.text = showInfo;
|
||||
label.style.width = 300;
|
||||
label.style.marginLeft = 0;
|
||||
label.style.flexGrow = 1;
|
||||
elementRow.Add(label);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
<ui:Button text="Package Settings" display-tooltip-when-elided="true" name="PackageSettingsButton" />
|
||||
<ui:VisualElement name="PublicContainer2">
|
||||
<ui:Toggle label="Enable Addressable" name="EnableAddressable" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Support Extensionless" name="SupportExtensionless" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Location To Lower" name="LocationToLower" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Include Asset GUID" name="IncludeAssetGUID" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
<ui:Toggle label="Auto Collect Shaders" name="AutoCollectShaders" value="true" style="width: 196px; -unity-text-align: middle-left;" />
|
||||
@@ -29,7 +30,7 @@
|
||||
<ui:VisualElement name="PackageContainer" style="width: 200px; flex-grow: 0; background-color: rgb(67, 67, 67); border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px;">
|
||||
<ui:Label text="Packages" display-tooltip-when-elided="true" name="PackageTitle" style="background-color: rgb(89, 89, 89); -unity-text-align: upper-center; -unity-font-style: bold; border-left-width: 5px; border-right-width: 5px; border-top-width: 5px; border-bottom-width: 5px; font-size: 12px;" />
|
||||
<ui:ListView focusable="true" name="PackageListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:VisualElement name="PackageAddContainer" style="height: 20px; flex-direction: row; justify-content: center; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
@@ -39,7 +40,7 @@
|
||||
<ui:TextField picking-mode="Ignore" label="Package Name" name="PackageName" style="flex-direction: column;" />
|
||||
<ui:TextField picking-mode="Ignore" label="Package Desc" name="PackageDesc" style="flex-direction: column;" />
|
||||
<ui:ListView focusable="true" name="GroupListView" item-height="20" virtualization-method="DynamicHeight" reorderable="true" reorder-mode="Animated" style="flex-grow: 1;" />
|
||||
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center;">
|
||||
<ui:VisualElement name="GroupAddContainer" style="height: 20px; flex-direction: row; justify-content: center; flex-shrink: 0;">
|
||||
<ui:Button text=" - " display-tooltip-when-elided="true" name="RemoveBtn" />
|
||||
<ui:Button text=" + " display-tooltip-when-elided="true" name="AddBtn" />
|
||||
</ui:VisualElement>
|
||||
|
||||
@@ -70,7 +70,11 @@ namespace YooAsset.Editor
|
||||
foreach (var cacheInfoPair in _database)
|
||||
{
|
||||
var assetPath = cacheInfoPair.Key;
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath, AssetPathToGUIDOptions.OnlyExistingAssets);
|
||||
#else
|
||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
#endif
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
{
|
||||
removeList.Add(assetPath);
|
||||
@@ -84,8 +88,8 @@ namespace YooAsset.Editor
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ClearDatabase(true);
|
||||
Debug.LogError($"Failed to load cache database : {ex.Message}");
|
||||
ClearDatabase(true);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -165,7 +169,8 @@ namespace YooAsset.Editor
|
||||
File.Delete(_databaseFilePath);
|
||||
}
|
||||
|
||||
_database.Clear();
|
||||
if (_database != null)
|
||||
_database.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -173,26 +178,42 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public string[] GetDependencies(string assetPath, bool recursive)
|
||||
{
|
||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会包含主资源路径!
|
||||
|
||||
// 注意:机制上不允许存在未收录的资源
|
||||
if (_database.ContainsKey(assetPath) == false)
|
||||
{
|
||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||
}
|
||||
|
||||
var result = new HashSet<string> { assetPath };
|
||||
CollectDependencies(assetPath, result, recursive);
|
||||
var result = new HashSet<string>();
|
||||
|
||||
// 注意:递归收集依赖时,依赖列表中包含主资源
|
||||
if (recursive)
|
||||
result.Add(assetPath);
|
||||
|
||||
// 收集依赖
|
||||
CollectDependencies(assetPath, assetPath, result, recursive);
|
||||
|
||||
// 注意:AssetDatabase.GetDependencies保持一致,将主资源添加到依赖列表最前面
|
||||
return result.ToArray();
|
||||
}
|
||||
private void CollectDependencies(string assetPath, HashSet<string> result, bool recursive)
|
||||
private void CollectDependencies(string parent, string assetPath, HashSet<string> result, bool recursive)
|
||||
{
|
||||
if (_database.TryGetValue(assetPath, out var cacheInfo) == false)
|
||||
{
|
||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||
// 说明:检测是否为丢失引用的资产
|
||||
#if UNITY_2021_3_OR_NEWER
|
||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath, AssetPathToGUIDOptions.OnlyExistingAssets);
|
||||
#else
|
||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
#endif
|
||||
if (string.IsNullOrEmpty(assetGUID))
|
||||
{
|
||||
Debug.LogWarning($"{parent} found missing asset : {assetPath}");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var dependGUID in cacheInfo.DependGUIDs)
|
||||
@@ -213,7 +234,7 @@ namespace YooAsset.Editor
|
||||
|
||||
// 递归收集依赖
|
||||
if (recursive)
|
||||
CollectDependencies(dependAssetPath, result, recursive);
|
||||
CollectDependencies(assetPath, dependAssetPath, result, recursive);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -237,6 +258,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private DependencyInfo CreateDependencyInfo(string assetPath)
|
||||
{
|
||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
||||
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||
var dependGUIDs = new List<string>();
|
||||
|
||||
@@ -1,6 +1,26 @@
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
public enum ECollectFlags
|
||||
{
|
||||
None = 0,
|
||||
|
||||
/// <summary>
|
||||
/// 不收集依赖资源
|
||||
/// </summary>
|
||||
IgnoreGetDependencies = 1 << 0,
|
||||
|
||||
/// <summary>
|
||||
/// 忽略静态收集器
|
||||
/// </summary>
|
||||
IgnoreStaticCollector = 1 << 1,
|
||||
|
||||
/// <summary>
|
||||
/// 忽略依赖收集器
|
||||
/// </summary>
|
||||
IgnoreDependCollector = 1 << 2,
|
||||
}
|
||||
|
||||
public class CollectCommand
|
||||
{
|
||||
/// <summary>
|
||||
@@ -17,7 +37,20 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 模拟构建模式
|
||||
/// </summary>
|
||||
public bool SimulateBuild { set; get; }
|
||||
public bool SimulateBuild
|
||||
{
|
||||
set
|
||||
{
|
||||
SetFlag(ECollectFlags.IgnoreGetDependencies, value);
|
||||
SetFlag(ECollectFlags.IgnoreStaticCollector, value);
|
||||
SetFlag(ECollectFlags.IgnoreDependCollector, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口收集模式
|
||||
/// </summary>
|
||||
public int CollectFlags { set; get; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 资源包名唯一化
|
||||
@@ -34,6 +67,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public bool EnableAddressable { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 支持无后缀名的资源定位地址
|
||||
/// </summary>
|
||||
public bool SupportExtensionless { set; get; }
|
||||
|
||||
/// <summary>
|
||||
/// 资源定位地址大小写不敏感
|
||||
/// </summary>
|
||||
@@ -65,5 +103,24 @@ namespace YooAsset.Editor
|
||||
PackageName = packageName;
|
||||
IgnoreRule = ignoreRule;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置标记位
|
||||
/// </summary>
|
||||
public void SetFlag(ECollectFlags flag, bool isOn)
|
||||
{
|
||||
if (isOn)
|
||||
CollectFlags |= (int)flag; // 开启指定标志位
|
||||
else
|
||||
CollectFlags &= ~(int)flag; // 关闭指定标志位
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询标记位
|
||||
/// </summary>
|
||||
public bool IsFlagSet(ECollectFlags flag)
|
||||
{
|
||||
return (CollectFlags & (int)flag) != 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,13 @@ namespace YooAsset.Editor
|
||||
public interface IFilterRule
|
||||
{
|
||||
/// <summary>
|
||||
/// 是否为收集资源
|
||||
/// 搜寻的资源类型
|
||||
/// 说明:使用引擎方法搜索获取所有资源列表
|
||||
/// </summary>
|
||||
string FindAssetType { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证搜寻的资源是否为收集资源
|
||||
/// </summary>
|
||||
/// <returns>如果收集该资源返回TRUE</returns>
|
||||
bool IsCollectAsset(FilterRuleData data);
|
||||
|
||||
@@ -9,6 +9,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集所有资源")]
|
||||
public class CollectAll : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return true;
|
||||
@@ -18,6 +23,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集场景")]
|
||||
public class CollectScene : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Scene.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
string extension = Path.GetExtension(data.AssetPath);
|
||||
@@ -28,6 +38,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集预制体")]
|
||||
public class CollectPrefab : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Prefab.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".prefab";
|
||||
@@ -37,6 +52,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集精灵类型的纹理")]
|
||||
public class CollectSprite : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Sprite.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
var mainAssetType = AssetDatabase.GetMainAssetTypeAtPath(data.AssetPath);
|
||||
@@ -58,6 +78,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器")]
|
||||
public class CollectShader : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.Shader.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shader";
|
||||
@@ -67,6 +92,11 @@ namespace YooAsset.Editor
|
||||
[DisplayName("收集着色器变种集合")]
|
||||
public class CollectShaderVariants : IFilterRule
|
||||
{
|
||||
public string FindAssetType
|
||||
{
|
||||
get { return EAssetSearchType.All.ToString(); }
|
||||
}
|
||||
|
||||
public bool IsCollectAsset(FilterRuleData data)
|
||||
{
|
||||
return Path.GetExtension(data.AssetPath) == ".shadervariants";
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
||||
/// <summary>
|
||||
/// 忽略的文件类型
|
||||
/// </summary>
|
||||
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".dll", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
public readonly static HashSet<string> IgnoreFileExtensions = new HashSet<string>() { "", ".so", ".cs", ".js", ".boo", ".meta", ".cginc", ".hlsl" };
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,16 +17,25 @@ namespace YooAsset.Editor
|
||||
public const string RawFileExtension = "rawfile";
|
||||
|
||||
/// <summary>
|
||||
/// Unity着色器资源包名称
|
||||
/// 默认的Unity着色器资源包名称
|
||||
/// </summary>
|
||||
public const string ShadersBundleName = "unityshaders";
|
||||
|
||||
/// <summary>
|
||||
/// 默认的Unity脚本资源包名称
|
||||
/// </summary>
|
||||
public const string MonosBundleName = "unitymonos";
|
||||
|
||||
public static PackRuleResult CreateShadersPackRuleResult()
|
||||
{
|
||||
PackRuleResult result = new PackRuleResult(ShadersBundleName, AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
public static PackRuleResult CreateMonosPackRuleResult()
|
||||
{
|
||||
PackRuleResult result = new PackRuleResult(MonosBundleName, AssetBundleFileExtension);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
@@ -15,22 +14,4 @@ namespace YooAsset.Editor
|
||||
this.DisplayName = name;
|
||||
}
|
||||
}
|
||||
|
||||
public static class DisplayNameAttributeHelper
|
||||
{
|
||||
internal static T GetAttribute<T>(Type type) where T : Attribute
|
||||
{
|
||||
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
internal static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||
{
|
||||
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
|
||||
internal static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||
{
|
||||
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -38,21 +38,31 @@ namespace YooAsset.Editor
|
||||
/// 资源包视图
|
||||
/// </summary>
|
||||
BundleView,
|
||||
|
||||
/// <summary>
|
||||
/// 异步操作视图
|
||||
/// </summary>
|
||||
OperationView,
|
||||
}
|
||||
|
||||
|
||||
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||
|
||||
private Label _playerName;
|
||||
private ToolbarButton _playerName;
|
||||
private ToolbarMenu _viewModeMenu;
|
||||
private SliderInt _frameSlider;
|
||||
private DebuggerAssetListViewer _assetListViewer;
|
||||
private DebuggerBundleListViewer _bundleListViewer;
|
||||
private DebuggerOperationListViewer _operationListViewer;
|
||||
|
||||
private EViewMode _viewMode;
|
||||
private string _searchKeyWord;
|
||||
private DebugReport _currentReport;
|
||||
private RemotePlayerSession _currentPlayerSession;
|
||||
|
||||
private double _lastRepaintTime = 0;
|
||||
private int _nextRepaintIndex = -1;
|
||||
private int _lastRepaintIndex = 0;
|
||||
private int _rangeIndex = 0;
|
||||
|
||||
|
||||
@@ -78,13 +88,14 @@ namespace YooAsset.Editor
|
||||
exportBtn.clicked += ExportBtn_clicked;
|
||||
|
||||
// 用户列表菜单
|
||||
_playerName = root.Q<Label>("PlayerName");
|
||||
_playerName = root.Q<ToolbarButton>("PlayerName");
|
||||
_playerName.text = "Editor player";
|
||||
|
||||
// 视口模式菜单
|
||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
||||
_viewModeMenu.menu.AppendAction(EViewMode.OperationView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.OperationView);
|
||||
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||
|
||||
// 搜索栏
|
||||
@@ -111,6 +122,9 @@ namespace YooAsset.Editor
|
||||
|
||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||
frameClear.clicked += OnFrameClear_clicked;
|
||||
|
||||
var recorderToggle = root.Q<ToggleRecord>("FrameRecord");
|
||||
recorderToggle.RegisterValueChangedCallback(OnRecordToggleValueChange);
|
||||
}
|
||||
|
||||
// 加载视图
|
||||
@@ -121,6 +135,10 @@ namespace YooAsset.Editor
|
||||
_bundleListViewer = new DebuggerBundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 加载视图
|
||||
_operationListViewer = new DebuggerOperationListViewer();
|
||||
_operationListViewer.InitViewer();
|
||||
|
||||
// 显示视图
|
||||
_viewMode = EViewMode.AssetView;
|
||||
_assetListViewer.AttachParent(root);
|
||||
@@ -129,8 +147,9 @@ namespace YooAsset.Editor
|
||||
EditorConnection.instance.Initialize();
|
||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||
RemoteEditorConnection.Instance.Initialize();
|
||||
RemoteEditorConnection.Instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -142,9 +161,23 @@ namespace YooAsset.Editor
|
||||
// 远程调试
|
||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor);
|
||||
_playerSessions.Clear();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
// 每间隔1秒绘制一次页面
|
||||
if (EditorApplication.timeSinceStartup - _lastRepaintTime > 1f)
|
||||
{
|
||||
_lastRepaintTime = EditorApplication.timeSinceStartup;
|
||||
if (_nextRepaintIndex >= 0)
|
||||
{
|
||||
RepaintFrame(_nextRepaintIndex);
|
||||
_nextRepaintIndex = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnHandleConnectionEvent(int playerId)
|
||||
{
|
||||
@@ -158,24 +191,27 @@ namespace YooAsset.Editor
|
||||
}
|
||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||
{
|
||||
int playerId = args.playerId;
|
||||
var debugReport = DebugReport.Deserialize(args.data);
|
||||
OnHandleDebugReport(args.playerId, debugReport);
|
||||
}
|
||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
||||
{
|
||||
Debug.Log($"Handle player {playerId} debug report !");
|
||||
|
||||
if (debugReport.DebuggerVersion != RemoteDebuggerDefine.DebuggerVersion)
|
||||
{
|
||||
Debug.LogWarning($"Debugger versions are inconsistent : {debugReport.DebuggerVersion} != {RemoteDebuggerDefine.DebuggerVersion}");
|
||||
return;
|
||||
}
|
||||
|
||||
//Debug.Log($"Handle player {playerId} debug report !");
|
||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||
_currentPlayerSession.AddDebugReport(debugReport);
|
||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
||||
UpdateFrameView(_currentPlayerSession);
|
||||
_nextRepaintIndex = _currentPlayerSession.MaxRangeValue;
|
||||
}
|
||||
|
||||
private void OnFrameSliderChange(int sliderValue)
|
||||
{
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
RepaintFrame(_rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameLast_clicked()
|
||||
@@ -184,7 +220,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
RepaintFrame(_rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameNext_clicked()
|
||||
@@ -193,56 +229,37 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||
_frameSlider.value = _rangeIndex;
|
||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
||||
RepaintFrame(_rangeIndex);
|
||||
}
|
||||
}
|
||||
private void OnFrameClear_clicked()
|
||||
{
|
||||
_nextRepaintIndex = -1;
|
||||
_lastRepaintIndex = 0;
|
||||
_rangeIndex = 0;
|
||||
|
||||
_frameSlider.label = $"Frame:";
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.highValue = 0;
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
_operationListViewer.ClearView();
|
||||
|
||||
if (_currentPlayerSession != null)
|
||||
{
|
||||
_frameSlider.label = $"Frame:";
|
||||
_frameSlider.value = 0;
|
||||
_frameSlider.lowValue = 0;
|
||||
_frameSlider.highValue = 0;
|
||||
_currentPlayerSession.ClearDebugReport();
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
}
|
||||
}
|
||||
|
||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||
private void OnRecordToggleValueChange(ChangeEvent<bool> evt)
|
||||
{
|
||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||
_playerSessions.Add(playerId, newSession);
|
||||
return newSession;
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession)
|
||||
{
|
||||
if (playerSession != null)
|
||||
{
|
||||
UpdateFrameView(playerSession, playerSession.MaxRangeValue);
|
||||
}
|
||||
}
|
||||
private void UpdateFrameView(RemotePlayerSession playerSession, int rangeIndex)
|
||||
{
|
||||
if (playerSession == null)
|
||||
return;
|
||||
|
||||
var debugReport = playerSession.GetDebugReport(rangeIndex);
|
||||
if (debugReport != null)
|
||||
{
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_assetListViewer.FillViewData(debugReport);
|
||||
_bundleListViewer.FillViewData(debugReport);
|
||||
}
|
||||
// 发送采集数据的命令
|
||||
RemoteCommand command = new RemoteCommand();
|
||||
command.CommandType = (int)ERemoteCommand.SampleAuto;
|
||||
command.CommandParam = evt.newValue ? "open" : "close";
|
||||
byte[] data = RemoteCommand.Serialize(command);
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||
}
|
||||
|
||||
private void SampleBtn_onClick()
|
||||
@@ -252,8 +269,8 @@ namespace YooAsset.Editor
|
||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||
command.CommandParam = string.Empty;
|
||||
byte[] data = RemoteCommand.Serialize(command);
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||
}
|
||||
private void ExportBtn_clicked()
|
||||
{
|
||||
@@ -279,6 +296,7 @@ namespace YooAsset.Editor
|
||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||
FileUtility.WriteAllText(filePath, fileContent);
|
||||
Debug.Log($"Debug report file saved : {filePath}");
|
||||
}
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
@@ -288,6 +306,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_assetListViewer.RebuildView(_searchKeyWord);
|
||||
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||
_operationListViewer.RebuildView(_searchKeyWord);
|
||||
}
|
||||
}
|
||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||
@@ -303,16 +322,27 @@ namespace YooAsset.Editor
|
||||
{
|
||||
_assetListViewer.AttachParent(root);
|
||||
_bundleListViewer.DetachParent();
|
||||
_operationListViewer.DetachParent();
|
||||
}
|
||||
else if (viewMode == EViewMode.BundleView)
|
||||
{
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
_operationListViewer.DetachParent();
|
||||
}
|
||||
else if (viewMode == EViewMode.OperationView)
|
||||
{
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.DetachParent();
|
||||
_operationListViewer.AttachParent(root);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotImplementedException(viewMode.ToString());
|
||||
}
|
||||
|
||||
// 重新绘制该帧数据
|
||||
RepaintFrame(_lastRepaintIndex);
|
||||
}
|
||||
}
|
||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||
@@ -323,6 +353,63 @@ namespace YooAsset.Editor
|
||||
else
|
||||
return DropdownMenuAction.Status.Normal;
|
||||
}
|
||||
|
||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
||||
{
|
||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
||||
{
|
||||
return session;
|
||||
}
|
||||
else
|
||||
{
|
||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
||||
_playerSessions.Add(playerId, newSession);
|
||||
return newSession;
|
||||
}
|
||||
}
|
||||
private void RepaintFrame(int repaintIndex)
|
||||
{
|
||||
if (_currentPlayerSession == null)
|
||||
{
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
_operationListViewer.ClearView();
|
||||
return;
|
||||
}
|
||||
|
||||
var debugReport = _currentPlayerSession.GetDebugReport(repaintIndex);
|
||||
if (debugReport != null)
|
||||
{
|
||||
_lastRepaintIndex = repaintIndex;
|
||||
_currentReport = debugReport;
|
||||
_frameSlider.label = $"Frame: {debugReport.FrameCount}";
|
||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
||||
_frameSlider.value = repaintIndex;
|
||||
|
||||
if (_viewMode == EViewMode.AssetView)
|
||||
{
|
||||
_assetListViewer.FillViewData(debugReport);
|
||||
_bundleListViewer.ClearView();
|
||||
_operationListViewer.ClearView();
|
||||
}
|
||||
else if (_viewMode == EViewMode.BundleView)
|
||||
{
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.FillViewData(debugReport);
|
||||
_operationListViewer.ClearView();
|
||||
}
|
||||
else if (_viewMode == EViewMode.OperationView)
|
||||
{
|
||||
_assetListViewer.ClearView();
|
||||
_bundleListViewer.ClearView();
|
||||
_operationListViewer.FillViewData(debugReport);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new System.NotImplementedException(_viewMode.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,7 +1,7 @@
|
||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: lower-left; padding-left: 5px;" />
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="IP" parse-escape-sequences="true" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px;" />
|
||||
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 150px; flex-grow: 0;" />
|
||||
<uie:ToolbarSearchField focusable="true" name="SearchField" style="flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Refresh" display-tooltip-when-elided="true" name="SampleButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
<uie:ToolbarButton text="Export" display-tooltip-when-elided="true" name="ExportButton" style="width: 70px; background-color: rgb(15, 118, 31); -unity-text-align: middle-center; border-top-left-radius: 2px; border-bottom-left-radius: 2px; border-top-right-radius: 2px; border-bottom-right-radius: 2px; border-left-width: 1px; border-right-width: 1px;" />
|
||||
@@ -11,5 +11,6 @@
|
||||
<uie:ToolbarButton text=" << " display-tooltip-when-elided="true" name="FrameLast" />
|
||||
<uie:ToolbarButton text=" >> " display-tooltip-when-elided="true" name="FrameNext" />
|
||||
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
|
||||
<YooAsset.Editor.ToggleRecord name="FrameRecord" style="width: 20px;" />
|
||||
</uie:Toolbar>
|
||||
</ui:UXML>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace YooAsset.Editor
|
||||
{
|
||||
internal class RemotePlayerSession
|
||||
{
|
||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
||||
private readonly Queue<DebugReport> _reports = new Queue<DebugReport>();
|
||||
|
||||
/// <summary>
|
||||
/// 用户ID
|
||||
@@ -29,7 +30,7 @@ namespace YooAsset.Editor
|
||||
{
|
||||
get
|
||||
{
|
||||
int index = _reportList.Count - 1;
|
||||
int index = _reports.Count - 1;
|
||||
if (index < 0)
|
||||
index = 0;
|
||||
return index;
|
||||
@@ -37,7 +38,7 @@ namespace YooAsset.Editor
|
||||
}
|
||||
|
||||
|
||||
public RemotePlayerSession(int playerId, int maxReportCount = 1000)
|
||||
public RemotePlayerSession(int playerId, int maxReportCount = 500)
|
||||
{
|
||||
PlayerId = playerId;
|
||||
MaxReportCount = maxReportCount;
|
||||
@@ -48,7 +49,7 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public void ClearDebugReport()
|
||||
{
|
||||
_reportList.Clear();
|
||||
_reports.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -59,9 +60,9 @@ namespace YooAsset.Editor
|
||||
if (report == null)
|
||||
Debug.LogWarning("Invalid debug report data !");
|
||||
|
||||
if (_reportList.Count >= MaxReportCount)
|
||||
_reportList.RemoveAt(0);
|
||||
_reportList.Add(report);
|
||||
if (_reports.Count >= MaxReportCount)
|
||||
_reports.Dequeue();
|
||||
_reports.Enqueue(report);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -69,11 +70,11 @@ namespace YooAsset.Editor
|
||||
/// </summary>
|
||||
public DebugReport GetDebugReport(int rangeIndex)
|
||||
{
|
||||
if (_reportList.Count == 0)
|
||||
if (_reports.Count == 0)
|
||||
return null;
|
||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
||||
if (rangeIndex < 0 || rangeIndex >= _reports.Count)
|
||||
return null;
|
||||
return _reportList[rangeIndex];
|
||||
return _reports.ElementAt(rangeIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user