Compare commits

...

56 Commits

Author SHA1 Message Date
何冠峰
974493f88d Update CHANGELOG.md 2025-03-25 11:15:56 +08:00
何冠峰
69a69988a1 Update package.json 2025-03-25 11:15:24 +08:00
何冠峰
4e9c1955eb fix #486 2025-03-14 18:54:03 +08:00
何冠峰
b6c68a533e update asset bundle builder
增加TaskCreateCatalog任务节点
2025-03-14 18:49:56 +08:00
何冠峰
38aa1c3509 update file system 2025-03-14 18:26:04 +08:00
何冠峰
eb2f783417 update resource package 2025-03-14 17:23:55 +08:00
何冠峰
8556e071fa fix #507 2025-03-14 16:50:48 +08:00
何冠峰
6155256fb6 Update CHANGELOG.md 2025-03-14 14:48:16 +08:00
何冠峰
0d4f2bc893 Update package.json 2025-03-14 14:47:39 +08:00
何冠峰
600e928ab4 fix #512 2025-03-14 14:32:39 +08:00
何冠峰
4599ff098c update resource package
优化ClearCacheFilesAsync方法
2025-03-14 12:27:01 +08:00
何冠峰
4d2df5b705 Update TestBundleEncryption.cs 2025-03-13 16:29:48 +08:00
何冠峰
79a7732cfd Update InitializeParameters.cs 2025-03-13 14:00:59 +08:00
何冠峰
79467bbf13 update editor assembly 2025-03-12 18:32:28 +08:00
何冠峰
c7d678282b Merge pull request #501 from Y-way/support-macros
Update MacrosProcessor.cs
2025-03-12 17:17:47 +08:00
何冠峰
d376afc217 fix #508 2025-03-12 17:16:24 +08:00
何冠峰
a62f808591 fix #506 2025-03-12 16:36:37 +08:00
何冠峰
b334a4986b fix #504 2025-03-12 10:39:44 +08:00
何冠峰
a4111349a0 fix #502 2025-03-11 15:40:57 +08:00
Y-way
bdcf95384f Update .gitignore 2025-03-10 16:13:18 +08:00
Y-way
d910af589d Update MacrosProcessor.cs
修正YooAsset相关宏在引用库不能生效的问题.
2025-03-10 15:22:44 +08:00
何冠峰
0531864534 Update package.json 2025-03-10 10:29:44 +08:00
何冠峰
72b1278f5c Merge pull request #499 from benjamini258369gmail/fix-rawIgnore-dll
fix ignore raw dll
2025-03-10 10:27:13 +08:00
benjamini
875cd24cba fix ignore raw dll 2025-03-08 17:54:11 +09:00
何冠峰
fcc729a0bf Update CHANGELOG.md 2025-03-08 15:53:46 +08:00
何冠峰
d10e54248b Update package.json 2025-03-08 15:53:35 +08:00
何冠峰
b84800a905 update assembly 2025-03-08 15:51:27 +08:00
何冠峰
8ccd7e552c fix #498 2025-03-08 15:41:03 +08:00
何冠峰
772ba484eb Update HandleFactory.cs 2025-03-08 15:01:19 +08:00
何冠峰
cdbedee705 update asmdef
YooAsset版本宏定义
2025-03-08 14:34:41 +08:00
何冠峰
10cce48e71 Merge pull request #497 from Y-way/support-macros
Support DefineConstants for YooAsset Package
2025-03-08 12:05:07 +08:00
何冠峰
13e8410d80 fix #389 2025-03-08 11:50:35 +08:00
何冠峰
6f07faf4da fix #495 2025-03-08 11:24:17 +08:00
何冠峰
e3228d406e update resource manager
优化Handle生成和移除逻辑
2025-03-08 10:58:19 +08:00
何冠峰
daf2133535 fix #496 2025-03-07 15:03:13 +08:00
Y-way
9bcbc10862 Support DefineConstants for YooAsset Package
自定义YOO_VERSION_2  以及版本管理宏,用于YooAsset升级时的宏定义处理
2025-03-07 15:00:20 +08:00
何冠峰
e6958d205e Update CHANGELOG.md 2025-03-06 15:05:52 +08:00
何冠峰
b03d9db2b0 Update package.json 2025-03-06 15:05:39 +08:00
何冠峰
30853b6d62 update space shooter 2025-03-06 14:31:40 +08:00
何冠峰
a7cafcb328 update UIElements
展示单位Units
2025-03-06 14:31:26 +08:00
何冠峰
d03bca5512 update asset bundle debugger 2025-03-06 12:20:45 +08:00
何冠峰
af3fc50188 update UIElements 2025-03-06 12:20:13 +08:00
何冠峰
b71eeeb855 update UIElements 2025-03-06 11:45:51 +08:00
何冠峰
317c42521a update test sample 2025-03-06 11:39:26 +08:00
何冠峰
064d69269e Update PakcageInvokeBuildParam.cs 2025-03-06 11:17:20 +08:00
何冠峰
9e6401d3c0 update space shooter 2025-03-06 11:17:00 +08:00
何冠峰
2aaba328ee fix #488 2025-03-06 11:16:21 +08:00
何冠峰
62fdc93a82 update test sample 2025-03-06 10:55:54 +08:00
何冠峰
408f0942ee update test sample 2025-03-05 20:00:02 +08:00
何冠峰
ddda9e29db fix #491 2025-03-05 17:39:33 +08:00
何冠峰
c2b33f5ec4 fix #492 2025-03-05 17:29:52 +08:00
何冠峰
e58999e484 update asset bundle debugger 2025-03-05 17:26:58 +08:00
何冠峰
ed9692574c Update AssetBundleSimulateBuilder.cs
模拟构建默认启用依赖关系数据库
2025-03-05 10:54:33 +08:00
何冠峰
f7e078e064 update file system 2025-03-05 10:54:02 +08:00
何冠峰
b74a44dc36 update UIElements 2025-03-03 20:57:50 +08:00
何冠峰
6b36cdb5ee update AssetBundleDebugger
内置了新的UIElments的TreeViewer组件。
2025-03-03 18:28:02 +08:00
211 changed files with 3362 additions and 688 deletions

