【m】框架大更新

This commit is contained in:
2025-10-31 11:18:23 +08:00
parent ae6e7c804b
commit 8e1d52ddbf
1883 changed files with 213934 additions and 640 deletions
@@ -0,0 +1,46 @@
using System.IO;
using UnityEditor;
using UnityEngine;
namespace YooAsset.Editor
{
public class AssetBundleInspector
{
[CustomEditor(typeof(AssetBundle))]
internal class AssetBundleEditor : UnityEditor.Editor
{
internal bool pathFoldout = false;
internal bool advancedFoldout = false;
public override void OnInspectorGUI()
{
AssetBundle bundle = target as AssetBundle;
using (new EditorGUI.DisabledScope(true))
{
var leftStyle = new GUIStyle(GUI.skin.GetStyle("Label"));
leftStyle.alignment = TextAnchor.UpperLeft;
GUILayout.Label(new GUIContent("Name: " + bundle.name), leftStyle);
var assetNames = bundle.GetAllAssetNames();
pathFoldout = EditorGUILayout.Foldout(pathFoldout, "Source Asset Paths");
if (pathFoldout)
{
EditorGUI.indentLevel++;
foreach (var asset in assetNames)
EditorGUILayout.LabelField(asset);
EditorGUI.indentLevel--;
}
advancedFoldout = EditorGUILayout.Foldout(advancedFoldout, "Advanced Data");
}
if (advancedFoldout)
{
EditorGUI.indentLevel++;
base.OnInspectorGUI();
EditorGUI.indentLevel--;
}
}
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bfdeb81409dcf774aa7e01837fbb05c2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,65 @@
using System.IO;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
namespace YooAsset.Editor
{
public static class AssetBundleRecorder
{
private static readonly Dictionary<string, AssetBundle> _loadedAssetBundles = new Dictionary<string, AssetBundle>(1000);
/// <summary>
/// 获取AssetBundle对象,如果没有被缓存就重新加载。
/// </summary>
public static AssetBundle GetAssetBundle(string filePath)
{
// 如果文件不存在
if (File.Exists(filePath) == false)
{
Debug.LogWarning($"Not found asset bundle file : {filePath}");
return null;
}
// 验证文件有效性(可能文件被加密)
byte[] fileData = File.ReadAllBytes(filePath);
if (EditorTools.CheckBundleFileValid(fileData) == false)
{
Debug.LogWarning($"The asset bundle file is invalid and may be encrypted : {filePath}");
return null;
}
if (_loadedAssetBundles.TryGetValue(filePath, out AssetBundle bundle))
{
return bundle;
}
else
{
AssetBundle newBundle = AssetBundle.LoadFromFile(filePath);
if (newBundle != null)
{
string[] assetNames = newBundle.GetAllAssetNames();
foreach (string name in assetNames)
{
newBundle.LoadAsset(name);
}
_loadedAssetBundles.Add(filePath, newBundle);
}
return newBundle;
}
}
/// <summary>
/// 卸载所有已经加载的AssetBundle文件
/// </summary>
public static void UnloadAll()
{
foreach (var valuePair in _loadedAssetBundles)
{
if (valuePair.Value != null)
valuePair.Value.Unload(true);
}
_loadedAssetBundles.Clear();
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 956c2aeeca847184c9a150af512508fe
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,186 @@
#if UNITY_2019_4_OR_NEWER
using System;
using UnityEditor;
using UnityEngine;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace YooAsset.Editor
{
public class AssetBundleReporterWindow : EditorWindow
{
[MenuItem("YooAsset/AssetBundle Reporter", false, 103)]
public static void OpenWindow()
{
AssetBundleReporterWindow window = GetWindow<AssetBundleReporterWindow>("AssetBundle Reporter", true, WindowsDefine.DockedWindowTypes);
window.minSize = new Vector2(800, 600);
}
/// <summary>
/// 视图模式
/// </summary>
private enum EViewMode
{
/// <summary>
/// 概览视图
/// </summary>
Summary,
/// <summary>
/// 资源对象视图
/// </summary>
AssetView,
/// <summary>
/// 资源包视图
/// </summary>
BundleView,
}
private ToolbarMenu _viewModeMenu;
private ReporterSummaryViewer _summaryViewer;
private ReporterAssetListViewer _assetListViewer;
private ReporterBundleListViewer _bundleListViewer;
private EViewMode _viewMode;
private BuildReport _buildReport;
private string _reportFilePath;
private string _searchKeyWord;
public void CreateGUI()
{
try
{
VisualElement root = this.rootVisualElement;
// 加载布局文件
var visualAsset = UxmlLoader.LoadWindowUXML<AssetBundleReporterWindow>();
if (visualAsset == null)
return;
visualAsset.CloneTree(root);
// 导入按钮
var importBtn = root.Q<Button>("ImportButton");
importBtn.clicked += ImportBtn_onClick;
// 视图模式菜单
_viewModeMenu = root.Q<ToolbarMenu>("ViewModeMenu");
_viewModeMenu.menu.AppendAction(EViewMode.Summary.ToString(), ViewModeMenuAction0, ViewModeMenuFun0);
_viewModeMenu.menu.AppendAction(EViewMode.AssetView.ToString(), ViewModeMenuAction1, ViewModeMenuFun1);
_viewModeMenu.menu.AppendAction(EViewMode.BundleView.ToString(), ViewModeMenuAction2, ViewModeMenuFun2);
// 搜索栏
var searchField = root.Q<ToolbarSearchField>("SearchField");
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 加载视图
_summaryViewer = new ReporterSummaryViewer();
_summaryViewer.InitViewer();
// 加载视图
_assetListViewer = new ReporterAssetListViewer();
_assetListViewer.InitViewer();
// 加载视图
_bundleListViewer = new ReporterBundleListViewer();
_bundleListViewer.InitViewer();
// 显示视图
_viewMode = EViewMode.Summary;
_viewModeMenu.text = EViewMode.Summary.ToString();
_summaryViewer.AttachParent(root);
}
catch (Exception e)
{
Debug.LogError(e.ToString());
}
}
public void OnDestroy()
{
AssetBundleRecorder.UnloadAll();
}
private void ImportBtn_onClick()
{
string selectFilePath = EditorUtility.OpenFilePanel("导入报告", EditorTools.GetProjectPath(), "report");
if (string.IsNullOrEmpty(selectFilePath))
return;
_reportFilePath = selectFilePath;
string jsonData = FileUtility.ReadAllText(_reportFilePath);
_buildReport = BuildReport.Deserialize(jsonData);
_summaryViewer.FillViewData(_buildReport);
_assetListViewer.FillViewData(_buildReport, _reportFilePath);
_bundleListViewer.FillViewData(_buildReport, _reportFilePath);
}
private void OnSearchKeyWordChange(ChangeEvent<string> e)
{
_searchKeyWord = e.newValue;
if (_buildReport != null)
{
_assetListViewer.RebuildView(_searchKeyWord);
_bundleListViewer.RebuildView(_searchKeyWord);
}
}
private void ViewModeMenuAction0(DropdownMenuAction action)
{
if (_viewMode != EViewMode.Summary)
{
_viewMode = EViewMode.Summary;
VisualElement root = this.rootVisualElement;
_viewModeMenu.text = EViewMode.Summary.ToString();
_summaryViewer.AttachParent(root);
_assetListViewer.DetachParent();
_bundleListViewer.DetachParent();
}
}
private void ViewModeMenuAction1(DropdownMenuAction action)
{
if (_viewMode != EViewMode.AssetView)
{
_viewMode = EViewMode.AssetView;
VisualElement root = this.rootVisualElement;
_viewModeMenu.text = EViewMode.AssetView.ToString();
_summaryViewer.DetachParent();
_assetListViewer.AttachParent(root);
_bundleListViewer.DetachParent();
}
}
private void ViewModeMenuAction2(DropdownMenuAction action)
{
if (_viewMode != EViewMode.BundleView)
{
_viewMode = EViewMode.BundleView;
VisualElement root = this.rootVisualElement;
_viewModeMenu.text = EViewMode.BundleView.ToString();
_summaryViewer.DetachParent();
_assetListViewer.DetachParent();
_bundleListViewer.AttachParent(root);
}
}
private DropdownMenuAction.Status ViewModeMenuFun0(DropdownMenuAction action)
{
if (_viewMode == EViewMode.Summary)
return DropdownMenuAction.Status.Checked;
else
return DropdownMenuAction.Status.Normal;
}
private DropdownMenuAction.Status ViewModeMenuFun1(DropdownMenuAction action)
{
if (_viewMode == EViewMode.AssetView)
return DropdownMenuAction.Status.Checked;
else
return DropdownMenuAction.Status.Normal;
}
private DropdownMenuAction.Status ViewModeMenuFun2(DropdownMenuAction action)
{
if (_viewMode == EViewMode.BundleView)
return DropdownMenuAction.Status.Checked;
else
return DropdownMenuAction.Status.Normal;
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3899632bd2686d24c91fbf997f86c863
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,7 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<uie:Toolbar name="Toolbar" style="display: flex;">
<uie:ToolbarMenu display-tooltip-when-elided="true" name="ViewModeMenu" text="ViewMode" style="width: 100px; flex-grow: 0;" />
<uie:ToolbarSearchField focusable="true" name="SearchField" style="width: 300px; flex-grow: 1;" />
<ui:Button text="Import" display-tooltip-when-elided="true" name="ImportButton" style="width: 50px; background-color: rgb(56, 147, 58);" />
</uie:Toolbar>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 0cf5ea42e6dbbd044998476a1704222b
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,76 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
namespace YooAsset.Editor
{
/// <summary>
/// 构建报告
/// </summary>
[Serializable]
public class BuildReport
{
/// <summary>
/// 汇总信息
/// </summary>
public ReportSummary Summary = new ReportSummary();
/// <summary>
/// 资源对象列表
/// </summary>
public List<ReportAssetInfo> AssetInfos = new List<ReportAssetInfo>();
/// <summary>
/// 资源包列表
/// </summary>
public List<ReportBundleInfo> BundleInfos = new List<ReportBundleInfo>();
/// <summary>
/// 未被依赖的资源列表
/// </summary>
public List<ReportIndependAsset> IndependAssets = new List<ReportIndependAsset>();
/// <summary>
/// 获取资源包信息类
/// </summary>
public ReportBundleInfo GetBundleInfo(string bundleName)
{
foreach (var bundleInfo in BundleInfos)
{
if (bundleInfo.BundleName == bundleName)
return bundleInfo;
}
throw new Exception($"Not found bundle : {bundleName}");
}
/// <summary>
/// 获取资源信息类
/// </summary>
public ReportAssetInfo GetAssetInfo(string assetPath)
{
foreach (var assetInfo in AssetInfos)
{
if (assetInfo.AssetPath == assetPath)
return assetInfo;
}
throw new Exception($"Not found asset : {assetPath}");
}
public static void Serialize(string savePath, BuildReport buildReport)
{
if (File.Exists(savePath))
File.Delete(savePath);
string json = JsonUtility.ToJson(buildReport, true);
FileUtility.WriteAllText(savePath, json);
}
public static BuildReport Deserialize(string jsonData)
{
BuildReport report = JsonUtility.FromJson<BuildReport>(jsonData);
return report;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 481722a9fb3bcb0439f8e124a83f46a2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,52 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportAssetInfo
{
/// <summary>
/// 可寻址地址
/// </summary>
public string Address;
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源GUID
/// 说明:Meta文件记录的GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源的分类标签
/// </summary>
public string[] AssetTags;
/// <summary>
/// 所属资源包名称
/// </summary>
public string MainBundleName;
/// <summary>
/// 所属资源包的大小
/// </summary>
public long MainBundleSize;
/// <summary>
/// 依赖的资源集合
/// </summary>
public List<AssetInfo> DependAssets = new List<AssetInfo>();
/// <summary>
/// 依赖的资源包集合
/// 说明:框架层收集查询结果
/// </summary>
public List<string> DependBundles = new List<string>();
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3be1aca312e51ee489444d57666a1fbf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,74 @@
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportBundleInfo
{
/// <summary>
/// 资源包名称
/// </summary>
public string BundleName;
/// <summary>
/// 文件名称
/// </summary>
public string FileName;
/// <summary>
/// 文件哈希值
/// </summary>
public string FileHash;
/// <summary>
/// 文件校验码
/// </summary>
public uint FileCRC;
/// <summary>
/// 文件大小(字节数)
/// </summary>
public long FileSize;
/// <summary>
/// 加密文件
/// </summary>
public bool Encrypted;
/// <summary>
/// 资源包标签集合
/// </summary>
public string[] Tags;
/// <summary>
/// 依赖的资源包集合
/// 说明:引擎层构建查询结果
/// </summary>
public List<string> DependBundles = new List<string>();
/// <summary>
/// 引用该资源包的资源包集合
/// 说明:谁依赖该资源包
/// </summary>
public List<string> ReferenceBundles = new List<string>();
/// <summary>
/// 资源包内部所有资产
/// </summary>
public List<AssetInfo> BundleContents = new List<AssetInfo>();
/// <summary>
/// 获取资源分类标签的字符串
/// </summary>
public string GetTagsString()
{
if (Tags != null)
return String.Join(";", Tags);
else
return string.Empty;
}
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 619c30bb770aa9d4d94ade597e2cdecf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
namespace YooAsset.Editor
{
[Serializable]
public class ReportIndependAsset
{
/// <summary>
/// 资源路径
/// </summary>
public string AssetPath;
/// <summary>
/// 资源GUID
/// </summary>
public string AssetGUID;
/// <summary>
/// 资源类型
/// </summary>
public string AssetType;
/// <summary>
/// 资源文件大小
/// </summary>
public long FileSize;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a0c1fa7490c2ee84c8a33f27531286c1
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,98 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
namespace YooAsset.Editor
{
[Serializable]
public class ReportSummary
{
/// <summary>
/// YooAsset版本
/// </summary>
public string YooVersion;
/// <summary>
/// 引擎版本
/// </summary>
public string UnityVersion;
/// <summary>
/// 构建时间
/// </summary>
public string BuildDate;
/// <summary>
/// 构建耗时(单位:秒)
/// </summary>
public int BuildSeconds;
/// <summary>
/// 构建平台
/// </summary>
public BuildTarget BuildTarget;
/// <summary>
/// 构建管线
/// </summary>
public string BuildPipeline;
/// <summary>
/// 构建的资源包类型
/// </summary>
public int BuildBundleType;
/// <summary>
/// 构建包裹名称
/// </summary>
public string BuildPackageName;
/// <summary>
/// 构建包裹版本
/// </summary>
public string BuildPackageVersion;
/// <summary>
/// 构建包裹备注
/// </summary>
public string BuildPackageNote;
// 收集器配置
public bool UniqueBundleName;
public bool EnableAddressable;
public bool SupportExtensionless;
public bool LocationToLower;
public bool IncludeAssetGUID;
public bool AutoCollectShaders;
public string IgnoreRuleName;
// 构建参数
public bool ClearBuildCacheFiles;
public bool UseAssetDependencyDB;
public bool EnableSharePackRule;
public bool SingleReferencedPackAlone;
public string EncryptionServicesClassName;
public string ManifestProcessServicesClassName;
public string ManifestRestoreServicesClassName;
public EFileNameStyle FileNameStyle;
// 引擎参数
public ECompressOption CompressOption;
public bool DisableWriteTypeTree;
public bool IgnoreTypeTreeChanges;
public bool WriteLinkXML = true;
public string CacheServerHost;
public int CacheServerPort;
public string BuiltinShadersBundleName;
public string MonoScriptsBundleName;
// 构建结果
public int AssetFileTotalCount;
public int MainAssetTotalCount;
public int AllBundleTotalCount;
public long AllBundleTotalSize;
public int EncryptedBundleTotalCount;
public long EncryptedBundleTotalSize;
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: baed70a091071834cafb730875fdf5a6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: e49d2fc023c9a4a4a9c87e793230b440
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,292 @@
#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;
using System.IO;
namespace YooAsset.Editor
{
internal class ReporterAssetListViewer
{
private class AssetTableData : DefaultTableData
{
public ReportAssetInfo AssetInfo;
}
private class DependTableData : DefaultTableData
{
public ReportBundleInfo BundleInfo;
}
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableViewer _assetTableView;
private TableViewer _dependTableView;
private BuildReport _buildReport;
private string _reportFilePath;
private List<ITableData> _sourceDatas;
/// <summary>
/// 初始化页面
/// </summary>
public void InitViewer()
{
// 加载布局文件
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterAssetListViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 资源列表
_assetTableView = _root.Q<TableViewer>("TopTableView");
_assetTableView.SelectionChangedEvent = OnAssetTableViewSelectionChanged;
_assetTableView.ClickTableDataEvent = OnClickAssetTableView;
CreateAssetTableViewColumns();
// 依赖列表
_dependTableView = _root.Q<TableViewer>("BottomTableView");
_dependTableView.ClickTableDataEvent = OnClickBundleTableView;
CreateDependTableViewColumns();
// 面板分屏
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 CreateAssetTableViewColumns()
{
// AssetPath
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("AssetPath", "Asset Path", 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();
};
_assetTableView.AddColumn(column);
}
//MainBundle
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
var column = new TableColumn("MainBundle", "Main Bundle", 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();
};
_assetTableView.AddColumn(column);
}
}
private void CreateDependTableViewColumns()
{
// DependBundles
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("DependBundles", "Depend Bundles", 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();
};
_dependTableView.AddColumn(column);
}
// FileSize
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("FileSize", "File Size", 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;
long fileSize = (long)cell.CellValue;
infoLabel.text = EditorUtility.FormatBytes(fileSize);
};
_dependTableView.AddColumn(column);
}
// FileHash
{
var columnStyle = new ColumnStyle(250);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
var column = new TableColumn("FileHash", "File Hash", 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();
};
_dependTableView.AddColumn(column);
}
}
/// <summary>
/// 填充页面数据
/// </summary>
public void FillViewData(BuildReport buildReport, string reprotFilePath)
{
_buildReport = buildReport;
_reportFilePath = reprotFilePath;
// 清空旧数据
_assetTableView.ClearAll(false, true);
_dependTableView.ClearAll(false, true);
// 填充数据源
_sourceDatas = new List<ITableData>(_buildReport.AssetInfos.Count);
foreach (var assetInfo in _buildReport.AssetInfos)
{
var rowData = new AssetTableData();
rowData.AssetInfo = assetInfo;
rowData.AddAssetPathCell("AssetPath", assetInfo.AssetPath);
rowData.AddStringValueCell("MainBundle", assetInfo.MainBundleName);
_sourceDatas.Add(rowData);
}
_assetTableView.itemsSource = _sourceDatas;
// 重建视图
RebuildView(null);
}
/// <summary>
/// 重建视图
/// </summary>
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_assetTableView.RebuildView();
}
/// <summary>
/// 挂接到父类页面上
/// </summary>
public void AttachParent(VisualElement parent)
{
parent.Add(_root);
}
/// <summary>
/// 从父类页面脱离开
/// </summary>
public void DetachParent()
{
_root.RemoveFromHierarchy();
}
private void OnAssetTableViewSelectionChanged(ITableData data)
{
var assetTableData = data as AssetTableData;
ReportAssetInfo assetInfo = assetTableData.AssetInfo;
// 填充依赖数据
var sourceDatas = new List<ITableData>(assetInfo.DependBundles.Count);
foreach (string dependBundleName in assetInfo.DependBundles)
{
var dependBundle = _buildReport.GetBundleInfo(dependBundleName);
var rowData = new DependTableData();
rowData.BundleInfo = dependBundle;
rowData.AddStringValueCell("DependBundles", dependBundle.BundleName);
rowData.AddLongValueCell("FileSize", dependBundle.FileSize);
rowData.AddStringValueCell("FileHash", dependBundle.FileHash);
sourceDatas.Add(rowData);
}
_dependTableView.itemsSource = sourceDatas;
_dependTableView.RebuildView();
}
private void OnClickAssetTableView(PointerDownEvent evt, ITableData data)
{
// 鼠标双击后检视
if (evt.clickCount != 2)
return;
foreach (var cell in data.Cells)
{
if (cell is AssetPathCell assetPathCell)
{
if (assetPathCell.PingAssetObject())
break;
}
}
}
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
{
// 鼠标双击后检视
if (evt.clickCount != 2)
return;
var dependTableData = data as DependTableData;
if (dependTableData.BundleInfo.Encrypted)
return;
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
{
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
string filePath = $"{rootDirectory}/{dependTableData.BundleInfo.FileName}";
if (File.Exists(filePath))
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
else
Selection.activeObject = null;
}
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddce16c5ebbb73d4fa11b3d9b6cd7f6a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
<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;">
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
</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;">
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: e077c5b54be900644882d0ce03df9f75
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,378 @@
#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 ReporterBundleListViewer
{
private class BundleTableData : DefaultTableData
{
public ReportBundleInfo BundleInfo;
}
private class IncludeTableData : DefaultTableData
{
public ReportAssetInfo AssetInfo;
}
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private TableViewer _bundleTableView;
private TableViewer _includeTableView;
private BuildReport _buildReport;
private string _reportFilePath;
private List<ITableData> _sourceDatas;
/// <summary>
/// 初始化页面
/// </summary>
public void InitViewer()
{
// 加载布局文件
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterBundleListViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 资源包列表
_bundleTableView = _root.Q<TableViewer>("TopTableView");
_bundleTableView.ClickTableDataEvent = OnClickBundleTableView;
_bundleTableView.SelectionChangedEvent = OnBundleTableViewSelectionChanged;
CreateBundleTableViewColumns();
// 包含列表
_includeTableView = _root.Q<TableViewer>("BottomTableView");
_includeTableView.ClickTableDataEvent = OnClickIncludeTableView;
CreateIncludeTableViewColumns();
#if UNITY_2020_3_OR_NEWER
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);
#endif
}
private void CreateBundleTableViewColumns()
{
//BundleName
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("BundleName", "Bundle 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();
};
_bundleTableView.AddColumn(column);
}
// FileSize
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
var column = new TableColumn("FileSize", "File Size", 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;
long fileSize = (long)cell.CellValue;
infoLabel.text = EditorUtility.FormatBytes(fileSize);
};
_bundleTableView.AddColumn(column);
}
// FileHash
{
var columnStyle = new ColumnStyle(250);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
var column = new TableColumn("FileHash", "File Hash", 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();
};
_bundleTableView.AddColumn(column);
}
//Encrypted
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = true;
var column = new TableColumn("Encrypted", "Encrypted", 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;
bool encrypted = (bool)cell.CellValue;
infoLabel.text = encrypted.ToString();
};
_bundleTableView.AddColumn(column);
}
//Tags
{
var columnStyle = new ColumnStyle(150, 100, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
var column = new TableColumn("Tags", "Tags", 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();
};
_bundleTableView.AddColumn(column);
}
}
private void CreateIncludeTableViewColumns()
{
//IncludeAssets
{
var columnStyle = new ColumnStyle(600, 500, 1000);
columnStyle.Stretchable = true;
columnStyle.Searchable = true;
columnStyle.Sortable = true;
columnStyle.Counter = true;
var column = new TableColumn("IncludeAssets", "Include Assets", 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();
};
_includeTableView.AddColumn(column);
}
//AssetSource
{
var columnStyle = new ColumnStyle(100);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
var column = new TableColumn("AssetSource", "Asset Source", 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();
};
_includeTableView.AddColumn(column);
}
//AssetGUID
{
var columnStyle = new ColumnStyle(250);
columnStyle.Stretchable = false;
columnStyle.Searchable = false;
columnStyle.Sortable = false;
var column = new TableColumn("AssetGUID", "Asset GUID", 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();
};
_includeTableView.AddColumn(column);
}
}
/// <summary>
/// 填充页面数据
/// </summary>
public void FillViewData(BuildReport buildReport, string reprotFilePath)
{
_buildReport = buildReport;
_reportFilePath = reprotFilePath;
// 清空旧数据
_bundleTableView.ClearAll(false, true);
_includeTableView.ClearAll(false, true);
// 填充数据源
_sourceDatas = new List<ITableData>(_buildReport.BundleInfos.Count);
foreach (var bundleInfo in _buildReport.BundleInfos)
{
var rowData = new BundleTableData();
rowData.BundleInfo = bundleInfo;
rowData.AddStringValueCell("BundleName", bundleInfo.BundleName);
rowData.AddLongValueCell("FileSize", bundleInfo.FileSize);
rowData.AddStringValueCell("FileHash", bundleInfo.FileHash);
rowData.AddBoolValueCell("Encrypted", bundleInfo.Encrypted);
rowData.AddStringValueCell("Tags", string.Join(";", bundleInfo.Tags));
_sourceDatas.Add(rowData);
}
_bundleTableView.itemsSource = _sourceDatas;
// 重建视图
RebuildView(null);
}
/// <summary>
/// 重建视图
/// </summary>
public void RebuildView(string searchKeyWord)
{
// 搜索匹配
DefaultSearchSystem.Search(_sourceDatas, searchKeyWord);
// 重建视图
_bundleTableView.RebuildView();
}
/// <summary>
/// 挂接到父类页面上
/// </summary>
public void AttachParent(VisualElement parent)
{
parent.Add(_root);
}
/// <summary>
/// 从父类页面脱离开
/// </summary>
public void DetachParent()
{
_root.RemoveFromHierarchy();
}
private void OnBundleTableViewSelectionChanged(ITableData data)
{
var bundleTableData = data as BundleTableData;
var bundleInfo = bundleTableData.BundleInfo;
// 填充包含数据
var sourceDatas = new List<ITableData>();
var mainAssetDic = new HashSet<string>();
foreach (var assetInfo in _buildReport.AssetInfos)
{
if (assetInfo.MainBundleName == bundleInfo.BundleName)
{
mainAssetDic.Add(assetInfo.AssetPath);
var rowData = new IncludeTableData();
rowData.AssetInfo = assetInfo;
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
rowData.AddStringValueCell("AssetSource", "MainAsset");
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
sourceDatas.Add(rowData);
}
}
foreach (var assetInfo in bundleInfo.BundleContents)
{
if (mainAssetDic.Contains(assetInfo.AssetPath) == false)
{
var rowData = new IncludeTableData();
rowData.AssetInfo = null;
rowData.AddAssetPathCell("IncludeAssets", assetInfo.AssetPath);
rowData.AddStringValueCell("AssetSource", "BuiltinAsset");
rowData.AddStringValueCell("AssetGUID", assetInfo.AssetGUID);
sourceDatas.Add(rowData);
}
}
_includeTableView.itemsSource = sourceDatas;
_includeTableView.RebuildView();
}
private void OnClickBundleTableView(PointerDownEvent evt, ITableData data)
{
// 鼠标双击后检视
if (evt.clickCount != 2)
return;
var bundleTableData = data as BundleTableData;
if (bundleTableData.BundleInfo.Encrypted)
return;
if (_buildReport.Summary.BuildBundleType == (int)EBuildBundleType.AssetBundle)
{
string rootDirectory = Path.GetDirectoryName(_reportFilePath);
string filePath = $"{rootDirectory}/{bundleTableData.BundleInfo.FileName}";
if (File.Exists(filePath))
Selection.activeObject = AssetBundleRecorder.GetAssetBundle(filePath);
else
Selection.activeObject = null;
}
}
private void OnClickIncludeTableView(PointerDownEvent evt, ITableData data)
{
// 鼠标双击后检视
if (evt.clickCount != 2)
return;
foreach (var cell in data.Cells)
{
if (cell is AssetPathCell assetPathCell)
{
if (assetPathCell.PingAssetObject())
break;
}
}
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6a8ecbacce158fc4d9d4d87b7c44b42d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,8 @@
<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;">
<YooAsset.Editor.TableViewer name="TopTableView" style="flex-grow: 1;" />
</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;">
<YooAsset.Editor.TableViewer name="BottomTableView" style="flex-grow: 1;" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 93f6f95d85a14e545a75b0335085339d
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
@@ -0,0 +1,180 @@
#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 ReporterSummaryViewer
{
private VisualTreeAsset _visualAsset;
private TemplateContainer _root;
private ScrollView _scrollView;
/// <summary>
/// 初始化页面
/// </summary>
public void InitViewer()
{
// 加载布局文件
_visualAsset = UxmlLoader.LoadWindowUXML<ReporterSummaryViewer>();
if (_visualAsset == null)
return;
_root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f;
// 概述列表
_scrollView = _root.Q<ScrollView>("ScrollView");
}
/// <summary>
/// 填充页面数据
/// </summary>
public void FillViewData(BuildReport buildReport)
{
_scrollView.Clear();
BindListViewHeader("Build Infos");
BindListViewItem("YooAsset Version", buildReport.Summary.YooVersion);
BindListViewItem("UnityEngine Version", buildReport.Summary.UnityVersion);
BindListViewItem("Build Date", buildReport.Summary.BuildDate);
BindListViewItem("Build Seconds", ConvertTime(buildReport.Summary.BuildSeconds));
BindListViewItem("Build Target", $"{buildReport.Summary.BuildTarget}");
BindListViewItem("Build Pipeline", $"{buildReport.Summary.BuildPipeline}");
BindListViewItem("Build Bundle Type", buildReport.Summary.BuildBundleType.ToString());
BindListViewItem("Package Name", buildReport.Summary.BuildPackageName);
BindListViewItem("Package Version", buildReport.Summary.BuildPackageVersion);
BindListViewItem("Package Note", buildReport.Summary.BuildPackageNote);
BindListViewItem(string.Empty, string.Empty);
BindListViewHeader("Collect Settings");
BindListViewItem("Unique Bundle Name", $"{buildReport.Summary.UniqueBundleName}");
BindListViewItem("Enable Addressable", $"{buildReport.Summary.EnableAddressable}");
BindListViewItem("Support Extensionless", $"{buildReport.Summary.SupportExtensionless}");
BindListViewItem("Location To Lower", $"{buildReport.Summary.LocationToLower}");
BindListViewItem("Include Asset GUID", $"{buildReport.Summary.IncludeAssetGUID}");
BindListViewItem("Auto Collect Shaders", $"{buildReport.Summary.AutoCollectShaders}");
BindListViewItem("Ignore Rule Name", $"{buildReport.Summary.IgnoreRuleName}");
BindListViewItem(string.Empty, string.Empty);
BindListViewHeader("Build Params");
BindListViewItem("Clear Build Cache Files", $"{buildReport.Summary.ClearBuildCacheFiles}");
BindListViewItem("Use Asset Dependency DB", $"{buildReport.Summary.UseAssetDependencyDB}");
BindListViewItem("Enable Share Pack Rule", $"{buildReport.Summary.EnableSharePackRule}");
BindListViewItem("Single Referenced Pack Alone", $"{buildReport.Summary.SingleReferencedPackAlone}");
BindListViewItem("Encryption Services", buildReport.Summary.EncryptionServicesClassName);
BindListViewItem("Manifest Process Services", buildReport.Summary.ManifestProcessServicesClassName);
BindListViewItem("Manifest Restore Services", buildReport.Summary.ManifestRestoreServicesClassName);
BindListViewItem("FileNameStyle", $"{buildReport.Summary.FileNameStyle}");
BindListViewItem("CompressOption", $"{buildReport.Summary.CompressOption}");
BindListViewItem("DisableWriteTypeTree", $"{buildReport.Summary.DisableWriteTypeTree}");
BindListViewItem("IgnoreTypeTreeChanges", $"{buildReport.Summary.IgnoreTypeTreeChanges}");
BindListViewItem(string.Empty, string.Empty);
BindListViewHeader("Build Results");
BindListViewItem("Asset File Total Count", $"{buildReport.Summary.AssetFileTotalCount}");
BindListViewItem("Main Asset Total Count", $"{buildReport.Summary.MainAssetTotalCount}");
BindListViewItem("All Bundle Total Count", $"{buildReport.Summary.AllBundleTotalCount}");
BindListViewItem("All Bundle Total Size", ConvertSize(buildReport.Summary.AllBundleTotalSize));
BindListViewItem("Encrypted Bundle Total Count", $"{buildReport.Summary.EncryptedBundleTotalCount}");
BindListViewItem("Encrypted Bundle Total Size", ConvertSize(buildReport.Summary.EncryptedBundleTotalSize));
}
/// <summary>
/// 挂接到父类页面上
/// </summary>
public void AttachParent(VisualElement parent)
{
parent.Add(_root);
}
/// <summary>
/// 从父类页面脱离开
/// </summary>
public void DetachParent()
{
_root.RemoveFromHierarchy();
}
// 列表相关
private void BindListViewHeader(string titile)
{
Toolbar toolbar = new Toolbar();
_scrollView.Add(toolbar);
ToolbarButton titleButton = new ToolbarButton();
titleButton.text = titile;
titleButton.style.unityTextAlign = TextAnchor.MiddleCenter;
titleButton.style.width = 200;
toolbar.Add(titleButton);
ToolbarButton valueButton = new ToolbarButton();
valueButton.style.unityTextAlign = TextAnchor.MiddleCenter;
valueButton.style.width = 150;
valueButton.style.flexShrink = 1;
valueButton.style.flexGrow = 1;
valueButton.SetEnabled(false);
toolbar.Add(valueButton);
}
private void BindListViewItem(string name, string value)
{
VisualElement element = MakeListViewItem();
_scrollView.Add(element);
// Title
var titleLabel = element.Q<Label>("TitleLabel");
titleLabel.text = name;
// Value
var valueLabel = element.Q<Label>("ValueLabel");
valueLabel.text = value;
}
private VisualElement MakeListViewItem()
{
VisualElement element = new VisualElement();
element.style.flexDirection = FlexDirection.Row;
var titleLabel = new Label();
titleLabel.name = "TitleLabel";
titleLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
titleLabel.style.marginLeft = 3f;
titleLabel.style.width = 200;
element.Add(titleLabel);
var valueLabel = new Label();
valueLabel.name = "ValueLabel";
valueLabel.style.unityTextAlign = TextAnchor.MiddleLeft;
valueLabel.style.marginLeft = 3f;
valueLabel.style.flexGrow = 1f;
valueLabel.style.width = 150;
element.Add(valueLabel);
return element;
}
private string ConvertTime(int time)
{
if (time <= 60)
{
return $"{time}秒钟";
}
else
{
int minute = time / 60;
return $"{minute}分钟";
}
}
private string ConvertSize(long size)
{
if (size == 0)
return "0";
return EditorUtility.FormatBytes(size);
}
}
}
#endif
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 896c12501e8f07d47ad8b7362529ab56
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,5 @@
<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:ScrollView name="ScrollView" horizontal-scroller-visibility="Hidden" />
</ui:VisualElement>
</ui:UXML>
@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ac015612956bc8544862fdd3803491bb
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}