mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-19 14:50:10 +00:00
Compare commits
148 Commits
2.3.2-prev
...
2.3.12
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
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/StreamingAssets.meta
|
||||||
/Assets/Samples
|
/Assets/Samples
|
||||||
/Assets/Samples.meta
|
/Assets/Samples.meta
|
||||||
|
/Assets/csc.rsp
|
||||||
|
/Assets/csc.rsp.meta
|
||||||
/UserSettings
|
/UserSettings
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,271 @@
|
|||||||
|
|
||||||
All notable changes to this package will be documented in this file.
|
All notable changes to this package will be documented in this file.
|
||||||
|
|
||||||
|
## [2.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
|
## [2.3.2-preview] - 2025-02-27
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 5280dfac6a481ee429c769ba5688c9d2
|
guid: fab3cd742c11be2479b07f5d447a78c9
|
||||||
folderAsset: yes
|
folderAsset: yes
|
||||||
DefaultImporter:
|
DefaultImporter:
|
||||||
externalObjects: {}
|
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
|
fileFormatVersion: 2
|
||||||
guid: 0c3f4136cf7142346ae33e8a82cbdb27
|
guid: ef774f01e50ab0a4d88122041938a6b9
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
19
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
19
Assets/YooAsset/Editor/Assembly/MacroDefine.cs
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
#if YOO_ASSET_EXPERIMENT
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class MacroDefine
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// YooAsset版本宏定义
|
||||||
|
/// </summary>
|
||||||
|
public static readonly List<string> Macros = new List<string>()
|
||||||
|
{
|
||||||
|
"YOO_ASSET_2",
|
||||||
|
"YOO_ASSET_2_3",
|
||||||
|
"YOO_ASSET_2_3_OR_NEWER",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 56ea224b45d314e4a86b558404e9b6c8
|
guid: a61e5c2ca04aab647b1ed0492086aa8f
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
106
Assets/YooAsset/Editor/Assembly/MacroProcessor.cs
Normal file
106
Assets/YooAsset/Editor/Assembly/MacroProcessor.cs
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using UnityEditor;
|
||||||
|
|
||||||
|
#if YOO_ASSET_EXPERIMENT
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class MacroProcessor : AssetPostprocessor
|
||||||
|
{
|
||||||
|
static string OnGeneratedCSProject(string path, string content)
|
||||||
|
{
|
||||||
|
XmlDocument xmlDoc = new XmlDocument();
|
||||||
|
xmlDoc.LoadXml(content);
|
||||||
|
|
||||||
|
if (IsCSProjectReferenced(xmlDoc.DocumentElement) == false)
|
||||||
|
return content;
|
||||||
|
|
||||||
|
if (ProcessDefineConstants(xmlDoc.DocumentElement) == false)
|
||||||
|
return content;
|
||||||
|
|
||||||
|
// 将修改后的XML结构重新输出为文本
|
||||||
|
using (var memoryStream = new MemoryStream())
|
||||||
|
{
|
||||||
|
var writerSettings = new XmlWriterSettings
|
||||||
|
{
|
||||||
|
Indent = true,
|
||||||
|
Encoding = new UTF8Encoding(false), //无BOM
|
||||||
|
OmitXmlDeclaration = false
|
||||||
|
};
|
||||||
|
|
||||||
|
using (var xmlWriter = XmlWriter.Create(memoryStream, writerSettings))
|
||||||
|
{
|
||||||
|
xmlDoc.Save(xmlWriter);
|
||||||
|
}
|
||||||
|
return Encoding.UTF8.GetString(memoryStream.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 处理宏定义
|
||||||
|
/// </summary>
|
||||||
|
private static bool ProcessDefineConstants(XmlElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool processed = false;
|
||||||
|
foreach (XmlNode node in element.ChildNodes)
|
||||||
|
{
|
||||||
|
if (node.Name != "PropertyGroup")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
{
|
||||||
|
if (childNode.Name != "DefineConstants")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string[] defines = childNode.InnerText.Split(';');
|
||||||
|
HashSet<string> hashSets = new HashSet<string>(defines);
|
||||||
|
foreach (string yooMacro in MacroDefine.Macros)
|
||||||
|
{
|
||||||
|
string tmpMacro = yooMacro.Trim();
|
||||||
|
if (hashSets.Contains(tmpMacro) == false)
|
||||||
|
hashSets.Add(tmpMacro);
|
||||||
|
}
|
||||||
|
childNode.InnerText = string.Join(";", hashSets.ToArray());
|
||||||
|
processed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return processed;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检测工程是否引用了YooAsset
|
||||||
|
/// </summary>
|
||||||
|
private static bool IsCSProjectReferenced(XmlElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
foreach (XmlNode node in element.ChildNodes)
|
||||||
|
{
|
||||||
|
if (node.Name != "ItemGroup")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
foreach (XmlNode childNode in node.ChildNodes)
|
||||||
|
{
|
||||||
|
if (childNode.Name != "Reference" && childNode.Name != "ProjectReference")
|
||||||
|
continue;
|
||||||
|
|
||||||
|
string include = childNode.Attributes["Include"].Value;
|
||||||
|
if (include.Contains("YooAsset"))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 07f7c95e8e42fd04f81b9925b2dcf0d0
|
guid: 88d5a41d078a82e40b82265ed4c3631a
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
115
Assets/YooAsset/Editor/Assembly/RspGenerator.cs
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
#if YOO_ASSET_EXPERIMENT
|
||||||
|
namespace YooAsset.Editor.Experiment
|
||||||
|
{
|
||||||
|
[InitializeOnLoad]
|
||||||
|
public class RspGenerator
|
||||||
|
{
|
||||||
|
// csc.rsp文件路径
|
||||||
|
private static string RspFilePath => Path.Combine(Application.dataPath, "csc.rsp");
|
||||||
|
|
||||||
|
static RspGenerator()
|
||||||
|
{
|
||||||
|
UpdateRspFile(MacroDefine.Macros, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新csc.rsp文件
|
||||||
|
/// </summary>
|
||||||
|
private static void UpdateRspFile(List<string> addMacros, List<string> removeMacros)
|
||||||
|
{
|
||||||
|
var existingDefines = new HashSet<string>();
|
||||||
|
var otherLines = new List<string>();
|
||||||
|
|
||||||
|
// 1. 读取现有内容
|
||||||
|
ReadRspFile(existingDefines, otherLines);
|
||||||
|
|
||||||
|
// 2. 添加新宏
|
||||||
|
if (addMacros != null && addMacros.Count > 0)
|
||||||
|
{
|
||||||
|
addMacros.ForEach(x =>
|
||||||
|
{
|
||||||
|
if (existingDefines.Contains(x) == false)
|
||||||
|
existingDefines.Add(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 移除指定宏
|
||||||
|
if (removeMacros != null && removeMacros.Count > 0)
|
||||||
|
{
|
||||||
|
removeMacros.ForEach(x =>
|
||||||
|
{
|
||||||
|
existingDefines.Remove(x);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. 重新生成内容
|
||||||
|
WriteRspFile(existingDefines, otherLines);
|
||||||
|
|
||||||
|
// 5. 刷新AssetDatabase
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
EditorUtility.RequestScriptReload();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取csc.rsp文件,返回宏定义和其他行
|
||||||
|
/// </summary>
|
||||||
|
private static void ReadRspFile(HashSet<string> defines, List<string> others)
|
||||||
|
{
|
||||||
|
if (defines == null)
|
||||||
|
defines = new HashSet<string>();
|
||||||
|
|
||||||
|
if (others == null)
|
||||||
|
others = new List<string>();
|
||||||
|
|
||||||
|
if (File.Exists(RspFilePath) == false)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (string line in File.ReadAllLines(RspFilePath))
|
||||||
|
{
|
||||||
|
if (line.StartsWith("-define:"))
|
||||||
|
{
|
||||||
|
string[] parts = line.Split(new[] { ':' }, 2);
|
||||||
|
if (parts.Length == 2)
|
||||||
|
{
|
||||||
|
defines.Add(parts[1].Trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
others.Add(line);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重新写入csc.rsp文件
|
||||||
|
/// </summary>
|
||||||
|
private static void WriteRspFile(HashSet<string> defines, List<string> others)
|
||||||
|
{
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
if (others != null && others.Count > 0)
|
||||||
|
{
|
||||||
|
others.ForEach(o => sb.AppendLine(o));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (defines != null && defines.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (string define in defines)
|
||||||
|
{
|
||||||
|
sb.AppendLine($"-define:{define}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllText(RspFilePath, sb.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 88e4ec854876f3f40bce38bc880c0f6a
|
guid: c2662e1d33b1eea469695b68d18b1739
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@@ -97,7 +97,7 @@ namespace YooAsset.Editor
|
|||||||
private Button _passesVisibleBtn;
|
private Button _passesVisibleBtn;
|
||||||
private Label _titleLabel;
|
private Label _titleLabel;
|
||||||
private Label _descLabel;
|
private Label _descLabel;
|
||||||
private TableView _elementTableView;
|
private TableViewer _elementTableView;
|
||||||
|
|
||||||
private ScanReportCombiner _reportCombiner;
|
private ScanReportCombiner _reportCombiner;
|
||||||
private string _lastestOpenFolder;
|
private string _lastestOpenFolder;
|
||||||
@@ -152,7 +152,7 @@ namespace YooAsset.Editor
|
|||||||
_descLabel = root.Q<Label>("ReportDesc");
|
_descLabel = root.Q<Label>("ReportDesc");
|
||||||
|
|
||||||
// 列表相关
|
// 列表相关
|
||||||
_elementTableView = root.Q<TableView>("TopTableView");
|
_elementTableView = root.Q<TableViewer>("TopTableView");
|
||||||
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
_elementTableView.ClickTableDataEvent = OnClickTableViewItem;
|
||||||
|
|
||||||
_lastestOpenFolder = EditorTools.GetProjectPath();
|
_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()
|
private void ImportSingleBtn_clicked()
|
||||||
{
|
{
|
||||||
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", _lastestOpenFolder, "json");
|
||||||
@@ -326,7 +352,7 @@ namespace YooAsset.Editor
|
|||||||
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
var column = new TableColumn("眼睛框", string.Empty, columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
var toggle = new DisplayToggle();
|
var toggle = new ToggleDisplay();
|
||||||
toggle.text = string.Empty;
|
toggle.text = string.Empty;
|
||||||
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
toggle.style.unityTextAlign = TextAnchor.MiddleCenter;
|
||||||
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
toggle.RegisterValueChangedCallback((evt) => { OnDisplayToggleValueChange(toggle, evt); });
|
||||||
@@ -334,11 +360,10 @@ namespace YooAsset.Editor
|
|||||||
};
|
};
|
||||||
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
{
|
{
|
||||||
var toggle = element as DisplayToggle;
|
var toggle = element as ToggleDisplay;
|
||||||
toggle.userData = data;
|
toggle.userData = data;
|
||||||
var tableData = data as ElementTableData;
|
var tableData = data as ElementTableData;
|
||||||
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
toggle.SetValueWithoutNotify(tableData.Element.Hidden);
|
||||||
toggle.RefreshIcon();
|
|
||||||
};
|
};
|
||||||
_elementTableView.AddColumn(column);
|
_elementTableView.AddColumn(column);
|
||||||
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
var headerElement = _elementTableView.GetHeaderElement("眼睛框");
|
||||||
@@ -442,18 +467,36 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = header.Stretchable;
|
columnStyle.Stretchable = header.Stretchable;
|
||||||
columnStyle.Searchable = header.Searchable;
|
columnStyle.Searchable = header.Searchable;
|
||||||
columnStyle.Sortable = header.Sortable;
|
columnStyle.Sortable = header.Sortable;
|
||||||
|
columnStyle.Counter = header.Counter;
|
||||||
|
columnStyle.Units = header.Units;
|
||||||
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
var column = new TableColumn(header.HeaderTitle, header.HeaderTitle, columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
var label = new Label();
|
if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
label.style.marginLeft = 3f;
|
{
|
||||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
var objectFiled = new ObjectField();
|
||||||
return label;
|
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) =>
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
{
|
{
|
||||||
var infoLabel = element as Label;
|
if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
infoLabel.text = (string)cell.GetDisplayObject();
|
{
|
||||||
|
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);
|
_elementTableView.AddColumn(column);
|
||||||
}
|
}
|
||||||
@@ -479,6 +522,10 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
tableData.AddAssetPathCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
}
|
}
|
||||||
|
else if (header.HeaderType == EHeaderType.AssetObject)
|
||||||
|
{
|
||||||
|
tableData.AddAssetObjectCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
|
}
|
||||||
else if (header.HeaderType == EHeaderType.StringValue)
|
else if (header.HeaderType == EHeaderType.StringValue)
|
||||||
{
|
{
|
||||||
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
tableData.AddStringValueCell(scanInfo.HeaderTitle, scanInfo.ScanInfo);
|
||||||
@@ -577,10 +624,8 @@ namespace YooAsset.Editor
|
|||||||
// 重绘视图
|
// 重绘视图
|
||||||
RebuildView();
|
RebuildView();
|
||||||
}
|
}
|
||||||
private void OnDisplayToggleValueChange(DisplayToggle toggle, ChangeEvent<bool> e)
|
private void OnDisplayToggleValueChange(ToggleDisplay toggle, ChangeEvent<bool> e)
|
||||||
{
|
{
|
||||||
toggle.RefreshIcon();
|
|
||||||
|
|
||||||
// 处理自身
|
// 处理自身
|
||||||
toggle.SetValueWithoutNotify(e.newValue);
|
toggle.SetValueWithoutNotify(e.newValue);
|
||||||
|
|
||||||
@@ -593,7 +638,8 @@ namespace YooAsset.Editor
|
|||||||
foreach (var selectedItem in selectedItems)
|
foreach (var selectedItem in selectedItems)
|
||||||
{
|
{
|
||||||
var selectElement = selectedItem as ElementTableData;
|
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;" />
|
<ui:Button text="显示白名单元素" display-tooltip-when-elided="true" name="WhiteListVisibleButton" style="width: 100px;" />
|
||||||
</uie:Toolbar>
|
</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;">
|
<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:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
AssetPath,
|
AssetPath,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源对象
|
||||||
|
/// </summary>
|
||||||
|
AssetObject,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 字符串
|
/// 字符串
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -43,6 +43,16 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool Sortable = false;
|
public bool Sortable = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 统计数量
|
||||||
|
/// </summary>
|
||||||
|
public bool Counter = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 展示单位
|
||||||
|
/// </summary>
|
||||||
|
public string Units = string.Empty;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数值类型
|
/// 数值类型
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -89,6 +99,16 @@ namespace YooAsset.Editor
|
|||||||
Sortable = true;
|
Sortable = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public ReportHeader SetCounter()
|
||||||
|
{
|
||||||
|
Counter = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public ReportHeader SetUnits(string units)
|
||||||
|
{
|
||||||
|
Units = units;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public ReportHeader SetHeaderType(EHeaderType value)
|
public ReportHeader SetHeaderType(EHeaderType value)
|
||||||
{
|
{
|
||||||
HeaderType = value;
|
HeaderType = value;
|
||||||
@@ -106,6 +126,12 @@ namespace YooAsset.Editor
|
|||||||
if (string.IsNullOrEmpty(guid))
|
if (string.IsNullOrEmpty(guid))
|
||||||
throw new Exception($"{HeaderTitle} value is invalid asset path : {value}");
|
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)
|
else if (HeaderType == EHeaderType.DoubleValue)
|
||||||
{
|
{
|
||||||
if (double.TryParse(value, out double doubleValue) == false)
|
if (double.TryParse(value, out double doubleValue) == false)
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return new ScannerResult(e.Message);
|
return new ScannerResult(e.StackTrace);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ namespace YooAsset.Editor
|
|||||||
if (Succeed)
|
if (Succeed)
|
||||||
{
|
{
|
||||||
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
var reproterWindow = AssetArtReporterWindow.OpenWindow();
|
||||||
reproterWindow.ImportSingleReprotFile(ReprotFilePath);
|
reproterWindow.ImportSingleReprotFile(Report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,9 @@ namespace YooAsset.Editor
|
|||||||
var buildParametersContext = new BuildParametersContext(buildParameters);
|
var buildParametersContext = new BuildParametersContext(buildParameters);
|
||||||
_buildContext.SetContextObject(buildParametersContext);
|
_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}");
|
BuildLogger.Log($"Begin to build package : {buildParameters.PackageName} by {buildParameters.BuildPipeline}");
|
||||||
@@ -50,6 +51,9 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Error(buildResult.ErrorInfo);
|
BuildLogger.Error(buildResult.ErrorInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 关闭日志系统
|
||||||
|
BuildLogger.Shuntdown();
|
||||||
|
|
||||||
return buildResult;
|
return buildResult;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,97 +6,110 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
public static class AssetBundleBuilderSetting
|
public static class AssetBundleBuilderSetting
|
||||||
{
|
{
|
||||||
// EBuildPipeline
|
// BuildPipelineName
|
||||||
public static EBuildPipeline GetPackageBuildPipeline(string packageName)
|
public static string GetPackageBuildPipeline(string packageName)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{nameof(EBuildPipeline)}";
|
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||||
return (EBuildPipeline)EditorPrefs.GetInt(key, (int)EBuildPipeline.BuiltinBuildPipeline);
|
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)}";
|
string key = $"{Application.productName}_{packageName}_BuildPipelineName";
|
||||||
EditorPrefs.SetInt(key, (int)buildPipeline);
|
EditorPrefs.SetString(key, buildPipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ECompressOption
|
// 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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
return (ECompressOption)EditorPrefs.GetInt(key, (int)ECompressOption.LZ4);
|
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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(ECompressOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)compressOption);
|
EditorPrefs.SetInt(key, (int)compressOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EFileNameStyle
|
// 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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
return (EFileNameStyle)EditorPrefs.GetInt(key, (int)EFileNameStyle.HashName);
|
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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EFileNameStyle)}";
|
||||||
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
EditorPrefs.SetInt(key, (int)fileNameStyle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EBuildinFileCopyOption
|
// 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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
return (EBuildinFileCopyOption)EditorPrefs.GetInt(key, (int)EBuildinFileCopyOption.None);
|
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)}";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_{nameof(EBuildinFileCopyOption)}";
|
||||||
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
EditorPrefs.SetInt(key, (int)buildinFileCopyOption);
|
||||||
}
|
}
|
||||||
|
|
||||||
// BuildFileCopyParams
|
// BuildFileCopyParams
|
||||||
public static string GetPackageBuildinFileCopyParams(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageBuildinFileCopyParams(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
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";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_BuildFileCopyParams";
|
||||||
EditorPrefs.SetString(key, buildinFileCopyParams);
|
EditorPrefs.SetString(key, buildinFileCopyParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
// EncyptionClassName
|
// EncyptionServicesClassName
|
||||||
public static string GetPackageEncyptionClassName(string packageName, EBuildPipeline buildPipeline)
|
public static string GetPackageEncyptionServicesClassName(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionClassName";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_EncyptionServicesClassName";
|
||||||
return EditorPrefs.GetString(key, string.Empty);
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ManifestServicesClassName
|
||||||
|
public static string GetPackageManifestServicesClassName(string packageName, string buildPipeline)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName";
|
||||||
|
return EditorPrefs.GetString(key, $"{typeof(ManifestNone).FullName}");
|
||||||
|
}
|
||||||
|
public static void SetPackageManifestServicesClassName(string packageName, string buildPipeline, string encyptionClassName)
|
||||||
|
{
|
||||||
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ManifestServicesClassName";
|
||||||
EditorPrefs.SetString(key, encyptionClassName);
|
EditorPrefs.SetString(key, encyptionClassName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ClearBuildCache
|
// ClearBuildCache
|
||||||
public static bool GetPackageClearBuildCache(string packageName, EBuildPipeline buildPipeline)
|
public static bool GetPackageClearBuildCache(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
return EditorPrefs.GetInt(key, 0) > 0;
|
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";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_ClearBuildCache";
|
||||||
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
EditorPrefs.SetInt(key, clearBuildCache ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// UseAssetDependencyDB
|
// UseAssetDependencyDB
|
||||||
public static bool GetPackageUseAssetDependencyDB(string packageName, EBuildPipeline buildPipeline)
|
public static bool GetPackageUseAssetDependencyDB(string packageName, string buildPipeline)
|
||||||
{
|
{
|
||||||
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
return EditorPrefs.GetInt(key, 0) > 0;
|
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";
|
string key = $"{Application.productName}_{packageName}_{buildPipeline}_UseAssetDependencyDB";
|
||||||
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
EditorPrefs.SetInt(key, useAssetDependencyDB ? 1 : 0);
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
|
|
||||||
private string _buildPackage;
|
private string _buildPackage;
|
||||||
private EBuildPipeline _buildPipeline;
|
private string _buildPipeline;
|
||||||
|
|
||||||
|
private Dictionary<string, Type> _viewClassDic = new Dictionary<string, Type>(10);
|
||||||
|
|
||||||
private Toolbar _toolbar;
|
private Toolbar _toolbar;
|
||||||
private ToolbarMenu _packageMenu;
|
private ToolbarMenu _packageMenu;
|
||||||
@@ -69,11 +71,23 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_pipelineMenu = new ToolbarMenu();
|
_pipelineMenu = new ToolbarMenu();
|
||||||
_pipelineMenu.style.width = 200;
|
_pipelineMenu.style.width = 200;
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.EditorSimulateBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.EditorSimulateBuildPipeline);
|
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.BuiltinBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.BuiltinBuildPipeline);
|
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.ScriptableBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.ScriptableBuildPipeline);
|
|
||||||
_pipelineMenu.menu.AppendAction(EBuildPipeline.RawFileBuildPipeline.ToString(), PipelineMenuAction, PipelineMenuFun, EBuildPipeline.RawFileBuildPipeline);
|
|
||||||
_toolbar.Add(_pipelineMenu);
|
_toolbar.Add(_pipelineMenu);
|
||||||
|
|
||||||
|
var viewerClassTypes = EditorTools.GetAssignableTypes(typeof(BuildPipelineViewerBase));
|
||||||
|
foreach (var classType in viewerClassTypes)
|
||||||
|
{
|
||||||
|
var buildPipelineAttribute = EditorTools.GetAttribute<BuildPipelineAttribute>(classType);
|
||||||
|
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();
|
RefreshBuildPipelineView();
|
||||||
@@ -91,28 +105,18 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
_buildPipeline = AssetBundleBuilderSetting.GetPackageBuildPipeline(_buildPackage);
|
||||||
_packageMenu.text = _buildPackage;
|
_packageMenu.text = _buildPackage;
|
||||||
_pipelineMenu.text = _buildPipeline.ToString();
|
_pipelineMenu.text = _buildPipeline;
|
||||||
|
|
||||||
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
if (_viewClassDic.TryGetValue(_buildPipeline, out Type value))
|
||||||
if (_buildPipeline == EBuildPipeline.EditorSimulateBuildPipeline)
|
|
||||||
{
|
{
|
||||||
var viewer = new EditorSimulateBuildPipelineViewer(_buildPackage, buildTarget, _container);
|
var buildTarget = EditorUserBuildSettings.activeBuildTarget;
|
||||||
}
|
var viewer = Activator.CreateInstance(value) as BuildPipelineViewerBase;
|
||||||
else if (_buildPipeline == EBuildPipeline.BuiltinBuildPipeline)
|
viewer.InitView(_buildPackage, _buildPipeline, buildTarget);
|
||||||
{
|
viewer.CreateView(_container);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException(_buildPipeline.ToString());
|
Debug.LogError($"Not found build pipeline : {_buildPipeline}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private List<string> GetBuildPackageNames()
|
private List<string> GetBuildPackageNames()
|
||||||
@@ -145,18 +149,16 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
private void PipelineMenuAction(DropdownMenuAction action)
|
private void PipelineMenuAction(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
if (_buildPipeline != action.name)
|
||||||
if (_buildPipeline != pipelineType)
|
|
||||||
{
|
{
|
||||||
_buildPipeline = pipelineType;
|
_buildPipeline = action.name;
|
||||||
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, pipelineType);
|
AssetBundleBuilderSetting.SetPackageBuildPipeline(_buildPackage, _buildPipeline);
|
||||||
RefreshBuildPipelineView();
|
RefreshBuildPipelineView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
private DropdownMenuAction.Status PipelineMenuFun(DropdownMenuAction action)
|
||||||
{
|
{
|
||||||
var pipelineType = (EBuildPipeline)action.userData;
|
if (_buildPipeline == action.name)
|
||||||
if (_buildPipeline == pipelineType)
|
|
||||||
return DropdownMenuAction.Status.Checked;
|
return DropdownMenuAction.Status.Checked;
|
||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
return DropdownMenuAction.Status.Normal;
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ namespace YooAsset.Editor
|
|||||||
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
buildParameters.FileNameStyle = EFileNameStyle.HashName;
|
||||||
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
buildParameters.BuildinFileCopyOption = EBuildinFileCopyOption.None;
|
||||||
buildParameters.BuildinFileCopyParams = string.Empty;
|
buildParameters.BuildinFileCopyParams = string.Empty;
|
||||||
|
buildParameters.UseAssetDependencyDB = true;
|
||||||
|
|
||||||
var pipeline = new EditorSimulateBuildPipeline();
|
var pipeline = new EditorSimulateBuildPipeline();
|
||||||
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
BuildResult buildResult = pipeline.Run(buildParameters, false);
|
||||||
|
|||||||
@@ -98,6 +98,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IEncryptionServices EncryptionServices;
|
public IEncryptionServices EncryptionServices;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 资源清单服务类
|
||||||
|
/// </summary>
|
||||||
|
public IManifestServices ManifestServices;
|
||||||
|
|
||||||
|
|
||||||
private string _pipelineOutputDirectory = string.Empty;
|
private string _pipelineOutputDirectory = string.Empty;
|
||||||
private string _packageOutputDirectory = 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.ManifestServices;
|
||||||
|
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(manifestServices, buildPackageName, buildinRootDirectory);
|
||||||
|
|
||||||
|
// 刷新目录
|
||||||
|
AssetDatabase.Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 2d2c835e5e40ca34d93480587c8125df
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -30,7 +30,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 创建新补丁清单
|
// 创建新补丁清单
|
||||||
PackageManifest manifest = new PackageManifest();
|
PackageManifest manifest = new PackageManifest();
|
||||||
manifest.FileVersion = YooAssetSettings.ManifestFileVersion;
|
manifest.FileVersion = ManifestDefine.FileVersion;
|
||||||
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
manifest.EnableAddressable = buildMapContext.Command.EnableAddressable;
|
||||||
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
manifest.LocationToLower = buildMapContext.Command.LocationToLower;
|
||||||
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
manifest.IncludeAssetGUID = buildMapContext.Command.IncludeAssetGUID;
|
||||||
@@ -58,7 +58,7 @@ namespace YooAsset.Editor
|
|||||||
if (processBundleDepends)
|
if (processBundleDepends)
|
||||||
ProcessBuiltinBundleDependency(context, manifest);
|
ProcessBuiltinBundleDependency(context, manifest);
|
||||||
|
|
||||||
// 创建补丁清单文本文件
|
// 创建资源清单文本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestJsonFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
@@ -66,18 +66,18 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Log($"Create package manifest file: {filePath}");
|
BuildLogger.Log($"Create package manifest file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单二进制文件
|
// 创建资源清单二进制文件
|
||||||
string packageHash;
|
string packageHash;
|
||||||
string packagePath;
|
string packagePath;
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetManifestBinaryFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
packagePath = $"{packageOutputDirectory}/{fileName}";
|
packagePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
ManifestTools.SerializeToBinary(packagePath, manifest);
|
ManifestTools.SerializeToBinary(packagePath, manifest, buildParameters.ManifestServices);
|
||||||
packageHash = HashUtility.FileCRC32(packagePath);
|
packageHash = HashUtility.FileCRC32(packagePath);
|
||||||
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
BuildLogger.Log($"Create package manifest file: {packagePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单哈希文件
|
// 创建资源清单哈希文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
string fileName = YooAssetSettingsData.GetPackageHashFileName(buildParameters.PackageName, buildParameters.PackageVersion);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
@@ -85,7 +85,7 @@ namespace YooAsset.Editor
|
|||||||
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
BuildLogger.Log($"Create package manifest hash file: {filePath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建补丁清单版本文件
|
// 创建资源清单版本文件
|
||||||
{
|
{
|
||||||
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
string fileName = YooAssetSettingsData.GetPackageVersionFileName(buildParameters.PackageName);
|
||||||
string filePath = $"{packageOutputDirectory}/{fileName}";
|
string filePath = $"{packageOutputDirectory}/{fileName}";
|
||||||
@@ -97,7 +97,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
ManifestContext manifestContext = new ManifestContext();
|
ManifestContext manifestContext = new ManifestContext();
|
||||||
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
byte[] bytesData = FileUtility.ReadAllBytes(packagePath);
|
||||||
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData);
|
manifestContext.Manifest = ManifestTools.DeserializeFromBinary(bytesData, buildParameters.ManifestServices);
|
||||||
context.SetContextObject(manifestContext);
|
context.SetContextObject(manifestContext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,8 @@ namespace YooAsset.Editor
|
|||||||
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
buildReport.Summary.EnableSharePackRule = buildParameters.EnableSharePackRule;
|
||||||
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
buildReport.Summary.SingleReferencedPackAlone = buildParameters.SingleReferencedPackAlone;
|
||||||
buildReport.Summary.FileNameStyle = buildParameters.FileNameStyle;
|
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.ManifestServicesClassName = buildParameters.ManifestServices == null ? "null" : buildParameters.ManifestServices.GetType().FullName;
|
||||||
if (buildParameters is BuiltinBuildParameters)
|
if (buildParameters is BuiltinBuildParameters)
|
||||||
{
|
{
|
||||||
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
var builtinBuildParameters = buildParameters as BuiltinBuildParameters;
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_BBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8fe3d00b03dc9c64a96b7acfdf99b54c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCreateReport_BBP(),
|
new TaskCreateReport_BBP(),
|
||||||
new TaskCreatePackage_BBP(),
|
new TaskCreatePackage_BBP(),
|
||||||
new TaskCopyBuildinFiles_BBP(),
|
new TaskCopyBuildinFiles_BBP(),
|
||||||
|
new TaskCreateCatalog_BBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_RFBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 563771ecaff17ee498b5fda7c1132e62
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -38,6 +38,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCreateReport_RFBP(),
|
new TaskCreateReport_RFBP(),
|
||||||
new TaskCreatePackage_RFBP(),
|
new TaskCreatePackage_RFBP(),
|
||||||
new TaskCopyBuildinFiles_RFBP(),
|
new TaskCopyBuildinFiles_RFBP(),
|
||||||
|
new TaskCreateCatalog_RFBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class TaskCreateCatalog_SBP : TaskCreateCatalog, IBuildTask
|
||||||
|
{
|
||||||
|
void IBuildTask.Run(BuildContext context)
|
||||||
|
{
|
||||||
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
|
if (buildParametersContext.Parameters.BuildinFileCopyOption != EBuildinFileCopyOption.None)
|
||||||
|
{
|
||||||
|
CreateCatalogFile(buildParametersContext);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d8241b1eb8e22874b84d279dae9bbd1b
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -11,7 +11,7 @@ namespace YooAsset.Editor
|
|||||||
void IBuildTask.Run(BuildContext context)
|
void IBuildTask.Run(BuildContext context)
|
||||||
{
|
{
|
||||||
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
var buildParametersContext = context.GetContextObject<BuildParametersContext>();
|
||||||
var buildParameters = buildParametersContext.Parameters;
|
var buildParameters = buildParametersContext.Parameters as ScriptableBuildParameters;
|
||||||
|
|
||||||
// 检测基础构建参数
|
// 检测基础构建参数
|
||||||
buildParametersContext.CheckBuildParameters();
|
buildParametersContext.CheckBuildParameters();
|
||||||
@@ -50,6 +50,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
BuildLogger.Log($"Create pipeline output directory: {pipelineOutputDirectory}");
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,6 +14,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
public ECompressOption CompressOption = ECompressOption.Uncompressed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从AssetBundle文件头里剥离Unity版本信息
|
||||||
|
/// </summary>
|
||||||
|
public bool StripUnityVersion = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
/// 禁止写入类型树结构(可以降低包体和内存并提高加载效率)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -70,6 +75,9 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
throw new System.NotImplementedException(CompressOption.ToString());
|
throw new System.NotImplementedException(CompressOption.ToString());
|
||||||
|
|
||||||
|
if (StripUnityVersion)
|
||||||
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.StripUnityVersion;
|
||||||
|
|
||||||
if (DisableWriteTypeTree)
|
if (DisableWriteTypeTree)
|
||||||
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
buildParams.ContentBuildFlags |= UnityEditor.Build.Content.ContentBuildFlags.DisableWriteTypeTree;
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace YooAsset.Editor
|
|||||||
new TaskCreateReport_SBP(),
|
new TaskCreateReport_SBP(),
|
||||||
new TaskCreatePackage_SBP(),
|
new TaskCreatePackage_SBP(),
|
||||||
new TaskCopyBuildinFiles_SBP(),
|
new TaskCopyBuildinFiles_SBP(),
|
||||||
|
new TaskCreateCatalog_SBP()
|
||||||
};
|
};
|
||||||
return pipeline;
|
return pipeline;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,37 +2,100 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal static class BuildLogger
|
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;
|
_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)
|
public static void Log(string message)
|
||||||
{
|
{
|
||||||
if (_enableLog)
|
if (_enableLog)
|
||||||
{
|
{
|
||||||
|
WriteLog("INFO", message);
|
||||||
Debug.Log(message);
|
Debug.Log(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static void Warning(string message)
|
public static void Warning(string message)
|
||||||
{
|
{
|
||||||
Debug.LogWarning(message);
|
if (_enableLog)
|
||||||
|
{
|
||||||
|
WriteLog("WARN", message);
|
||||||
|
Debug.LogWarning(message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public static void Error(string 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)
|
public static string GetErrorMessage(ErrorCode code, string message)
|
||||||
{
|
{
|
||||||
return $"[ErrorCode{(int)code}] {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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ namespace YooAsset.Editor
|
|||||||
BuildPipelineIsNullOrEmpty = 116,
|
BuildPipelineIsNullOrEmpty = 116,
|
||||||
BuildBundleTypeIsUnknown = 117,
|
BuildBundleTypeIsUnknown = 117,
|
||||||
RecommendScriptBuildPipeline = 130,
|
RecommendScriptBuildPipeline = 130,
|
||||||
|
BuiltinShadersBundleNameIsNull = 131,
|
||||||
|
|
||||||
// TaskGetBuildMap
|
// TaskGetBuildMap
|
||||||
RemoveInvalidTags = 200,
|
RemoveInvalidTags = 200,
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
public class ManifestNone : IManifestServices
|
||||||
|
{
|
||||||
|
public byte[] ProcessManifest(byte[] fileData)
|
||||||
|
{
|
||||||
|
return fileData;
|
||||||
|
}
|
||||||
|
public byte[] 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
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
public interface IBuildPipeline
|
public interface IBuildPipeline
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 运行构建任务
|
||||||
|
/// </summary>
|
||||||
BuildResult Run(BuildParameters buildParameters, bool enableLog);
|
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,224 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
internal abstract class BuildPipelineViewerBase
|
internal abstract class BuildPipelineViewerBase
|
||||||
{
|
{
|
||||||
private const int StyleWidth = 400;
|
protected const int StyleWidth = 400;
|
||||||
private const int LabelMinWidth = 180;
|
protected const int LabelMinWidth = 190;
|
||||||
|
|
||||||
protected readonly string PackageName;
|
protected string PackageName { private set; get; }
|
||||||
protected readonly BuildTarget BuildTarget;
|
protected string PipelineName { private set; get; }
|
||||||
protected readonly EBuildPipeline BuildPipeline;
|
protected BuildTarget BuildTarget { private set; get; }
|
||||||
protected TemplateContainer Root;
|
|
||||||
|
|
||||||
private TextField _buildOutputField;
|
/// <summary>
|
||||||
private TextField _buildVersionField;
|
/// 初始化视图
|
||||||
private PopupField<Enum> _buildModeField;
|
/// </summary>
|
||||||
private PopupField<Type> _encryptionField;
|
public void InitView(string packageName, string pipelineName, BuildTarget buildTarget)
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
PackageName = packageName;
|
PackageName = packageName;
|
||||||
|
PipelineName = pipelineName;
|
||||||
BuildTarget = buildTarget;
|
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>
|
||||||
/// 执行构建任务
|
/// 创建视图
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected abstract void ExecuteBuild();
|
public abstract void CreateView(VisualElement parent);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取构建版本
|
/// 获取默认版本
|
||||||
/// </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>
|
||||||
/// 创建加密类实例
|
/// 创建资源加密服务类实例
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected IEncryptionServices CreateEncryptionInstance()
|
protected IEncryptionServices CreateEncryptionServicesInstance()
|
||||||
{
|
{
|
||||||
var encyptionClassName = AssetBundleBuilderSetting.GetPackageEncyptionClassName(PackageName, BuildPipeline);
|
var className = AssetBundleBuilderSetting.GetPackageEncyptionServicesClassName(PackageName, PipelineName);
|
||||||
var encryptionClassTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
var classTypes = EditorTools.GetAssignableTypes(typeof(IEncryptionServices));
|
||||||
var classType = encryptionClassTypes.Find(x => x.FullName.Equals(encyptionClassName));
|
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||||
if (classType != null)
|
if (classType != null)
|
||||||
return (IEncryptionServices)Activator.CreateInstance(classType);
|
return (IEncryptionServices)Activator.CreateInstance(classType);
|
||||||
else
|
else
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private string GetDefaultPackageVersion()
|
/// <summary>
|
||||||
|
/// 创建资源清单服务类实例
|
||||||
|
/// </summary>
|
||||||
|
protected IManifestServices CreateManifestServicesInstance()
|
||||||
{
|
{
|
||||||
int totalMinutes = DateTime.Now.Hour * 60 + DateTime.Now.Minute;
|
var className = AssetBundleBuilderSetting.GetPackageManifestServicesClassName(PackageName, PipelineName);
|
||||||
return DateTime.Now.ToString("yyyy-MM-dd") + "-" + totalMinutes;
|
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestServices));
|
||||||
|
var classType = classTypes.Find(x => x.FullName.Equals(className));
|
||||||
|
if (classType != null)
|
||||||
|
return (IManifestServices)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> CreateManifestServicesField(VisualElement container)
|
||||||
|
{
|
||||||
|
// 清单服务类
|
||||||
|
var classTypes = EditorTools.GetAssignableTypes(typeof(IManifestServices));
|
||||||
|
if (classTypes.Count > 0)
|
||||||
|
{
|
||||||
|
var className = AssetBundleBuilderSetting.GetPackageManifestServicesClassName(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 Services";
|
||||||
|
popupField.style.width = StyleWidth;
|
||||||
|
popupField.RegisterValueChangedCallback(evt =>
|
||||||
|
{
|
||||||
|
AssetBundleBuilderSetting.SetPackageManifestServicesClassName(PackageName, PipelineName, popupField.value.FullName);
|
||||||
|
});
|
||||||
|
container.Add(popupField);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||||
|
return popupField;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var popupField = new PopupField<Type>();
|
||||||
|
popupField.label = "Manifest Services";
|
||||||
|
popupField.style.width = StyleWidth;
|
||||||
|
container.Add(popupField);
|
||||||
|
UIElementsTools.SetElementLabelMinWidth(popupField, LabelMinWidth);
|
||||||
|
return popupField;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: e2e1fae9b05cc554e9ebfee01f2b9333
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,132 @@
|
|||||||
|
#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> _manifestServicesField;
|
||||||
|
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);
|
||||||
|
_manifestServicesField = CreateManifestServicesField(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("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||||
|
{
|
||||||
|
EditorTools.ClearUnityConsole();
|
||||||
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[Build] 打包已经取消");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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.ManifestServices = CreateManifestServicesInstance();
|
||||||
|
|
||||||
|
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:TextField picking-mode="Ignore" label="Build Version" name="BuildVersion" />
|
||||||
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
<ui:Toggle label="Clear Build Cache" name="ClearBuildCache" />
|
||||||
<ui:Toggle label="Use Asset Depend DB" name="UseAssetDependency" />
|
<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="Compression" value="Center" name="Compression" />
|
||||||
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
<uie:EnumField label="File Name Style" value="Center" name="FileNameStyle" />
|
||||||
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
<uie:EnumField label="Copy Buildin File Option" value="Center" name="CopyBuildinFileOption" />
|
||||||
@@ -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
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 33b6cb215b1d7bb4888cb3455b500399
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -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("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||||
|
{
|
||||||
|
EditorTools.ClearUnityConsole();
|
||||||
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[Build] 打包已经取消");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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,124 @@
|
|||||||
|
#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> _manifestServicesField;
|
||||||
|
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);
|
||||||
|
_manifestServicesField = CreateManifestServicesField(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("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||||
|
{
|
||||||
|
EditorTools.ClearUnityConsole();
|
||||||
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[Build] 打包已经取消");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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.ManifestServices = CreateManifestServicesInstance();
|
||||||
|
|
||||||
|
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,145 @@
|
|||||||
|
#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> _manifestServicesField;
|
||||||
|
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);
|
||||||
|
_manifestServicesField = CreateManifestServicesField(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("提示", $"开始构建资源包[{PackageName}]!", "Yes", "No"))
|
||||||
|
{
|
||||||
|
EditorTools.ClearUnityConsole();
|
||||||
|
EditorApplication.delayCall += ExecuteBuild;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogWarning("[Build] 打包已经取消");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <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);
|
||||||
|
var builtinShaderBundleName = GetBuiltinShaderBundleName();
|
||||||
|
|
||||||
|
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.BuiltinShadersBundleName = builtinShaderBundleName;
|
||||||
|
buildParameters.EncryptionServices = CreateEncryptionServicesInstance();
|
||||||
|
buildParameters.ManifestServices = CreateManifestServicesInstance();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#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
|
|
||||||
@@ -259,10 +259,13 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
private List<string> GetAssetTags(AssetBundleCollectorGroup group)
|
||||||
{
|
{
|
||||||
List<string> tags = EditorTools.StringToStringList(group.AssetTags, ';');
|
List<string> result = EditorTools.StringToStringList(AssetTags, ';');
|
||||||
List<string> temper = EditorTools.StringToStringList(AssetTags, ';');
|
if (CollectorType == ECollectorType.MainAssetCollector)
|
||||||
tags.AddRange(temper);
|
{
|
||||||
return tags;
|
List<string> temps = EditorTools.StringToStringList(group.AssetTags, ';');
|
||||||
|
result.AddRange(temps);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
private List<AssetInfo> GetAllDependencies(CollectCommand command, string mainAssetPath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private static string GetRuleDisplayName(string name, Type type)
|
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)
|
if (attribute != null && string.IsNullOrEmpty(attribute.DisplayName) == false)
|
||||||
return attribute.DisplayName;
|
return attribute.DisplayName;
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -762,6 +762,7 @@ namespace YooAsset.Editor
|
|||||||
elementTop.Add(objectField);
|
elementTop.Add(objectField);
|
||||||
var label = objectField.Q<Label>();
|
var label = objectField.Q<Label>();
|
||||||
label.style.minWidth = 63;
|
label.style.minWidth = 63;
|
||||||
|
UIElementsTools.SetObjectFieldShowPath(objectField);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bottom VisualElement
|
// Bottom VisualElement
|
||||||
@@ -851,8 +852,6 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
var collector = selectGroup.Collectors[index];
|
var collector = selectGroup.Collectors[index];
|
||||||
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
var collectObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(collector.CollectPath);
|
||||||
if (collectObject != null)
|
|
||||||
collectObject.name = collector.CollectPath;
|
|
||||||
|
|
||||||
// 注意:非主资源收集器的标签栏需要被冻结
|
// 注意:非主资源收集器的标签栏需要被冻结
|
||||||
var textTags = element.Q<TextField>("TextField1");
|
var textTags = element.Q<TextField>("TextField1");
|
||||||
@@ -885,13 +884,13 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
collector.CollectPath = AssetDatabase.GetAssetPath(evt.newValue);
|
||||||
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
collector.CollectorGUID = AssetDatabase.AssetPathToGUID(collector.CollectPath);
|
||||||
objectField1.value.name = collector.CollectPath;
|
|
||||||
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
AssetBundleCollectorSettingData.ModifyCollector(selectGroup, collector);
|
||||||
if (foldout.value)
|
if (foldout.value)
|
||||||
{
|
{
|
||||||
RefreshFoldout(foldout, selectGroup, collector);
|
RefreshFoldout(foldout, selectGroup, collector);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
UIElementsTools.RefreshObjectFieldShowPath(objectField1);
|
||||||
|
|
||||||
// Collector Type
|
// Collector Type
|
||||||
var popupField0 = element.Q<PopupField<string>>("PopupField0");
|
var popupField0 = element.Q<PopupField<string>>("PopupField0");
|
||||||
|
|||||||
@@ -70,7 +70,11 @@ namespace YooAsset.Editor
|
|||||||
foreach (var cacheInfoPair in _database)
|
foreach (var cacheInfoPair in _database)
|
||||||
{
|
{
|
||||||
var assetPath = cacheInfoPair.Key;
|
var assetPath = cacheInfoPair.Key;
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
|
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath, AssetPathToGUIDOptions.OnlyExistingAssets);
|
||||||
|
#else
|
||||||
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
var assetGUID = AssetDatabase.AssetPathToGUID(assetPath);
|
||||||
|
#endif
|
||||||
if (string.IsNullOrEmpty(assetGUID))
|
if (string.IsNullOrEmpty(assetGUID))
|
||||||
{
|
{
|
||||||
removeList.Add(assetPath);
|
removeList.Add(assetPath);
|
||||||
@@ -173,26 +177,42 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string[] GetDependencies(string assetPath, bool recursive)
|
public string[] GetDependencies(string assetPath, bool recursive)
|
||||||
{
|
{
|
||||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
|
||||||
// 注意:AssetDatabase.GetDependencies()方法返回结果里会包含主资源路径!
|
|
||||||
|
|
||||||
// 注意:机制上不允许存在未收录的资源
|
// 注意:机制上不允许存在未收录的资源
|
||||||
if (_database.ContainsKey(assetPath) == false)
|
if (_database.ContainsKey(assetPath) == false)
|
||||||
{
|
{
|
||||||
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
throw new Exception($"Fatal : can not found cache info : {assetPath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
var result = new HashSet<string> { assetPath };
|
var result = new HashSet<string>();
|
||||||
CollectDependencies(assetPath, result, recursive);
|
|
||||||
|
// 注意:递归收集依赖时,依赖列表中包含主资源
|
||||||
|
if (recursive)
|
||||||
|
result.Add(assetPath);
|
||||||
|
|
||||||
|
// 收集依赖
|
||||||
|
CollectDependencies(assetPath, assetPath, result, recursive);
|
||||||
|
|
||||||
// 注意:AssetDatabase.GetDependencies保持一致,将主资源添加到依赖列表最前面
|
|
||||||
return result.ToArray();
|
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)
|
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)
|
foreach (var dependGUID in cacheInfo.DependGUIDs)
|
||||||
@@ -213,7 +233,7 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// 递归收集依赖
|
// 递归收集依赖
|
||||||
if (recursive)
|
if (recursive)
|
||||||
CollectDependencies(dependAssetPath, result, recursive);
|
CollectDependencies(assetPath, dependAssetPath, result, recursive);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,6 +257,7 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private DependencyInfo CreateDependencyInfo(string assetPath)
|
private DependencyInfo CreateDependencyInfo(string assetPath)
|
||||||
{
|
{
|
||||||
|
// 注意:AssetDatabase.GetDependencies()方法返回结果里会踢出丢失文件!
|
||||||
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
var dependHash = AssetDatabase.GetAssetDependencyHash(assetPath);
|
||||||
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
|
var dependAssetPaths = AssetDatabase.GetDependencies(assetPath, false);
|
||||||
var dependGUIDs = new List<string>();
|
var dependGUIDs = new List<string>();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ namespace YooAsset.Editor
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 忽略的文件类型
|
/// 忽略的文件类型
|
||||||
/// </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>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Reflection;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
@@ -15,22 +14,4 @@ namespace YooAsset.Editor
|
|||||||
this.DisplayName = name;
|
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>
|
/// </summary>
|
||||||
BundleView,
|
BundleView,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 异步操作视图
|
||||||
|
/// </summary>
|
||||||
|
OperationView,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
private readonly Dictionary<int, RemotePlayerSession> _playerSessions = new Dictionary<int, RemotePlayerSession>();
|
||||||
|
|
||||||
private Label _playerName;
|
private ToolbarButton _playerName;
|
||||||
private ToolbarMenu _viewModeMenu;
|
private ToolbarMenu _viewModeMenu;
|
||||||
private SliderInt _frameSlider;
|
private SliderInt _frameSlider;
|
||||||
private DebuggerAssetListViewer _assetListViewer;
|
private DebuggerAssetListViewer _assetListViewer;
|
||||||
private DebuggerBundleListViewer _bundleListViewer;
|
private DebuggerBundleListViewer _bundleListViewer;
|
||||||
|
private DebuggerOperationListViewer _operationListViewer;
|
||||||
|
|
||||||
private EViewMode _viewMode;
|
private EViewMode _viewMode;
|
||||||
private string _searchKeyWord;
|
private string _searchKeyWord;
|
||||||
private DebugReport _currentReport;
|
private DebugReport _currentReport;
|
||||||
private RemotePlayerSession _currentPlayerSession;
|
private RemotePlayerSession _currentPlayerSession;
|
||||||
|
|
||||||
|
private double _lastRepaintTime = 0;
|
||||||
|
private int _nextRepaintIndex = -1;
|
||||||
|
private int _lastRepaintIndex = 0;
|
||||||
private int _rangeIndex = 0;
|
private int _rangeIndex = 0;
|
||||||
|
|
||||||
|
|
||||||
@@ -78,13 +88,14 @@ namespace YooAsset.Editor
|
|||||||
exportBtn.clicked += ExportBtn_clicked;
|
exportBtn.clicked += ExportBtn_clicked;
|
||||||
|
|
||||||
// 用户列表菜单
|
// 用户列表菜单
|
||||||
_playerName = root.Q<Label>("PlayerName");
|
_playerName = root.Q<ToolbarButton>("PlayerName");
|
||||||
_playerName.text = "Editor player";
|
_playerName.text = "Editor player";
|
||||||
|
|
||||||
// 视口模式菜单
|
// 视口模式菜单
|
||||||
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.AssetView);
|
||||||
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), OnViewModeMenuChange, OnViewModeMenuStatusUpdate, EViewMode.BundleView);
|
_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();
|
_viewModeMenu.text = EViewMode.AssetView.ToString();
|
||||||
|
|
||||||
// 搜索栏
|
// 搜索栏
|
||||||
@@ -111,6 +122,9 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
var frameClear = root.Q<ToolbarButton>("FrameClear");
|
||||||
frameClear.clicked += OnFrameClear_clicked;
|
frameClear.clicked += OnFrameClear_clicked;
|
||||||
|
|
||||||
|
var recorderToggle = root.Q<ToggleRecord>("FrameRecord");
|
||||||
|
recorderToggle.RegisterValueChangedCallback(OnRecordToggleValueChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载视图
|
// 加载视图
|
||||||
@@ -121,6 +135,10 @@ namespace YooAsset.Editor
|
|||||||
_bundleListViewer = new DebuggerBundleListViewer();
|
_bundleListViewer = new DebuggerBundleListViewer();
|
||||||
_bundleListViewer.InitViewer();
|
_bundleListViewer.InitViewer();
|
||||||
|
|
||||||
|
// 加载视图
|
||||||
|
_operationListViewer = new DebuggerOperationListViewer();
|
||||||
|
_operationListViewer.InitViewer();
|
||||||
|
|
||||||
// 显示视图
|
// 显示视图
|
||||||
_viewMode = EViewMode.AssetView;
|
_viewMode = EViewMode.AssetView;
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
@@ -129,8 +147,9 @@ namespace YooAsset.Editor
|
|||||||
EditorConnection.instance.Initialize();
|
EditorConnection.instance.Initialize();
|
||||||
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
EditorConnection.instance.RegisterConnection(OnHandleConnectionEvent);
|
||||||
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
EditorConnection.instance.RegisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
EditorConnection.instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||||
RemoteDebuggerInRuntime.EditorHandleDebugReportCallback = OnHandleDebugReport;
|
RemoteEditorConnection.Instance.Initialize();
|
||||||
|
RemoteEditorConnection.Instance.Register(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
@@ -142,9 +161,23 @@ namespace YooAsset.Editor
|
|||||||
// 远程调试
|
// 远程调试
|
||||||
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
EditorConnection.instance.UnregisterConnection(OnHandleConnectionEvent);
|
||||||
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
EditorConnection.instance.UnregisterDisconnection(OnHandleDisconnectionEvent);
|
||||||
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgSendPlayerToEditor, OnHandlePlayerMessage);
|
EditorConnection.instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor, OnHandlePlayerMessage);
|
||||||
|
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor);
|
||||||
_playerSessions.Clear();
|
_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)
|
private void OnHandleConnectionEvent(int playerId)
|
||||||
{
|
{
|
||||||
@@ -158,24 +191,27 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
private void OnHandlePlayerMessage(MessageEventArgs args)
|
private void OnHandlePlayerMessage(MessageEventArgs args)
|
||||||
{
|
{
|
||||||
|
int playerId = args.playerId;
|
||||||
var debugReport = DebugReport.Deserialize(args.data);
|
var debugReport = DebugReport.Deserialize(args.data);
|
||||||
OnHandleDebugReport(args.playerId, debugReport);
|
|
||||||
}
|
if (debugReport.DebuggerVersion != RemoteDebuggerDefine.DebuggerVersion)
|
||||||
private void OnHandleDebugReport(int playerId, DebugReport debugReport)
|
{
|
||||||
{
|
Debug.LogWarning($"Debugger versions are inconsistent : {debugReport.DebuggerVersion} != {RemoteDebuggerDefine.DebuggerVersion}");
|
||||||
Debug.Log($"Handle player {playerId} debug report !");
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//Debug.Log($"Handle player {playerId} debug report !");
|
||||||
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
_currentPlayerSession = GetOrCreatePlayerSession(playerId);
|
||||||
_currentPlayerSession.AddDebugReport(debugReport);
|
_currentPlayerSession.AddDebugReport(debugReport);
|
||||||
_frameSlider.highValue = _currentPlayerSession.MaxRangeValue;
|
_nextRepaintIndex = _currentPlayerSession.MaxRangeValue;
|
||||||
_frameSlider.value = _currentPlayerSession.MaxRangeValue;
|
|
||||||
UpdateFrameView(_currentPlayerSession);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnFrameSliderChange(int sliderValue)
|
private void OnFrameSliderChange(int sliderValue)
|
||||||
{
|
{
|
||||||
if (_currentPlayerSession != null)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(sliderValue); ;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
RepaintFrame(_rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameLast_clicked()
|
private void OnFrameLast_clicked()
|
||||||
@@ -184,7 +220,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex - 1);
|
||||||
_frameSlider.value = _rangeIndex;
|
_frameSlider.value = _rangeIndex;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
RepaintFrame(_rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameNext_clicked()
|
private void OnFrameNext_clicked()
|
||||||
@@ -193,56 +229,37 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
_rangeIndex = _currentPlayerSession.ClampRangeIndex(_rangeIndex + 1);
|
||||||
_frameSlider.value = _rangeIndex;
|
_frameSlider.value = _rangeIndex;
|
||||||
UpdateFrameView(_currentPlayerSession, _rangeIndex);
|
RepaintFrame(_rangeIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnFrameClear_clicked()
|
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)
|
if (_currentPlayerSession != null)
|
||||||
{
|
{
|
||||||
_frameSlider.label = $"Frame:";
|
|
||||||
_frameSlider.value = 0;
|
|
||||||
_frameSlider.lowValue = 0;
|
|
||||||
_frameSlider.highValue = 0;
|
|
||||||
_currentPlayerSession.ClearDebugReport();
|
_currentPlayerSession.ClearDebugReport();
|
||||||
_assetListViewer.ClearView();
|
|
||||||
_bundleListViewer.ClearView();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void OnRecordToggleValueChange(ChangeEvent<bool> evt)
|
||||||
private RemotePlayerSession GetOrCreatePlayerSession(int playerId)
|
|
||||||
{
|
{
|
||||||
if (_playerSessions.TryGetValue(playerId, out RemotePlayerSession session))
|
// 发送采集数据的命令
|
||||||
{
|
RemoteCommand command = new RemoteCommand();
|
||||||
return session;
|
command.CommandType = (int)ERemoteCommand.SampleAuto;
|
||||||
}
|
command.CommandParam = evt.newValue ? "open" : "close";
|
||||||
else
|
byte[] data = RemoteCommand.Serialize(command);
|
||||||
{
|
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||||
RemotePlayerSession newSession = new RemotePlayerSession(playerId);
|
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||||
_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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SampleBtn_onClick()
|
private void SampleBtn_onClick()
|
||||||
@@ -252,8 +269,8 @@ namespace YooAsset.Editor
|
|||||||
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
command.CommandType = (int)ERemoteCommand.SampleOnce;
|
||||||
command.CommandParam = string.Empty;
|
command.CommandParam = string.Empty;
|
||||||
byte[] data = RemoteCommand.Serialize(command);
|
byte[] data = RemoteCommand.Serialize(command);
|
||||||
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgSendEditorToPlayer, data);
|
EditorConnection.instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||||
RemoteDebuggerInRuntime.EditorRequestDebugReport();
|
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
|
||||||
}
|
}
|
||||||
private void ExportBtn_clicked()
|
private void ExportBtn_clicked()
|
||||||
{
|
{
|
||||||
@@ -279,6 +296,7 @@ namespace YooAsset.Editor
|
|||||||
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
string filePath = $"{resultPath}/{nameof(DebugReport)}_{_currentReport.FrameCount}.json";
|
||||||
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
string fileContent = JsonUtility.ToJson(_currentReport, true);
|
||||||
FileUtility.WriteAllText(filePath, fileContent);
|
FileUtility.WriteAllText(filePath, fileContent);
|
||||||
|
Debug.Log($"Debug report file saved : {filePath}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||||
@@ -288,6 +306,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_assetListViewer.RebuildView(_searchKeyWord);
|
_assetListViewer.RebuildView(_searchKeyWord);
|
||||||
_bundleListViewer.RebuildView(_searchKeyWord);
|
_bundleListViewer.RebuildView(_searchKeyWord);
|
||||||
|
_operationListViewer.RebuildView(_searchKeyWord);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void OnViewModeMenuChange(DropdownMenuAction action)
|
private void OnViewModeMenuChange(DropdownMenuAction action)
|
||||||
@@ -303,16 +322,27 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
_assetListViewer.AttachParent(root);
|
_assetListViewer.AttachParent(root);
|
||||||
_bundleListViewer.DetachParent();
|
_bundleListViewer.DetachParent();
|
||||||
|
_operationListViewer.DetachParent();
|
||||||
}
|
}
|
||||||
else if (viewMode == EViewMode.BundleView)
|
else if (viewMode == EViewMode.BundleView)
|
||||||
{
|
{
|
||||||
_assetListViewer.DetachParent();
|
_assetListViewer.DetachParent();
|
||||||
_bundleListViewer.AttachParent(root);
|
_bundleListViewer.AttachParent(root);
|
||||||
|
_operationListViewer.DetachParent();
|
||||||
|
}
|
||||||
|
else if (viewMode == EViewMode.OperationView)
|
||||||
|
{
|
||||||
|
_assetListViewer.DetachParent();
|
||||||
|
_bundleListViewer.DetachParent();
|
||||||
|
_operationListViewer.AttachParent(root);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new NotImplementedException(viewMode.ToString());
|
throw new NotImplementedException(viewMode.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 重新绘制该帧数据
|
||||||
|
RepaintFrame(_lastRepaintIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
|
||||||
@@ -323,6 +353,63 @@ namespace YooAsset.Editor
|
|||||||
else
|
else
|
||||||
return DropdownMenuAction.Status.Normal;
|
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
|
#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">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
|
||||||
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
<uie:Toolbar name="TopToolbar" style="display: flex;">
|
||||||
<ui:Label text="Player" display-tooltip-when-elided="true" name="PlayerName" style="width: 200px; -unity-text-align: lower-left; padding-left: 5px;" />
|
<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: 100px; flex-grow: 0;" />
|
<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: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="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;" />
|
<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="FrameLast" />
|
||||||
<uie:ToolbarButton text=" >> " display-tooltip-when-elided="true" name="FrameNext" />
|
<uie:ToolbarButton text=" >> " display-tooltip-when-elided="true" name="FrameNext" />
|
||||||
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
|
<uie:ToolbarButton text="Clear" display-tooltip-when-elided="true" name="FrameClear" />
|
||||||
|
<YooAsset.Editor.ToggleRecord name="FrameRecord" style="width: 20px;" />
|
||||||
</uie:Toolbar>
|
</uie:Toolbar>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -1,12 +1,13 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
namespace YooAsset.Editor
|
||||||
{
|
{
|
||||||
internal class RemotePlayerSession
|
internal class RemotePlayerSession
|
||||||
{
|
{
|
||||||
private readonly List<DebugReport> _reportList = new List<DebugReport>();
|
private readonly Queue<DebugReport> _reports = new Queue<DebugReport>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户ID
|
/// 用户ID
|
||||||
@@ -29,7 +30,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
int index = _reportList.Count - 1;
|
int index = _reports.Count - 1;
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
index = 0;
|
index = 0;
|
||||||
return index;
|
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;
|
PlayerId = playerId;
|
||||||
MaxReportCount = maxReportCount;
|
MaxReportCount = maxReportCount;
|
||||||
@@ -48,7 +49,7 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearDebugReport()
|
public void ClearDebugReport()
|
||||||
{
|
{
|
||||||
_reportList.Clear();
|
_reports.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -59,9 +60,9 @@ namespace YooAsset.Editor
|
|||||||
if (report == null)
|
if (report == null)
|
||||||
Debug.LogWarning("Invalid debug report data !");
|
Debug.LogWarning("Invalid debug report data !");
|
||||||
|
|
||||||
if (_reportList.Count >= MaxReportCount)
|
if (_reports.Count >= MaxReportCount)
|
||||||
_reportList.RemoveAt(0);
|
_reports.Dequeue();
|
||||||
_reportList.Add(report);
|
_reports.Enqueue(report);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -69,11 +70,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public DebugReport GetDebugReport(int rangeIndex)
|
public DebugReport GetDebugReport(int rangeIndex)
|
||||||
{
|
{
|
||||||
if (_reportList.Count == 0)
|
if (_reports.Count == 0)
|
||||||
return null;
|
return null;
|
||||||
if (rangeIndex < 0 || rangeIndex >= _reportList.Count)
|
if (rangeIndex < 0 || rangeIndex >= _reports.Count)
|
||||||
return null;
|
return null;
|
||||||
return _reportList[rangeIndex];
|
return _reports.ElementAt(rangeIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -24,10 +24,9 @@ namespace YooAsset.Editor
|
|||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private TableView _providerTableView;
|
private TableViewer _providerTableView;
|
||||||
private TableView _dependTableView;
|
private TableViewer _dependTableView;
|
||||||
|
|
||||||
private DebugReport _debugReport;
|
|
||||||
private List<ITableData> _sourceDatas;
|
private List<ITableData> _sourceDatas;
|
||||||
|
|
||||||
|
|
||||||
@@ -45,21 +44,20 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源列表
|
// 资源列表
|
||||||
_providerTableView = _root.Q<TableView>("TopTableView");
|
_providerTableView = _root.Q<TableViewer>("TopTableView");
|
||||||
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
|
_providerTableView.SelectionChangedEvent = OnProviderTableViewSelectionChanged;
|
||||||
CreateAssetTableViewColumns();
|
CreateAssetTableViewColumns();
|
||||||
|
|
||||||
// 依赖列表
|
// 依赖列表
|
||||||
_dependTableView = _root.Q<TableView>("BottomTableView");
|
_dependTableView = _root.Q<TableViewer>("BottomTableView");
|
||||||
CreateDependTableViewColumns();
|
CreateDependTableViewColumns();
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
// 面板分屏
|
||||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
topGroup.style.minHeight = 100;
|
topGroup.style.minHeight = 100;
|
||||||
bottomGroup.style.minHeight = 100f;
|
bottomGroup.style.minHeight = 100f;
|
||||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
private void CreateAssetTableViewColumns()
|
private void CreateAssetTableViewColumns()
|
||||||
{
|
{
|
||||||
@@ -90,6 +88,7 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = true;
|
columnStyle.Stretchable = true;
|
||||||
columnStyle.Searchable = true;
|
columnStyle.Searchable = true;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
var column = new TableColumn("AssetPath", "Asset Path", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -126,13 +125,13 @@ namespace YooAsset.Editor
|
|||||||
_providerTableView.AddColumn(column);
|
_providerTableView.AddColumn(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpawnTime
|
// BeginTime
|
||||||
{
|
{
|
||||||
var columnStyle = new ColumnStyle(100);
|
var columnStyle = new ColumnStyle(100);
|
||||||
columnStyle.Stretchable = false;
|
columnStyle.Stretchable = false;
|
||||||
columnStyle.Searchable = false;
|
columnStyle.Searchable = false;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
|
var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
@@ -149,10 +148,11 @@ namespace YooAsset.Editor
|
|||||||
|
|
||||||
// LoadingTime
|
// LoadingTime
|
||||||
{
|
{
|
||||||
var columnStyle = new ColumnStyle(100);
|
var columnStyle = new ColumnStyle(130);
|
||||||
columnStyle.Stretchable = false;
|
columnStyle.Stretchable = false;
|
||||||
columnStyle.Searchable = false;
|
columnStyle.Searchable = false;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Units = "ms";
|
||||||
var column = new TableColumn("LoadingTime", "Loading Time", columnStyle);
|
var column = new TableColumn("LoadingTime", "Loading Time", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -226,6 +226,7 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = true;
|
columnStyle.Stretchable = true;
|
||||||
columnStyle.Searchable = true;
|
columnStyle.Searchable = true;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
var column = new TableColumn("DependBundles", "Depend Bundles", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -279,7 +280,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
var dependTableData = data as DependTableData;
|
var dependTableData = data as DependTableData;
|
||||||
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed)
|
if (dependTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = new StyleColor(Color.white);
|
textColor = new StyleColor(Color.white);
|
||||||
@@ -297,8 +298,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport)
|
public void FillViewData(DebugReport debugReport)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
|
||||||
|
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_providerTableView.ClearAll(false, true);
|
_providerTableView.ClearAll(false, true);
|
||||||
_dependTableView.ClearAll(false, true);
|
_dependTableView.ClearAll(false, true);
|
||||||
@@ -315,7 +314,7 @@ namespace YooAsset.Editor
|
|||||||
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
rowData.AddAssetPathCell("PackageName", packageData.PackageName);
|
||||||
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
rowData.AddStringValueCell("AssetPath", providerInfo.AssetPath);
|
||||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||||
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
|
rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
|
||||||
rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime);
|
rowData.AddLongValueCell("LoadingTime", providerInfo.LoadingTime);
|
||||||
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
||||||
rowData.AddStringValueCell("Status", providerInfo.Status.ToString());
|
rowData.AddStringValueCell("Status", providerInfo.Status.ToString());
|
||||||
@@ -333,10 +332,11 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
|
||||||
_providerTableView.ClearAll(false, true);
|
_providerTableView.ClearAll(false, true);
|
||||||
|
_providerTableView.RebuildView();
|
||||||
|
|
||||||
_dependTableView.ClearAll(false, true);
|
_dependTableView.ClearAll(false, true);
|
||||||
RebuildView(null);
|
_dependTableView.RebuildView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -345,10 +345,12 @@ namespace YooAsset.Editor
|
|||||||
public void RebuildView(string searchKeyWord)
|
public void RebuildView(string searchKeyWord)
|
||||||
{
|
{
|
||||||
// 搜索匹配
|
// 搜索匹配
|
||||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
if (_sourceDatas != null)
|
||||||
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
|
|
||||||
// 重建视图
|
// 重建视图
|
||||||
_providerTableView.RebuildView();
|
_providerTableView.RebuildView();
|
||||||
|
_dependTableView.RebuildView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="TopTableView" />
|
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||||
<YooAsset.Editor.TableView name="BottomTableView" />
|
<YooAsset.Editor.TableViewer name="BottomTableView" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -28,11 +28,10 @@ namespace YooAsset.Editor
|
|||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private TableView _bundleTableView;
|
private TableViewer _bundleTableView;
|
||||||
private TableView _usingTableView;
|
private TableViewer _usingTableView;
|
||||||
private TableView _referenceTableView;
|
private TableViewer _referenceTableView;
|
||||||
|
|
||||||
private DebugReport _debugReport;
|
|
||||||
private List<ITableData> _sourceDatas;
|
private List<ITableData> _sourceDatas;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -49,26 +48,25 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
_bundleTableView = _root.Q<TableView>("BundleTableView");
|
_bundleTableView = _root.Q<TableViewer>("BundleTableView");
|
||||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||||
CreateBundleTableViewColumns();
|
CreateBundleTableViewColumns();
|
||||||
|
|
||||||
// 使用列表
|
// 使用列表
|
||||||
_usingTableView = _root.Q<TableView>("UsingTableView");
|
_usingTableView = _root.Q<TableViewer>("UsingTableView");
|
||||||
CreateUsingTableViewColumns();
|
CreateUsingTableViewColumns();
|
||||||
|
|
||||||
// 引用列表
|
// 引用列表
|
||||||
_referenceTableView = _root.Q<TableView>("ReferenceTableView");
|
_referenceTableView = _root.Q<TableViewer>("ReferenceTableView");
|
||||||
CreateReferenceTableViewColumns();
|
CreateReferenceTableViewColumns();
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
// 面板分屏
|
||||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
topGroup.style.minHeight = 100;
|
topGroup.style.minHeight = 100;
|
||||||
bottomGroup.style.minHeight = 100f;
|
bottomGroup.style.minHeight = 100f;
|
||||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
PanelSplitView.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
UIElementsTools.SplitVerticalPanel(bottomGroup, _usingTableView, _referenceTableView);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
private void CreateBundleTableViewColumns()
|
private void CreateBundleTableViewColumns()
|
||||||
{
|
{
|
||||||
@@ -99,6 +97,7 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = true;
|
columnStyle.Stretchable = true;
|
||||||
columnStyle.Searchable = true;
|
columnStyle.Searchable = true;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
var column = new TableColumn("BundleName", "Bundle Name", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -152,7 +151,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
var bundleTableData = data as BundleTableData;
|
var bundleTableData = data as BundleTableData;
|
||||||
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed)
|
if (bundleTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = new StyleColor(Color.white);
|
textColor = new StyleColor(Color.white);
|
||||||
@@ -172,6 +171,7 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = true;
|
columnStyle.Stretchable = true;
|
||||||
columnStyle.Searchable = true;
|
columnStyle.Searchable = true;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
var column = new TableColumn("UsingAssets", "Using Assets", columnStyle);
|
var column = new TableColumn("UsingAssets", "Using Assets", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -208,13 +208,13 @@ namespace YooAsset.Editor
|
|||||||
_usingTableView.AddColumn(column);
|
_usingTableView.AddColumn(column);
|
||||||
}
|
}
|
||||||
|
|
||||||
// SpawnTime
|
// BeginTime
|
||||||
{
|
{
|
||||||
var columnStyle = new ColumnStyle(100);
|
var columnStyle = new ColumnStyle(100);
|
||||||
columnStyle.Stretchable = false;
|
columnStyle.Stretchable = false;
|
||||||
columnStyle.Searchable = false;
|
columnStyle.Searchable = false;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
var column = new TableColumn("SpawnTime", "Spawn Time", columnStyle);
|
var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
var label = new Label();
|
var label = new Label();
|
||||||
@@ -287,6 +287,7 @@ namespace YooAsset.Editor
|
|||||||
columnStyle.Stretchable = true;
|
columnStyle.Stretchable = true;
|
||||||
columnStyle.Searchable = true;
|
columnStyle.Searchable = true;
|
||||||
columnStyle.Sortable = true;
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
|
var column = new TableColumn("ReferenceBundle", "Reference Bundle", columnStyle);
|
||||||
column.MakeCell = () =>
|
column.MakeCell = () =>
|
||||||
{
|
{
|
||||||
@@ -340,7 +341,7 @@ namespace YooAsset.Editor
|
|||||||
{
|
{
|
||||||
StyleColor textColor;
|
StyleColor textColor;
|
||||||
var feferenceTableData = data as ReferenceTableData;
|
var feferenceTableData = data as ReferenceTableData;
|
||||||
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed)
|
if (feferenceTableData.BundleInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
textColor = new StyleColor(Color.yellow);
|
textColor = new StyleColor(Color.yellow);
|
||||||
else
|
else
|
||||||
textColor = new StyleColor(Color.white);
|
textColor = new StyleColor(Color.white);
|
||||||
@@ -358,8 +359,6 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void FillViewData(DebugReport debugReport)
|
public void FillViewData(DebugReport debugReport)
|
||||||
{
|
{
|
||||||
_debugReport = debugReport;
|
|
||||||
|
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
_bundleTableView.ClearAll(false, true);
|
_bundleTableView.ClearAll(false, true);
|
||||||
_usingTableView.ClearAll(false, true);
|
_usingTableView.ClearAll(false, true);
|
||||||
@@ -392,11 +391,12 @@ namespace YooAsset.Editor
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void ClearView()
|
public void ClearView()
|
||||||
{
|
{
|
||||||
_debugReport = null;
|
|
||||||
_bundleTableView.ClearAll(false, true);
|
_bundleTableView.ClearAll(false, true);
|
||||||
_bundleTableView.RebuildView();
|
_bundleTableView.RebuildView();
|
||||||
|
|
||||||
_usingTableView.ClearAll(false, true);
|
_usingTableView.ClearAll(false, true);
|
||||||
_usingTableView.RebuildView();
|
_usingTableView.RebuildView();
|
||||||
|
|
||||||
_referenceTableView.ClearAll(false, true);
|
_referenceTableView.ClearAll(false, true);
|
||||||
_referenceTableView.RebuildView();
|
_referenceTableView.RebuildView();
|
||||||
}
|
}
|
||||||
@@ -407,10 +407,13 @@ namespace YooAsset.Editor
|
|||||||
public void RebuildView(string searchKeyWord)
|
public void RebuildView(string searchKeyWord)
|
||||||
{
|
{
|
||||||
// 搜索匹配
|
// 搜索匹配
|
||||||
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
if(_sourceDatas != null)
|
||||||
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
|
|
||||||
// 重建视图
|
// 重建视图
|
||||||
_bundleTableView.RebuildView();
|
_bundleTableView.RebuildView();
|
||||||
|
_usingTableView.RebuildView();
|
||||||
|
_referenceTableView.RebuildView();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -448,7 +451,7 @@ namespace YooAsset.Editor
|
|||||||
rowData.ProviderInfo = providerInfo;
|
rowData.ProviderInfo = providerInfo;
|
||||||
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
|
rowData.AddStringValueCell("UsingAssets", providerInfo.AssetPath);
|
||||||
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
rowData.AddStringValueCell("SpawnScene", providerInfo.SpawnScene);
|
||||||
rowData.AddStringValueCell("SpawnTime", providerInfo.SpawnTime);
|
rowData.AddStringValueCell("BeginTime", providerInfo.BeginTime);
|
||||||
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
rowData.AddLongValueCell("RefCount", providerInfo.RefCount);
|
||||||
rowData.AddStringValueCell("Status", providerInfo.Status);
|
rowData.AddStringValueCell("Status", providerInfo.Status);
|
||||||
sourceDatas.Add(rowData);
|
sourceDatas.Add(rowData);
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="BundleTableView" />
|
<YooAsset.Editor.TableViewer name="BundleTableView" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 400px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="BottomGroup" style="height: 400px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="UsingTableView" />
|
<YooAsset.Editor.TableViewer name="UsingTableView" />
|
||||||
<YooAsset.Editor.TableView name="ReferenceTableView" />
|
<YooAsset.Editor.TableViewer name="ReferenceTableView" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -0,0 +1,509 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
internal class DebuggerOperationListViewer
|
||||||
|
{
|
||||||
|
private class OperationTableData : DefaultTableData
|
||||||
|
{
|
||||||
|
public DebugPackageData PackageData;
|
||||||
|
public DebugOperationInfo OperationInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
private VisualTreeAsset _visualAsset;
|
||||||
|
private TemplateContainer _root;
|
||||||
|
|
||||||
|
private TableViewer _operationTableView;
|
||||||
|
private Toolbar _bottomToolbar;
|
||||||
|
private TreeViewer _childTreeView;
|
||||||
|
|
||||||
|
private List<ITableData> _sourceDatas;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化页面
|
||||||
|
/// </summary>
|
||||||
|
public void InitViewer()
|
||||||
|
{
|
||||||
|
// 加载布局文件
|
||||||
|
_visualAsset = UxmlLoader.LoadWindowUXML<DebuggerOperationListViewer>();
|
||||||
|
if (_visualAsset == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_root = _visualAsset.CloneTree();
|
||||||
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
|
// 任务列表
|
||||||
|
_operationTableView = _root.Q<TableViewer>("TopTableView");
|
||||||
|
_operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged;
|
||||||
|
CreateOperationTableViewColumns();
|
||||||
|
|
||||||
|
// 底部标题栏
|
||||||
|
_bottomToolbar = _root.Q<Toolbar>("BottomToolbar");
|
||||||
|
CreateBottomToolbarHeaders();
|
||||||
|
|
||||||
|
// 子列表
|
||||||
|
_childTreeView = _root.Q<TreeViewer>("BottomTreeView");
|
||||||
|
_childTreeView.makeItem = MakeTreeViewItem;
|
||||||
|
_childTreeView.bindItem = BindTreeViewItem;
|
||||||
|
|
||||||
|
// 面板分屏
|
||||||
|
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||||
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
|
topGroup.style.minHeight = 100;
|
||||||
|
bottomGroup.style.minHeight = 100f;
|
||||||
|
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
|
}
|
||||||
|
private void CreateOperationTableViewColumns()
|
||||||
|
{
|
||||||
|
// PackageName
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(200);
|
||||||
|
columnStyle.Searchable = true;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("PackageName", "Package Name", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// OperationName
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(300, 300, 600);
|
||||||
|
columnStyle.Stretchable = true;
|
||||||
|
columnStyle.Searchable = true;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Counter = true;
|
||||||
|
var column = new TableColumn("OperationName", "Operation Name", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Priority
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(100);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("Priority", "Priority", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Progress
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(100);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = false;
|
||||||
|
var column = new TableColumn("Progress", "Progress", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeginTime
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(100);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("BeginTime", "Begin Time", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProcessTime
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(130);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
columnStyle.Units = "ms";
|
||||||
|
var column = new TableColumn("ProcessTime", "Process Time", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(100);
|
||||||
|
columnStyle.Stretchable = false;
|
||||||
|
columnStyle.Searchable = false;
|
||||||
|
columnStyle.Sortable = true;
|
||||||
|
var column = new TableColumn("Status", "Status", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
return label;
|
||||||
|
};
|
||||||
|
column.BindCell = (VisualElement element, ITableData data, ITableCell cell) =>
|
||||||
|
{
|
||||||
|
StyleColor textColor;
|
||||||
|
var operationTableData = data as OperationTableData;
|
||||||
|
if (operationTableData.OperationInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
|
textColor = new StyleColor(Color.yellow);
|
||||||
|
else
|
||||||
|
textColor = new StyleColor(Color.white);
|
||||||
|
|
||||||
|
var infoLabel = element as Label;
|
||||||
|
infoLabel.text = (string)cell.GetDisplayObject();
|
||||||
|
infoLabel.style.color = textColor;
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desc
|
||||||
|
{
|
||||||
|
var columnStyle = new ColumnStyle(500, 500, 1000);
|
||||||
|
columnStyle.Stretchable = true;
|
||||||
|
columnStyle.Searchable = true;
|
||||||
|
var column = new TableColumn("Desc", "Desc", columnStyle);
|
||||||
|
column.MakeCell = () =>
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
_operationTableView.AddColumn(column);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void CreateBottomToolbarHeaders()
|
||||||
|
{
|
||||||
|
// OperationName
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "OperationName";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 315;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Progress
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "Progress";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 100;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeginTime
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "BeginTime";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 100;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProcessTime
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "ProcessTime (ms)";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 130;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "Status";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 100;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desc
|
||||||
|
{
|
||||||
|
ToolbarButton button = new ToolbarButton();
|
||||||
|
button.text = "Desc";
|
||||||
|
button.style.flexGrow = 0;
|
||||||
|
button.style.width = 500;
|
||||||
|
_bottomToolbar.Add(button);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 填充页面数据
|
||||||
|
/// </summary>
|
||||||
|
public void FillViewData(DebugReport debugReport)
|
||||||
|
{
|
||||||
|
// 清空旧数据
|
||||||
|
_operationTableView.ClearAll(false, true);
|
||||||
|
_childTreeView.ClearAll();
|
||||||
|
_childTreeView.RebuildView();
|
||||||
|
|
||||||
|
// 填充数据源
|
||||||
|
_sourceDatas = new List<ITableData>(1000);
|
||||||
|
foreach (var packageData in debugReport.PackageDatas)
|
||||||
|
{
|
||||||
|
foreach (var operationInfo in packageData.OperationInfos)
|
||||||
|
{
|
||||||
|
var rowData = new OperationTableData();
|
||||||
|
rowData.PackageData = packageData;
|
||||||
|
rowData.OperationInfo = operationInfo;
|
||||||
|
rowData.AddStringValueCell("PackageName", packageData.PackageName);
|
||||||
|
rowData.AddStringValueCell("OperationName", operationInfo.OperationName);
|
||||||
|
rowData.AddLongValueCell("Priority", operationInfo.Priority);
|
||||||
|
rowData.AddDoubleValueCell("Progress", operationInfo.Progress);
|
||||||
|
rowData.AddStringValueCell("BeginTime", operationInfo.BeginTime);
|
||||||
|
rowData.AddLongValueCell("LoadingTime", operationInfo.ProcessTime);
|
||||||
|
rowData.AddStringValueCell("Status", operationInfo.Status.ToString());
|
||||||
|
rowData.AddStringValueCell("Desc", operationInfo.OperationDesc);
|
||||||
|
_sourceDatas.Add(rowData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_operationTableView.itemsSource = _sourceDatas;
|
||||||
|
|
||||||
|
// 重建视图
|
||||||
|
RebuildView(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清空页面
|
||||||
|
/// </summary>
|
||||||
|
public void ClearView()
|
||||||
|
{
|
||||||
|
_operationTableView.ClearAll(false, true);
|
||||||
|
_operationTableView.RebuildView();
|
||||||
|
|
||||||
|
_childTreeView.ClearAll();
|
||||||
|
_childTreeView.RebuildView();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重建视图
|
||||||
|
/// </summary>
|
||||||
|
public void RebuildView(string searchKeyWord)
|
||||||
|
{
|
||||||
|
// 搜索匹配
|
||||||
|
if(_sourceDatas != null)
|
||||||
|
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
|
||||||
|
|
||||||
|
// 重建视图
|
||||||
|
_operationTableView.RebuildView();
|
||||||
|
_childTreeView.RebuildView();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 挂接到父类页面上
|
||||||
|
/// </summary>
|
||||||
|
public void AttachParent(VisualElement parent)
|
||||||
|
{
|
||||||
|
parent.Add(_root);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从父类页面脱离开
|
||||||
|
/// </summary>
|
||||||
|
public void DetachParent()
|
||||||
|
{
|
||||||
|
_root.RemoveFromHierarchy();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnOperationTableViewSelectionChanged(ITableData data)
|
||||||
|
{
|
||||||
|
var operationTableData = data as OperationTableData;
|
||||||
|
DebugPackageData packageData = operationTableData.PackageData;
|
||||||
|
DebugOperationInfo operationInfo = operationTableData.OperationInfo;
|
||||||
|
|
||||||
|
TreeNode rootNode = new TreeNode(operationInfo);
|
||||||
|
FillTreeData(operationInfo, rootNode);
|
||||||
|
_childTreeView.ClearAll();
|
||||||
|
_childTreeView.SetRootItem(rootNode);
|
||||||
|
_childTreeView.RebuildView();
|
||||||
|
}
|
||||||
|
private void MakeTreeViewItem(VisualElement container)
|
||||||
|
{
|
||||||
|
// OperationName
|
||||||
|
{
|
||||||
|
Label label = new Label();
|
||||||
|
label.name = "OperationName";
|
||||||
|
label.style.flexGrow = 0f;
|
||||||
|
label.style.width = 300;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Progress
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Progress";
|
||||||
|
label.style.flexGrow = 0f;
|
||||||
|
label.style.width = 100;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeginTime
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "BeginTime";
|
||||||
|
label.style.flexGrow = 0f;
|
||||||
|
label.style.width = 100;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProcessTime
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "ProcessTime";
|
||||||
|
label.style.flexGrow = 0f;
|
||||||
|
label.style.width = 130;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status
|
||||||
|
{
|
||||||
|
var label = new Label();
|
||||||
|
label.name = "Status";
|
||||||
|
label.style.flexGrow = 0f;
|
||||||
|
label.style.width = 100;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desc
|
||||||
|
{
|
||||||
|
Label label = new Label();
|
||||||
|
label.name = "Desc";
|
||||||
|
label.style.flexGrow = 1f;
|
||||||
|
label.style.width = 500;
|
||||||
|
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||||
|
container.Add(label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void BindTreeViewItem(VisualElement container, object userData)
|
||||||
|
{
|
||||||
|
var operationInfo = (DebugOperationInfo)userData;
|
||||||
|
|
||||||
|
// OperationName
|
||||||
|
{
|
||||||
|
var label = container.Q<Label>("OperationName");
|
||||||
|
label.text = operationInfo.OperationName;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Progress
|
||||||
|
{
|
||||||
|
var label = container.Q<Label>("Progress");
|
||||||
|
label.text = operationInfo.Progress.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// BeginTime
|
||||||
|
{
|
||||||
|
var label = container.Q<Label>("BeginTime");
|
||||||
|
label.text = operationInfo.BeginTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProcessTime
|
||||||
|
{
|
||||||
|
var label = container.Q<Label>("ProcessTime");
|
||||||
|
label.text = operationInfo.ProcessTime.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Status
|
||||||
|
{
|
||||||
|
StyleColor textColor;
|
||||||
|
if (operationInfo.Status == EOperationStatus.Failed.ToString())
|
||||||
|
textColor = new StyleColor(Color.yellow);
|
||||||
|
else
|
||||||
|
textColor = new StyleColor(Color.white);
|
||||||
|
|
||||||
|
var label = container.Q<Label>("Status");
|
||||||
|
label.text = operationInfo.Status;
|
||||||
|
label.style.color = textColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Desc
|
||||||
|
{
|
||||||
|
var label = container.Q<Label>("Desc");
|
||||||
|
label.text = operationInfo.OperationDesc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void FillTreeData(DebugOperationInfo parentOperation, TreeNode rootNode)
|
||||||
|
{
|
||||||
|
foreach (var childOperation in parentOperation.Childs)
|
||||||
|
{
|
||||||
|
var childNode = new TreeNode(childOperation);
|
||||||
|
rootNode.AddChild(childNode);
|
||||||
|
FillTreeData(childOperation, childNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: faabdaf3787cba6438d2300f7f71e26f
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
|
||||||
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
|
<YooAsset.Editor.TableViewer name="TopTableView" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
<ui:VisualElement name="BottomGroup" style="flex-grow: 1;">
|
||||||
|
<uie:Toolbar name="BottomToolbar" />
|
||||||
|
<YooAsset.Editor.TreeViewer name="BottomTreeView" />
|
||||||
|
</ui:VisualElement>
|
||||||
|
</ui:UXML>
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7147c7108cba1bb4dba3a2cfc758ad43
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
||||||
@@ -71,7 +71,8 @@ namespace YooAsset.Editor
|
|||||||
public bool UseAssetDependencyDB;
|
public bool UseAssetDependencyDB;
|
||||||
public bool EnableSharePackRule;
|
public bool EnableSharePackRule;
|
||||||
public bool SingleReferencedPackAlone;
|
public bool SingleReferencedPackAlone;
|
||||||
public string EncryptionClassName;
|
public string EncryptionServicesClassName;
|
||||||
|
public string ManifestServicesClassName;
|
||||||
public EFileNameStyle FileNameStyle;
|
public EFileNameStyle FileNameStyle;
|
||||||
|
|
||||||
// 引擎参数
|
// 引擎参数
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace YooAsset.Editor
|
|||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private TableView _assetTableView;
|
private TableViewer _assetTableView;
|
||||||
private TableView _dependTableView;
|
private TableViewer _dependTableView;
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
private string _reportFilePath;
|
private string _reportFilePath;
|
||||||
@@ -46,23 +46,22 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源列表
|
// 资源列表
|
||||||
_assetTableView = _root.Q<TableView>("TopTableView");
|
_assetTableView = _root.Q<TableViewer>("TopTableView");
|
||||||
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
|
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
|
||||||
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
|
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
|
||||||
CreateAssetTableViewColumns();
|
CreateAssetTableViewColumns();
|
||||||
|
|
||||||
// 依赖列表
|
// 依赖列表
|
||||||
_dependTableView = _root.Q<TableView>("BottomTableView");
|
_dependTableView = _root.Q<TableViewer>("BottomTableView");
|
||||||
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
|
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||||
CreateDependTableViewColumns();
|
CreateDependTableViewColumns();
|
||||||
|
|
||||||
#if UNITY_2020_3_OR_NEWER
|
// 面板分屏
|
||||||
var topGroup = _root.Q<VisualElement>("TopGroup");
|
var topGroup = _root.Q<VisualElement>("TopGroup");
|
||||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
topGroup.style.minHeight = 100;
|
topGroup.style.minHeight = 100;
|
||||||
bottomGroup.style.minHeight = 100f;
|
bottomGroup.style.minHeight = 100f;
|
||||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
private void CreateAssetTableViewColumns()
|
private void CreateAssetTableViewColumns()
|
||||||
{
|
{
|
||||||
@@ -239,9 +238,8 @@ namespace YooAsset.Editor
|
|||||||
ReportAssetInfo assetInfo = assetTableData.AssetInfo;
|
ReportAssetInfo assetInfo = assetTableData.AssetInfo;
|
||||||
|
|
||||||
// 填充依赖数据
|
// 填充依赖数据
|
||||||
var mainBundle = _buildReport.GetBundleInfo(assetInfo.MainBundleName);
|
var sourceDatas = new List<ITableData>(assetInfo.DependBundles.Count);
|
||||||
var sourceDatas = new List<ITableData>(mainBundle.DependBundles.Count);
|
foreach (string dependBundleName in assetInfo.DependBundles)
|
||||||
foreach (string dependBundleName in mainBundle.DependBundles)
|
|
||||||
{
|
{
|
||||||
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
|
||||||
var rowData = new DependTableData();
|
var rowData = new DependTableData();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -24,8 +24,8 @@ namespace YooAsset.Editor
|
|||||||
private VisualTreeAsset _visualAsset;
|
private VisualTreeAsset _visualAsset;
|
||||||
private TemplateContainer _root;
|
private TemplateContainer _root;
|
||||||
|
|
||||||
private TableView _bundleTableView;
|
private TableViewer _bundleTableView;
|
||||||
private TableView _includeTableView;
|
private TableViewer _includeTableView;
|
||||||
|
|
||||||
private BuildReport _buildReport;
|
private BuildReport _buildReport;
|
||||||
private string _reportFilePath;
|
private string _reportFilePath;
|
||||||
@@ -46,13 +46,13 @@ namespace YooAsset.Editor
|
|||||||
_root.style.flexGrow = 1f;
|
_root.style.flexGrow = 1f;
|
||||||
|
|
||||||
// 资源包列表
|
// 资源包列表
|
||||||
_bundleTableView = _root.Q<TableView>("TopTableView");
|
_bundleTableView = _root.Q<TableViewer>("TopTableView");
|
||||||
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
|
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
|
||||||
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
|
||||||
CreateBundleTableViewColumns();
|
CreateBundleTableViewColumns();
|
||||||
|
|
||||||
// 包含列表
|
// 包含列表
|
||||||
_includeTableView = _root.Q<TableView>("BottomTableView");
|
_includeTableView = _root.Q<TableViewer>("BottomTableView");
|
||||||
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
|
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
|
||||||
CreateIncludeTableViewColumns();
|
CreateIncludeTableViewColumns();
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ namespace YooAsset.Editor
|
|||||||
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
var bottomGroup = _root.Q<VisualElement>("BottomGroup");
|
||||||
topGroup.style.minHeight = 100;
|
topGroup.style.minHeight = 100;
|
||||||
bottomGroup.style.minHeight = 100f;
|
bottomGroup.style.minHeight = 100f;
|
||||||
PanelSplitView.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
UIElementsTools.SplitVerticalPanel(_root, topGroup, bottomGroup);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
private void CreateBundleTableViewColumns()
|
private void CreateBundleTableViewColumns()
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||||
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
|
||||||
<YooAsset.Editor.TableView name="TopTableView" style="flex-grow: 1;" />
|
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
<ui:VisualElement name="BottomGroup" style="height: 200px; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 1px; margin-bottom: 1px; display: flex; flex-grow: 1;">
|
||||||
<YooAsset.Editor.TableView name="BottomTableView" style="flex-grow: 1;" />
|
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
|
||||||
</ui:VisualElement>
|
</ui:VisualElement>
|
||||||
</ui:UXML>
|
</ui:UXML>
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ namespace YooAsset.Editor
|
|||||||
BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
|
BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
|
||||||
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
|
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
|
||||||
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
|
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
|
||||||
BindListViewItem("Encryption Class Name", buildReport.Summary.EncryptionClassName);
|
BindListViewItem("Encryption Services", buildReport.Summary.EncryptionServicesClassName);
|
||||||
|
BindListViewItem("Manifest Services", buildReport.Summary.ManifestServicesClassName);
|
||||||
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
|
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
|
||||||
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
|
||||||
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
|
||||||
|
|||||||
@@ -129,6 +129,23 @@ namespace YooAsset.Editor
|
|||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region Attribute
|
||||||
|
public static T GetAttribute<T>(Type type) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)type.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetAttribute<T>(MethodInfo methodInfo) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)methodInfo.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T GetAttribute<T>(FieldInfo field) where T : Attribute
|
||||||
|
{
|
||||||
|
return (T)field.GetCustomAttribute(typeof(T), false);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region PackageManager
|
#region PackageManager
|
||||||
public static string GetPackageManagerYooVersion()
|
public static string GetPackageManagerYooVersion()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,41 +0,0 @@
|
|||||||
#if UNITY_2019_4_OR_NEWER
|
|
||||||
using System;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 显示开关(眼睛图标)
|
|
||||||
/// </summary>
|
|
||||||
public class DisplayToggle : Toggle
|
|
||||||
{
|
|
||||||
private readonly VisualElement _checkbox;
|
|
||||||
|
|
||||||
public DisplayToggle()
|
|
||||||
{
|
|
||||||
_checkbox = this.Q<VisualElement>("unity-checkmark");
|
|
||||||
RefreshIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 刷新图标
|
|
||||||
/// </summary>
|
|
||||||
public void RefreshIcon()
|
|
||||||
{
|
|
||||||
if (this.value)
|
|
||||||
{
|
|
||||||
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleoff@2x").image as Texture2D;
|
|
||||||
_checkbox.style.backgroundImage = icon;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var icon = EditorGUIUtility.IconContent("animationvisibilitytoggleon@2x").image as Texture2D;
|
|
||||||
_checkbox.style.backgroundImage = icon;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#if UNITY_2020_3_OR_NEWER
|
|
||||||
using System;
|
|
||||||
using UnityEditor;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEditor.UIElements;
|
|
||||||
using UnityEngine.UIElements;
|
|
||||||
|
|
||||||
namespace YooAsset.Editor
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 分屏控件
|
|
||||||
/// </summary>
|
|
||||||
public class PanelSplitView : TwoPaneSplitView
|
|
||||||
{
|
|
||||||
public new class UxmlFactory : UxmlFactory<PanelSplitView, UxmlTraits>
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 竖版分屏
|
|
||||||
/// </summary>
|
|
||||||
public static void SplitVerticalPanel(VisualElement root, VisualElement panelA, VisualElement panelB)
|
|
||||||
{
|
|
||||||
root.Remove(panelA);
|
|
||||||
root.Remove(panelB);
|
|
||||||
|
|
||||||
var spliteView = new PanelSplitView();
|
|
||||||
spliteView.fixedPaneInitialDimension = 300;
|
|
||||||
spliteView.orientation = TwoPaneSplitViewOrientation.Vertical;
|
|
||||||
spliteView.contentContainer.Add(panelA);
|
|
||||||
spliteView.contentContainer.Add(panelB);
|
|
||||||
root.Add(spliteView);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 显示开关(眼睛图标)
|
||||||
|
/// </summary>
|
||||||
|
public class ToggleDisplay : Toggle
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<ToggleDisplay, UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly VisualElement _checkbox;
|
||||||
|
|
||||||
|
public ToggleDisplay()
|
||||||
|
{
|
||||||
|
_checkbox = this.Q<VisualElement>("unity-checkmark");
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
public override void SetValueWithoutNotify(bool newValue)
|
||||||
|
{
|
||||||
|
base.SetValueWithoutNotify(newValue);
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
|
protected override void ToggleValue()
|
||||||
|
{
|
||||||
|
base.ToggleValue();
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private void RefreshIcon()
|
||||||
|
{
|
||||||
|
if (this.value)
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent(UIElementsIcon.VisibilityToggleOff).image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent(UIElementsIcon.VisibilityToggleOn).image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
#if UNITY_2019_4_OR_NEWER
|
||||||
|
using System;
|
||||||
|
using UnityEditor;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEditor.UIElements;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
|
||||||
|
namespace YooAsset.Editor
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 折叠开关
|
||||||
|
/// </summary>
|
||||||
|
public class ToggleFoldout : Toggle
|
||||||
|
{
|
||||||
|
public new class UxmlFactory : UxmlFactory<ToggleFoldout, UxmlTraits>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly VisualElement _checkbox;
|
||||||
|
|
||||||
|
public ToggleFoldout()
|
||||||
|
{
|
||||||
|
_checkbox = this.Q<VisualElement>("unity-checkmark");
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
public override void SetValueWithoutNotify(bool newValue)
|
||||||
|
{
|
||||||
|
base.SetValueWithoutNotify(newValue);
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
#if UNITY_2021_3_OR_NEWER
|
||||||
|
protected override void ToggleValue()
|
||||||
|
{
|
||||||
|
base.ToggleValue();
|
||||||
|
RefreshIcon();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public void RefreshIcon()
|
||||||
|
{
|
||||||
|
if (this.value)
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent(UIElementsIcon.FoldoutOn).image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var icon = EditorGUIUtility.IconContent(UIElementsIcon.FoldoutOff).image as Texture2D;
|
||||||
|
_checkbox.style.backgroundImage = icon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user