2
.gitignore vendored
View File

@@ -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

View File

@@ -2,6 +2,67 @@
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.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

View File

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

View File

@@ -0,0 +1,17 @@
using System.Collections.Generic;
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",
};
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 07f7c95e8e42fd04f81b9925b2dcf0d0 guid: a61e5c2ca04aab647b1ed0492086aa8f
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View File

@@ -0,0 +1,96 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml;
using UnityEditor;
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结构重新输出为文本
var stringWriter = new StringWriter();
var writerSettings = new XmlWriterSettings();
writerSettings.Indent = true;
var xmlWriter = XmlWriter.Create(stringWriter, writerSettings);
xmlDoc.WriteTo(xmlWriter);
xmlWriter.Flush();
return stringWriter.ToString();
}
/// <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;
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2 fileFormatVersion: 2
guid: 88e4ec854876f3f40bce38bc880c0f6a guid: 88d5a41d078a82e40b82265ed4c3631a
MonoImporter: MonoImporter:
externalObjects: {} externalObjects: {}
serializedVersion: 2 serializedVersion: 2

View 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

View File

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

View File

@@ -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();
@@ -441,6 +441,8 @@ 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 = () =>
{ {

View File

@@ -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>

View File

@@ -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;

View File

@@ -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);

View File

@@ -0,0 +1,23 @@
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;
DefaultBuildinFileSystemBuild.CreateBuildinCatalogFile(buildPackageName, buildinRootDirectory);
// 刷新目录
AssetDatabase.Refresh();
}
}
}

View File

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

View File

@@ -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;

View File

@@ -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);
}
}
}
}

View File

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

View File

@@ -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;
} }

View File

@@ -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);
}
}
}
}

View File

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

View File

@@ -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;
} }

View File

@@ -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);
}
}
}
}

View File

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

View File

@@ -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;
} }

View File

@@ -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>

View File

@@ -59,6 +59,10 @@ namespace YooAsset.Editor
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;
@@ -161,6 +165,19 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Unregister(RemoteDebuggerDefine.kMsgPlayerSendToEditor); 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)
{ {
@@ -174,21 +191,27 @@ namespace YooAsset.Editor
} }
private void OnHandlePlayerMessage(MessageEventArgs args) private void OnHandlePlayerMessage(MessageEventArgs args)
{ {
var debugReport = DebugReport.Deserialize(args.data);
int playerId = args.playerId; int playerId = args.playerId;
Debug.Log($"Handle player {playerId} debug report !"); var debugReport = DebugReport.Deserialize(args.data);
if (debugReport.DebuggerVersion != RemoteDebuggerDefine.DebuggerVersion)
{
Debug.LogWarning($"Debugger versions are inconsistent : {debugReport.DebuggerVersion} != {RemoteDebuggerDefine.DebuggerVersion}");
return;
}
//Debug.Log($"Handle player {playerId} debug report !");
_currentPlayerSession = GetOrCreatePlayerSession(playerId); _currentPlayerSession = 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()
@@ -197,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()
@@ -206,21 +229,26 @@ 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()
{ {
if (_currentPlayerSession != null) _nextRepaintIndex = -1;
{ _lastRepaintIndex = 0;
_rangeIndex = 0;
_frameSlider.label = $"Frame:"; _frameSlider.label = $"Frame:";
_frameSlider.value = 0; _frameSlider.value = 0;
_frameSlider.lowValue = 0; _frameSlider.lowValue = 0;
_frameSlider.highValue = 0; _frameSlider.highValue = 0;
_currentPlayerSession.ClearDebugReport();
_assetListViewer.ClearView(); _assetListViewer.ClearView();
_bundleListViewer.ClearView(); _bundleListViewer.ClearView();
_operationListViewer.ClearView(); _operationListViewer.ClearView();
if (_currentPlayerSession != null)
{
_currentPlayerSession.ClearDebugReport();
} }
} }
private void OnRecordToggleValueChange(ChangeEvent<bool> evt) private void OnRecordToggleValueChange(ChangeEvent<bool> evt)
@@ -234,42 +262,6 @@ namespace YooAsset.Editor
RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data); RemoteEditorConnection.Instance.Send(RemoteDebuggerDefine.kMsgEditorSendToPlayer, data);
} }
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 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);
_operationListViewer.FillViewData(debugReport);
}
}
private void SampleBtn_onClick() private void SampleBtn_onClick()
{ {
// 发送采集数据的命令 // 发送采集数据的命令
@@ -347,6 +339,9 @@ namespace YooAsset.Editor
{ {
throw new NotImplementedException(viewMode.ToString()); throw new NotImplementedException(viewMode.ToString());
} }
// 重新绘制该帧数据
RepaintFrame(_lastRepaintIndex);
} }
} }
private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action) private DropdownMenuAction.Status OnViewModeMenuStatusUpdate(DropdownMenuAction action)
@@ -357,6 +352,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

View File

@@ -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>

View File

@@ -24,8 +24,8 @@ 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 List<ITableData> _sourceDatas; private List<ITableData> _sourceDatas;
@@ -44,12 +44,12 @@ 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();
// 面板分屏 // 面板分屏
@@ -148,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 = () =>
{ {
@@ -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);
@@ -332,8 +333,10 @@ namespace YooAsset.Editor
public void ClearView() public void ClearView()
{ {
_providerTableView.ClearAll(false, true); _providerTableView.ClearAll(false, true);
_providerTableView.RebuildView();
_dependTableView.ClearAll(false, true); _dependTableView.ClearAll(false, true);
RebuildView(null); _dependTableView.RebuildView();
} }
/// <summary> /// <summary>
@@ -342,10 +345,12 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord) public void RebuildView(string searchKeyWord)
{ {
// 搜索匹配 // 搜索匹配
if (_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord); DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图 // 重建视图
_providerTableView.RebuildView(); _providerTableView.RebuildView();
_dependTableView.RebuildView();
} }
/// <summary> /// <summary>

View File

@@ -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>

View File

@@ -28,9 +28,9 @@ 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 List<ITableData> _sourceDatas; private List<ITableData> _sourceDatas;
@@ -48,16 +48,16 @@ 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();
// 面板分屏 // 面板分屏
@@ -151,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);
@@ -341,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);
@@ -393,8 +393,10 @@ namespace YooAsset.Editor
{ {
_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();
} }
@@ -405,10 +407,13 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord) public void RebuildView(string searchKeyWord)
{ {
// 搜索匹配 // 搜索匹配
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord); DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图 // 重建视图
_bundleTableView.RebuildView(); _bundleTableView.RebuildView();
_usingTableView.RebuildView();
_referenceTableView.RebuildView();
} }
/// <summary> /// <summary>

View File

@@ -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>

View File

@@ -20,13 +20,10 @@ namespace YooAsset.Editor
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
private TableView _operationTableView; private TableViewer _operationTableView;
private Toolbar _bottomToolbar; private Toolbar _bottomToolbar;
#if UNITY_2022_3_OR_NEWER private TreeViewer _childTreeView;
private TreeView _childTreeView;
#endif
private int _treeItemID = 0;
private List<ITableData> _sourceDatas; private List<ITableData> _sourceDatas;
@@ -44,7 +41,7 @@ namespace YooAsset.Editor
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
// 任务列表 // 任务列表
_operationTableView = _root.Q<TableView>("TopTableView"); _operationTableView = _root.Q<TableViewer>("TopTableView");
_operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged; _operationTableView.SelectionChangedEvent = OnOperationTableViewSelectionChanged;
CreateOperationTableViewColumns(); CreateOperationTableViewColumns();
@@ -53,11 +50,9 @@ namespace YooAsset.Editor
CreateBottomToolbarHeaders(); CreateBottomToolbarHeaders();
// 子列表 // 子列表
#if UNITY_2022_3_OR_NEWER _childTreeView = _root.Q<TreeViewer>("BottomTreeView");
_childTreeView = _root.Q<TreeView>("BottomTreeView");
_childTreeView.makeItem = MakeTreeViewItem; _childTreeView.makeItem = MakeTreeViewItem;
_childTreeView.bindItem = BindTreeViewItem; _childTreeView.bindItem = BindTreeViewItem;
#endif
// 面板分屏 // 面板分屏
var topGroup = _root.Q<VisualElement>("TopGroup"); var topGroup = _root.Q<VisualElement>("TopGroup");
@@ -175,10 +170,11 @@ namespace YooAsset.Editor
// ProcessTime // ProcessTime
{ {
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("ProcessTime", "Process Time", columnStyle); var column = new TableColumn("ProcessTime", "Process Time", columnStyle);
column.MakeCell = () => column.MakeCell = () =>
{ {
@@ -275,9 +271,9 @@ namespace YooAsset.Editor
// ProcessTime // ProcessTime
{ {
ToolbarButton button = new ToolbarButton(); ToolbarButton button = new ToolbarButton();
button.text = "ProcessTime"; button.text = "ProcessTime (ms)";
button.style.flexGrow = 0; button.style.flexGrow = 0;
button.style.width = 100; button.style.width = 130;
_bottomToolbar.Add(button); _bottomToolbar.Add(button);
} }
@@ -307,11 +303,8 @@ namespace YooAsset.Editor
{ {
// 清空旧数据 // 清空旧数据
_operationTableView.ClearAll(false, true); _operationTableView.ClearAll(false, true);
_childTreeView.ClearAll();
#if UNITY_2022_3_OR_NEWER _childTreeView.RebuildView();
_childTreeView.SetRootItems(new List<TreeViewItemData<DebugOperationInfo>>());
_childTreeView.Rebuild();
#endif
// 填充数据源 // 填充数据源
_sourceDatas = new List<ITableData>(1000); _sourceDatas = new List<ITableData>(1000);
@@ -345,11 +338,10 @@ namespace YooAsset.Editor
public void ClearView() public void ClearView()
{ {
_operationTableView.ClearAll(false, true); _operationTableView.ClearAll(false, true);
#if UNITY_2022_3_OR_NEWER _operationTableView.RebuildView();
_childTreeView.SetRootItems(new List<TreeViewItemData<DebugOperationInfo>>());
_childTreeView.Rebuild(); _childTreeView.ClearAll();
#endif _childTreeView.RebuildView();
RebuildView(null);
} }
/// <summary> /// <summary>
@@ -358,10 +350,12 @@ namespace YooAsset.Editor
public void RebuildView(string searchKeyWord) public void RebuildView(string searchKeyWord)
{ {
// 搜索匹配 // 搜索匹配
if(_sourceDatas != null)
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord); DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图 // 重建视图
_operationTableView.RebuildView(); _operationTableView.RebuildView();
_childTreeView.RebuildView();
} }
/// <summary> /// <summary>
@@ -380,23 +374,20 @@ namespace YooAsset.Editor
_root.RemoveFromHierarchy(); _root.RemoveFromHierarchy();
} }
#if UNITY_2022_3_OR_NEWER
private void OnOperationTableViewSelectionChanged(ITableData data) private void OnOperationTableViewSelectionChanged(ITableData data)
{ {
var operationTableData = data as OperationTableData; var operationTableData = data as OperationTableData;
DebugPackageData packageData = operationTableData.PackageData; DebugPackageData packageData = operationTableData.PackageData;
DebugOperationInfo operationInfo = operationTableData.OperationInfo; DebugOperationInfo operationInfo = operationTableData.OperationInfo;
_treeItemID = 0; TreeNode rootNode = new TreeNode(operationInfo);
var rootItems = CreateTreeData(operationInfo); FillTreeData(operationInfo, rootNode);
_childTreeView.SetRootItems(rootItems); _childTreeView.ClearAll();
_childTreeView.Rebuild(); _childTreeView.SetRootItem(rootNode);
_childTreeView.RebuildView();
} }
private VisualElement MakeTreeViewItem() private void MakeTreeViewItem(VisualElement container)
{ {
VisualElement treeViewElement = new VisualElement();
treeViewElement.style.flexDirection = FlexDirection.Row;
// OperationName // OperationName
{ {
Label label = new Label(); Label label = new Label();
@@ -404,7 +395,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f; label.style.flexGrow = 0f;
label.style.width = 300; label.style.width = 300;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
// Progress // Progress
@@ -414,7 +405,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f; label.style.flexGrow = 0f;
label.style.width = 100; label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
// BeginTime // BeginTime
@@ -424,7 +415,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f; label.style.flexGrow = 0f;
label.style.width = 100; label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
// ProcessTime // ProcessTime
@@ -432,9 +423,9 @@ namespace YooAsset.Editor
var label = new Label(); var label = new Label();
label.name = "ProcessTime"; label.name = "ProcessTime";
label.style.flexGrow = 0f; label.style.flexGrow = 0f;
label.style.width = 100; label.style.width = 130;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
// Status // Status
@@ -444,7 +435,7 @@ namespace YooAsset.Editor
label.style.flexGrow = 0f; label.style.flexGrow = 0f;
label.style.width = 100; label.style.width = 100;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
// Desc // Desc
@@ -454,36 +445,34 @@ namespace YooAsset.Editor
label.style.flexGrow = 1f; label.style.flexGrow = 1f;
label.style.width = 500; label.style.width = 500;
label.style.unityTextAlign = TextAnchor.MiddleLeft; label.style.unityTextAlign = TextAnchor.MiddleLeft;
treeViewElement.Add(label); container.Add(label);
} }
return treeViewElement;
} }
private void BindTreeViewItem(VisualElement element, int index) private void BindTreeViewItem(VisualElement container, object userData)
{ {
var operationInfo = _childTreeView.GetItemDataForIndex<DebugOperationInfo>(index); var operationInfo = (DebugOperationInfo)userData;
// OperationName // OperationName
{ {
var label = element.Q<Label>("OperationName"); var label = container.Q<Label>("OperationName");
label.text = operationInfo.OperationName; label.text = operationInfo.OperationName;
} }
// Progress // Progress
{ {
var label = element.Q<Label>("Progress"); var label = container.Q<Label>("Progress");
label.text = operationInfo.Progress.ToString(); label.text = operationInfo.Progress.ToString();
} }
// BeginTime // BeginTime
{ {
var label = element.Q<Label>("BeginTime"); var label = container.Q<Label>("BeginTime");
label.text = operationInfo.BeginTime; label.text = operationInfo.BeginTime;
} }
// ProcessTime // ProcessTime
{ {
var label = element.Q<Label>("ProcessTime"); var label = container.Q<Label>("ProcessTime");
label.text = operationInfo.ProcessTime.ToString(); label.text = operationInfo.ProcessTime.ToString();
} }
@@ -495,33 +484,26 @@ namespace YooAsset.Editor
else else
textColor = new StyleColor(Color.white); textColor = new StyleColor(Color.white);
var label = element.Q<Label>("Status"); var label = container.Q<Label>("Status");
label.text = operationInfo.Status; label.text = operationInfo.Status;
label.style.color = textColor; label.style.color = textColor;
} }
// Desc // Desc
{ {
var label = element.Q<Label>("Desc"); var label = container.Q<Label>("Desc");
label.text = operationInfo.OperationDesc; label.text = operationInfo.OperationDesc;
} }
} }
private List<TreeViewItemData<DebugOperationInfo>> CreateTreeData(DebugOperationInfo parentOperation) private void FillTreeData(DebugOperationInfo parentOperation, TreeNode rootNode)
{ {
var rootItemList = new List<TreeViewItemData<DebugOperationInfo>>();
foreach (var childOperation in parentOperation.Childs) foreach (var childOperation in parentOperation.Childs)
{ {
var childItemList = CreateTreeData(childOperation); var childNode = new TreeNode(childOperation);
var treeItem = new TreeViewItemData<DebugOperationInfo>(_treeItemID++, childOperation, childItemList); rootNode.AddChild(childNode);
rootItemList.Add(treeItem); FillTreeData(childOperation, childNode);
} }
return rootItemList;
} }
#else
private void OnOperationTableViewSelectionChanged(ITableData data)
{
}
#endif
} }
} }
#endif #endif

View File

@@ -1,9 +1,9 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True"> <ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="True">
<ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;"> <ui:VisualElement name="TopGroup" style="flex-grow: 1; border-left-width: 1px; border-right-width: 1px; border-top-width: 1px; border-bottom-width: 1px; border-left-color: rgb(0, 0, 0); border-right-color: rgb(0, 0, 0); border-top-color: rgb(0, 0, 0); border-bottom-color: rgb(0, 0, 0); margin-left: 0; margin-right: 0; margin-top: 2px; margin-bottom: 1px; display: flex;">
<YooAsset.Editor.TableView name="TopTableView" /> <YooAsset.Editor.TableViewer name="TopTableView" />
</ui:VisualElement> </ui:VisualElement>
<ui:VisualElement name="BottomGroup" style="flex-grow: 1;"> <ui:VisualElement name="BottomGroup" style="flex-grow: 1;">
<uie:Toolbar name="BottomToolbar" /> <uie:Toolbar name="BottomToolbar" />
<ui:TreeView name="BottomTreeView" /> <YooAsset.Editor.TreeViewer name="BottomTreeView" />
</ui:VisualElement> </ui:VisualElement>
</ui:UXML> </ui:UXML>

View File

@@ -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,13 +46,13 @@ 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();

View File

@@ -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>

View File

@@ -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();

View File

@@ -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>

View File

@@ -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

View File

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

View File

@@ -46,6 +46,11 @@ namespace YooAsset.Editor
/// </summary> /// </summary>
public bool Counter = false; public bool Counter = false;
/// <summary>
/// 展示单位
/// </summary>
public string Units = string.Empty;
public ColumnStyle(Length width) public ColumnStyle(Length width)
{ {
if (width.value > MaxValue) if (width.value > MaxValue)

View File

@@ -13,9 +13,9 @@ namespace YooAsset.Editor
/// <summary> /// <summary>
/// Unity2022版本以上推荐官方类MultiColumnListView组件 /// Unity2022版本以上推荐官方类MultiColumnListView组件
/// </summary> /// </summary>
public class TableView : VisualElement public class TableViewer : VisualElement
{ {
public new class UxmlFactory : UxmlFactory<TableView, UxmlTraits> public new class UxmlFactory : UxmlFactory<TableViewer, UxmlTraits>
{ {
} }
@@ -82,7 +82,7 @@ namespace YooAsset.Editor
public Action<ITableData> SelectionChangedEvent; public Action<ITableData> SelectionChangedEvent;
public TableView() public TableViewer()
{ {
this.style.flexShrink = 1f; this.style.flexShrink = 1f;
this.style.flexGrow = 1f; this.style.flexGrow = 1f;
@@ -214,6 +214,16 @@ namespace YooAsset.Editor
} }
} }
// 设置展示单位
foreach (var column in _columns)
{
if (string.IsNullOrEmpty(column.ColumnStyle.Units) == false)
{
var toobarButton = GetHeaderElement(column.ElementName) as ToolbarButton;
toobarButton.text = $"{toobarButton.text} ({column.ColumnStyle.Units})";
}
}
// 设置升降符号 // 设置升降符号
if (string.IsNullOrEmpty(_sortingHeader) == false) if (string.IsNullOrEmpty(_sortingHeader) == false)
{ {

View File

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

View File

@@ -0,0 +1,77 @@
#if UNITY_2019_4_OR_NEWER
using System.IO;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
public class TreeNode
{
/// <summary>
/// 子节点集合
/// </summary>
public List<TreeNode> Children = new List<TreeNode>(10);
/// <summary>
/// 父节点
/// </summary>
public TreeNode Parent { get; set; }
/// <summary>
/// 用户数据
/// </summary>
public object UserData { get; set; }
/// <summary>
/// 是否展开
/// </summary>
public bool IsExpanded { get; set; } = false;
public TreeNode(object userData)
{
UserData = userData;
}
/// <summary>
/// 添加子节点
/// </summary>
public void AddChild(TreeNode child)
{
child.Parent = this;
Children.Add(child);
}
/// <summary>
/// 清理所有子节点
/// </summary>
public void ClearChildren()
{
foreach(var child in Children)
{
child.Parent = null;
}
Children.Clear();
}
/// <summary>
/// 计算节点的深度
/// </summary>
public int GetDepth()
{
int depth = 0;
TreeNode current = this;
while (current.Parent != null)
{
depth++;
current = current.Parent;
}
return depth;
}
}
}
#endif

View File

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

View File

@@ -0,0 +1,152 @@
#if UNITY_2019_4_OR_NEWER
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
public class TreeViewer : VisualElement
{
public new class UxmlFactory : UxmlFactory<TreeViewer, UxmlTraits>
{
}
private readonly ListView _listView;
private readonly List<TreeNode> _flattenList = new List<TreeNode>(1000);
private readonly List<TreeNode> _rootList = new List<TreeNode>(100);
/// <summary>
/// 制作列表元素
/// </summary>
public Action<VisualElement> makeItem { get; set; }
/// <summary>
/// 绑定列表数据
/// </summary>
public Action<VisualElement, object> bindItem { get; set; }
public TreeViewer()
{
this.style.flexShrink = 1f;
this.style.flexGrow = 1f;
// 创建ListView
_listView = new ListView();
_listView.style.flexShrink = 1f;
_listView.style.flexGrow = 1f;
_listView.itemsSource = _flattenList;
_listView.makeItem = MakeItemInternal;
_listView.bindItem = BindItemInternal;
this.Add(_listView);
}
/// <summary>
/// 设置根节点数据
/// </summary>
public void SetRootItem(TreeNode rootNode)
{
_rootList.Add(rootNode);
}
/// <summary>
/// 设置根节点数据
/// </summary>
public void SetRootItems(List<TreeNode> rootNodes)
{
_rootList.AddRange(rootNodes);
}
/// <summary>
/// 清理数据
/// </summary>
public void ClearAll()
{
_rootList.Clear();
}
/// <summary>
/// 重新绘制视图
/// </summary>
public void RebuildView()
{
_flattenList.Clear();
foreach (var treeRoot in _rootList)
{
FlattenTree(treeRoot, 0);
}
_listView.Rebuild();
}
/// <summary>
/// 将树形结构扁平化为列表
/// </summary>
private void FlattenTree(TreeNode node, int depth)
{
_flattenList.Add(node);
if (node.IsExpanded)
{
foreach (var child in node.Children)
{
FlattenTree(child, depth + 1);
}
}
}
private VisualElement MakeItemInternal()
{
var container = new VisualElement();
container.style.flexDirection = FlexDirection.Row;
// 折叠按钮
var toggle = new ToggleFoldout();
toggle.text = string.Empty;
toggle.name = "foldout";
toggle.style.alignSelf = Align.Center;
toggle.style.width = 15;
toggle.style.height = 15;
toggle.RegisterValueChangedCallback((ChangeEvent<bool> callback) =>
{
var treeNode = toggle.userData as TreeNode;
treeNode.IsExpanded = toggle.value;
RebuildView();
});
container.Add(toggle);
// 用户自定义元素
if (makeItem != null)
{
makeItem.Invoke(container);
}
return container;
}
private void BindItemInternal(VisualElement item, int index)
{
var treeNode = _flattenList[index];
// 设置折叠状态
var toggle = item.Q<ToggleFoldout>("foldout");
toggle.SetValueWithoutNotify(treeNode.IsExpanded);
toggle.userData = treeNode;
toggle.style.marginLeft = treeNode.GetDepth() * 15;
// 隐藏折叠按钮
if (treeNode.Children.Count == 0)
{
toggle.style.visibility = Visibility.Hidden;
}
// 用户自定义元素
if (bindItem != null)
{
bindItem.Invoke(item, treeNode.UserData);
}
}
}
}
#endif

View File

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

View File

@@ -10,6 +10,14 @@ namespace YooAsset.Editor
public const string RecordOn = "d_Record On@2x"; public const string RecordOn = "d_Record On@2x";
public const string RecordOff = "d_Record Off@2x"; public const string RecordOff = "d_Record Off@2x";
#if UNITY_2019
public const string FoldoutOn = "IN foldout on";
public const string FoldoutOff = "IN foldout";
#else
public const string FoldoutOn = "d_IN_foldout_on@2x";
public const string FoldoutOff = "d_IN_foldout@2x";
#endif
public const string VisibilityToggleOff = "animationvisibilitytoggleoff@2x"; public const string VisibilityToggleOff = "animationvisibilitytoggleoff@2x";
public const string VisibilityToggleOn = "animationvisibilitytoggleon@2x"; public const string VisibilityToggleOn = "animationvisibilitytoggleon@2x";
} }

View File

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

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
[Serializable] [Serializable]
internal class DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo> internal struct DebugBundleInfo : IComparer<DebugBundleInfo>, IComparable<DebugBundleInfo>
{ {
/// <summary> /// <summary>
/// 资源包名称 /// 资源包名称
@@ -20,7 +20,7 @@ namespace YooAsset
/// <summary> /// <summary>
/// 加载状态 /// 加载状态
/// </summary> /// </summary>
public EOperationStatus Status; public string Status;
/// <summary> /// <summary>
/// 谁引用了该资源包 /// 谁引用了该资源包

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
[Serializable] [Serializable]
internal class DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo> internal struct DebugOperationInfo : IComparer<DebugOperationInfo>, IComparable<DebugOperationInfo>
{ {
/// <summary> /// <summary>
/// 任务名称 /// 任务名称

View File

@@ -47,7 +47,7 @@ namespace YooAsset
else else
{ {
UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}"); UnityEngine.Debug.LogError($"Can not found {nameof(DebugBundleInfo)} : {bundleName}");
return null; return default;
} }
} }
} }

View File

@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace YooAsset namespace YooAsset
{ {
[Serializable] [Serializable]
internal class DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo> internal struct DebugProviderInfo : IComparer<DebugProviderInfo>, IComparable<DebugProviderInfo>
{ {
/// <summary> /// <summary>
/// 包裹名 /// 包裹名

View File

@@ -12,6 +12,11 @@ namespace YooAsset
[Serializable] [Serializable]
internal class DebugReport internal class DebugReport
{ {
/// <summary>
/// 调试器版本
/// </summary>
public string DebuggerVersion = RemoteDebuggerDefine.DebuggerVersion;
/// <summary> /// <summary>
/// 游戏帧 /// 游戏帧
/// </summary> /// </summary>

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Text;
namespace YooAsset namespace YooAsset
{ {
internal class RemoteDebuggerDefine internal class RemoteDebuggerDefine
{ {
public const string DebuggerVersion = "2.3.3";
public static readonly Guid kMsgPlayerSendToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3"); public static readonly Guid kMsgPlayerSendToEditor = new Guid("e34a5702dd353724aa315fb8011f08c3");
public static readonly Guid kMsgEditorSendToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a"); public static readonly Guid kMsgEditorSendToPlayer = new Guid("4d1926c9df5b052469a1c63448b7609a");
} }

View File

@@ -7,6 +7,15 @@ namespace YooAsset
{ {
internal class RemoteDebuggerInRuntime : MonoBehaviour internal class RemoteDebuggerInRuntime : MonoBehaviour
{ {
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_sampleOnce = false;
_autoSample = false;
}
#endif
private static bool _sampleOnce = false; private static bool _sampleOnce = false;
private static bool _autoSample = false; private static bool _autoSample = false;

View File

@@ -8,6 +8,14 @@ namespace YooAsset
{ {
internal class RemoteEditorConnection internal class RemoteEditorConnection
{ {
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_instance = null;
}
#endif
private static RemoteEditorConnection _instance; private static RemoteEditorConnection _instance;
public static RemoteEditorConnection Instance public static RemoteEditorConnection Instance
{ {

View File

@@ -8,6 +8,14 @@ namespace YooAsset
{ {
internal class RemotePlayerConnection internal class RemotePlayerConnection
{ {
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_instance = null;
}
#endif
private static RemotePlayerConnection _instance; private static RemotePlayerConnection _instance;
public static RemotePlayerConnection Instance public static RemotePlayerConnection Instance
{ {
@@ -23,12 +31,10 @@ namespace YooAsset
public void Initialize() public void Initialize()
{ {
Debug.LogWarning("X=Initialize");
_messageCallbacks.Clear(); _messageCallbacks.Clear();
} }
public void Register(Guid messageID, UnityAction<MessageEventArgs> callback) public void Register(Guid messageID, UnityAction<MessageEventArgs> callback)
{ {
Debug.LogWarning("X=Register");
if (messageID == Guid.Empty) if (messageID == Guid.Empty)
throw new ArgumentException("messageID is empty !"); throw new ArgumentException("messageID is empty !");
@@ -37,7 +43,6 @@ namespace YooAsset
} }
public void Unregister(Guid messageID) public void Unregister(Guid messageID)
{ {
Debug.LogWarning("X=Unregister");
if (_messageCallbacks.ContainsKey(messageID)) if (_messageCallbacks.ContainsKey(messageID))
_messageCallbacks.Remove(messageID); _messageCallbacks.Remove(messageID);
} }

View File

@@ -1,4 +1,5 @@
using UnityEngine.Networking; using UnityEngine.Networking;
using UnityEngine;
namespace YooAsset namespace YooAsset
{ {
@@ -9,6 +10,14 @@ namespace YooAsset
internal class DownloadSystemHelper internal class DownloadSystemHelper
{ {
#if UNITY_EDITOR
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
UnityWebRequestCreater = null;
}
#endif
public static UnityWebRequestDelegate UnityWebRequestCreater = null; public static UnityWebRequestDelegate UnityWebRequestCreater = null;
public static UnityWebRequest NewUnityWebRequestGet(string requestURL) public static UnityWebRequest NewUnityWebRequestGet(string requestURL)
{ {
@@ -28,7 +37,9 @@ namespace YooAsset
string url; string url;
// 获取对应平台的URL地址 // 获取对应平台的URL地址
#if UNITY_EDITOR #if UNITY_EDITOR_OSX
url = StringUtility.Format("file://{0}", path);
#elif UNITY_EDITOR
url = StringUtility.Format("file:///{0}", path); url = StringUtility.Format("file:///{0}", path);
#elif UNITY_WEBGL #elif UNITY_WEBGL
url = path; url = path;

View File

@@ -6,6 +6,14 @@ namespace YooAsset
{ {
internal class WebRequestCounter internal class WebRequestCounter
{ {
#if UNITY_EDITOR
[UnityEngine.RuntimeInitializeOnLoadMethod(UnityEngine.RuntimeInitializeLoadType.SubsystemRegistration)]
private static void OnRuntimeInitialize()
{
_requestFailedRecorder.Clear();
}
#endif
/// <summary> /// <summary>
/// 记录网络请求失败事件的次数 /// 记录网络请求失败事件的次数
/// </summary> /// </summary>

View File

@@ -0,0 +1,21 @@

namespace YooAsset
{
internal class CatalogDefine
{
/// <summary>
/// 文件极限大小100MB
/// </summary>
public const int FileMaxSize = 104857600;
/// <summary>
/// 文件头标记
/// </summary>
public const uint FileSign = 0x133C5EE;
/// <summary>
/// 文件格式版本
/// </summary>
public const string FileVersion = "1.0.0";
}
}

View File

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

View File

@@ -0,0 +1,102 @@
using System;
using System.IO;
using System.Collections.Generic;
using UnityEngine;
namespace YooAsset
{
internal static class CatalogTools
{
/// <summary>
/// 序列化JSON文件
/// </summary>
public static void SerializeToJson(string savePath, DefaultBuildinFileCatalog catalog)
{
string json = JsonUtility.ToJson(catalog, true);
FileUtility.WriteAllText(savePath, json);
}
/// <summary>
/// 反序列化JSON文件
/// </summary>
public static DefaultBuildinFileCatalog DeserializeFromJson(string jsonContent)
{
return JsonUtility.FromJson<DefaultBuildinFileCatalog>(jsonContent);
}
/// <summary>
/// 序列化(二进制文件)
/// </summary>
public static void SerializeToBinary(string savePath, DefaultBuildinFileCatalog catalog)
{
using (FileStream fs = new FileStream(savePath, FileMode.Create))
{
// 创建缓存器
BufferWriter buffer = new BufferWriter(CatalogDefine.FileMaxSize);
// 写入文件标记
buffer.WriteUInt32(CatalogDefine.FileSign);
// 写入文件版本
buffer.WriteUTF8(CatalogDefine.FileVersion);
// 写入文件头信息
buffer.WriteUTF8(catalog.PackageName);
buffer.WriteUTF8(catalog.PackageVersion);
// 写入资源包列表
buffer.WriteInt32(catalog.Wrappers.Count);
for (int i = 0; i < catalog.Wrappers.Count; i++)
{
var fileWrapper = catalog.Wrappers[i];
buffer.WriteUTF8(fileWrapper.BundleGUID);
buffer.WriteUTF8(fileWrapper.FileName);
}
// 写入文件流
buffer.WriteToStream(fs);
fs.Flush();
}
}
/// <summary>
/// 反序列化(二进制文件)
/// </summary>
public static DefaultBuildinFileCatalog DeserializeFromBinary(byte[] binaryData)
{
// 创建缓存器
BufferReader buffer = new BufferReader(binaryData);
// 读取文件标记
uint fileSign = buffer.ReadUInt32();
if (fileSign != CatalogDefine.FileSign)
throw new Exception("Invalid catalog file !");
// 读取文件版本
string fileVersion = buffer.ReadUTF8();
if (fileVersion != CatalogDefine.FileVersion)
throw new Exception($"The catalog file version are not compatible : {fileVersion} != {CatalogDefine.FileVersion}");
DefaultBuildinFileCatalog catalog = new DefaultBuildinFileCatalog();
{
// 读取文件头信息
catalog.FileVersion = fileVersion;
catalog.PackageName = buffer.ReadUTF8();
catalog.PackageVersion = buffer.ReadUTF8();
// 读取资源包列表
int fileCount = buffer.ReadInt32();
catalog.Wrappers = new List<DefaultBuildinFileCatalog.FileWrapper>(fileCount);
for (int i = 0; i < fileCount; i++)
{
var fileWrapper = new DefaultBuildinFileCatalog.FileWrapper();
fileWrapper.BundleGUID = buffer.ReadUTF8();
fileWrapper.FileName = buffer.ReadUTF8();
catalog.Wrappers.Add(fileWrapper);
}
}
return catalog;
}
}
}

View File

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

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