mirror of https://github.com/tuyoogame/YooAsset
Update AssetBundleBrowser
parent
fca99fe689
commit
85fe1f2485
|
@ -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="ShowModeMenu" text="ShowMode" style="width: 100px; flex-grow: 0;" />
|
||||
<uie:ToolbarPopupSearchField focusable="true" name="SearchField" style="flex-grow: 1; width: 300px;" />
|
||||
<ui:Button text="导入" 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: 9052b72c383e95043a0c7e7f369b1ad7
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
@ -1,11 +1,117 @@
|
|||
using System.Collections;
|
||||
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 AssetBundleBrowserWindow
|
||||
public class AssetBundleBrowserWindow : EditorWindow
|
||||
{
|
||||
[MenuItem("YooAsset/AssetBundle Browser", false, 103)]
|
||||
public static void ShowExample()
|
||||
{
|
||||
AssetBundleBrowserWindow wnd = GetWindow<AssetBundleBrowserWindow>();
|
||||
wnd.titleContent = new GUIContent("栗都관啞응묏야");
|
||||
wnd.minSize = new Vector2(800, 600);
|
||||
}
|
||||
|
||||
private enum EShowMode
|
||||
{
|
||||
AssetList,
|
||||
BundleList,
|
||||
}
|
||||
|
||||
private ToolbarMenu _showModeMenu;
|
||||
private AssetListViewer _assetListViewer;
|
||||
private BundleListViewer _bundleListViewer;
|
||||
|
||||
private EShowMode _showMode;
|
||||
private string _searchKeyWord;
|
||||
private PatchManifest _manifest;
|
||||
|
||||
|
||||
public void CreateGUI()
|
||||
{
|
||||
VisualElement root = this.rootVisualElement;
|
||||
|
||||
// 속潼꼈애匡숭
|
||||
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowser.uxml";
|
||||
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
||||
if (visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found AssetBundleBrowser.uxml : {uxml}");
|
||||
return;
|
||||
}
|
||||
visualAsset.CloneTree(root);
|
||||
|
||||
// 돔흙객큐
|
||||
var importBtn = root.Q<Button>("ImportButton");
|
||||
importBtn.clicked += ImportBtn_onClick;
|
||||
|
||||
// 鞫刻친駕꽉데
|
||||
_showModeMenu = root.Q<ToolbarMenu>("ShowModeMenu");
|
||||
_showModeMenu.menu.AppendAction(EShowMode.AssetList.ToString(), ShowModeMenuAction1);
|
||||
_showModeMenu.menu.AppendAction(EShowMode.BundleList.ToString(), ShowModeMenuAction2);
|
||||
|
||||
// 鎧乞으
|
||||
var searchField = root.Q<ToolbarPopupSearchField>("SearchField");
|
||||
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
|
||||
|
||||
// 속潼女충
|
||||
_assetListViewer = new AssetListViewer();
|
||||
_assetListViewer.InitViewer();
|
||||
|
||||
// 속潼女충
|
||||
_bundleListViewer = new BundleListViewer();
|
||||
_bundleListViewer.InitViewer();
|
||||
|
||||
// 놓迦女충
|
||||
_showMode = EShowMode.AssetList;
|
||||
_showModeMenu.text = EShowMode.AssetList.ToString();
|
||||
_assetListViewer.AttachParent(root);
|
||||
}
|
||||
|
||||
private void ImportBtn_onClick()
|
||||
{
|
||||
string selectFilePath = EditorUtility.OpenFilePanel("돔흙껸땀헌데", EditorTools.GetProjectPath(), "bytes");
|
||||
if (string.IsNullOrEmpty(selectFilePath))
|
||||
return;
|
||||
|
||||
string jsonData = FileUtility.ReadFile(selectFilePath);
|
||||
_manifest = PatchManifest.Deserialize(jsonData);
|
||||
_assetListViewer.FillViewData(_manifest, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_manifest, _searchKeyWord);
|
||||
}
|
||||
private void OnSearchKeyWordChange(ChangeEvent<string> e)
|
||||
{
|
||||
_searchKeyWord = e.newValue;
|
||||
_assetListViewer.FillViewData(_manifest, _searchKeyWord);
|
||||
_bundleListViewer.FillViewData(_manifest, _searchKeyWord);
|
||||
}
|
||||
private void ShowModeMenuAction1(DropdownMenuAction action)
|
||||
{
|
||||
if (_showMode != EShowMode.AssetList)
|
||||
{
|
||||
_showMode = EShowMode.AssetList;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_showModeMenu.text = EShowMode.AssetList.ToString();
|
||||
_bundleListViewer.DetachParent();
|
||||
_assetListViewer.AttachParent(root);
|
||||
}
|
||||
}
|
||||
private void ShowModeMenuAction2(DropdownMenuAction action)
|
||||
{
|
||||
if (_showMode != EShowMode.BundleList)
|
||||
{
|
||||
_showMode = EShowMode.BundleList;
|
||||
VisualElement root = this.rootVisualElement;
|
||||
_showModeMenu.text = EShowMode.BundleList.ToString();
|
||||
_assetListViewer.DetachParent();
|
||||
_bundleListViewer.AttachParent(root);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d6938e4c868d3f34f97d3bb0dbd9d509
|
||||
guid: 0063c156ec88acc4d862f9b31e6c74ad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2dfde84e843cc34468dd1071608926bc
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,241 @@
|
|||
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 AssetListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _assetListView;
|
||||
private ListView _dependListView;
|
||||
private PatchManifest _manifest;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/AssetListViewer.uxml";
|
||||
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(AssetListViewer)}.uxml : {uxml}");
|
||||
return;
|
||||
}
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源列表
|
||||
_assetListView = _root.Q<ListView>("TopListView");
|
||||
_assetListView.makeItem = MakeAssetListViewItem;
|
||||
_assetListView.bindItem = BindAssetListViewItem;
|
||||
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_assetListView.onSelectionChange += AssetListView_onSelectionChange;
|
||||
#else
|
||||
_assetListView.onSelectionChanged += AssetListView_onSelectionChange;
|
||||
#endif
|
||||
// 依赖列表
|
||||
_dependListView = _root.Q<ListView>("BottomListView");
|
||||
_dependListView.makeItem = MakeDependListViewItem;
|
||||
_dependListView.bindItem = BindDependListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(PatchManifest manifest, string searchKeyWord)
|
||||
{
|
||||
_manifest = manifest;
|
||||
_assetListView.Clear();
|
||||
_assetListView.itemsSource = FilterViewItems(manifest, searchKeyWord);
|
||||
}
|
||||
private List<PatchAsset> FilterViewItems(PatchManifest manifest, string searchKeyWord)
|
||||
{
|
||||
List<PatchAsset> result = new List<PatchAsset>(manifest.AssetList.Count);
|
||||
foreach (var patchAsset in manifest.AssetList)
|
||||
{
|
||||
if(string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (patchAsset.AssetPath.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(patchAsset);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 资源列表相关
|
||||
private VisualElement MakeAssetListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 145;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindAssetListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _assetListView.itemsSource as List<PatchAsset>;
|
||||
var patchAsset = sourceData[index];
|
||||
var patchBundle = _manifest.BundleList[patchAsset.BundleID];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = patchAsset.AssetPath;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = GetAssetFileSize(patchAsset.AssetPath);
|
||||
|
||||
// Main Bundle
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = patchBundle.BundleName;
|
||||
}
|
||||
private void AssetListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
PatchAsset patchAsset = item as PatchAsset;
|
||||
FillDependListView(patchAsset);
|
||||
}
|
||||
}
|
||||
|
||||
// 依赖列表相关
|
||||
private VisualElement MakeDependListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 250;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindDependListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<PatchBundle> bundles = _dependListView.itemsSource as List<PatchBundle>;
|
||||
PatchBundle patchBundle = bundles[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = patchBundle.BundleName;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = (patchBundle.SizeBytes / 1024f).ToString("f1") + " KB";
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = patchBundle.Hash;
|
||||
}
|
||||
private void FillDependListView(PatchAsset patchAsset)
|
||||
{
|
||||
List<PatchBundle> bundles = new List<PatchBundle>();
|
||||
var mainBundle = _manifest.BundleList[patchAsset.BundleID];
|
||||
bundles.Add(mainBundle);
|
||||
for (int i = 0; i < patchAsset.DependIDs.Length; i++)
|
||||
{
|
||||
int bundleID = patchAsset.DependIDs[i];
|
||||
var dependBundle = _manifest.BundleList[bundleID];
|
||||
bundles.Add(dependBundle);
|
||||
}
|
||||
|
||||
_dependListView.Clear();
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_dependListView.ClearSelection();
|
||||
#endif
|
||||
_dependListView.itemsSource = bundles;
|
||||
}
|
||||
|
||||
private string GetAssetFileSize(string assetPath)
|
||||
{
|
||||
string fullPath = EditorTools.GetProjectPath() + "/" + assetPath;
|
||||
if (File.Exists(fullPath) == false)
|
||||
return "unknown";
|
||||
else
|
||||
return (EditorTools.GetFileSize(fullPath) / 1024f).ToString("f1") + " KB";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: be28b213af401274881688f5bc0c2381
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,18 @@
|
|||
<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;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Asset Path" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Main Bundle" display-tooltip-when-elided="true" name="TopBar3" style="width: 145px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Depend Bundles" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="BottomBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5f81bc15a55ee0a49a266f9d71e2372b
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
|
@ -0,0 +1,294 @@
|
|||
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 BundleListViewer
|
||||
{
|
||||
private VisualTreeAsset _visualAsset;
|
||||
private TemplateContainer _root;
|
||||
|
||||
private ListView _bundleListView;
|
||||
private ListView _includeListView;
|
||||
private PatchManifest _manifest;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化页面
|
||||
/// </summary>
|
||||
public void InitViewer()
|
||||
{
|
||||
// 加载布局文件
|
||||
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/BundleListViewer.uxml";
|
||||
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
|
||||
if (_visualAsset == null)
|
||||
{
|
||||
Debug.LogError($"Not found {nameof(BundleListViewer)}.uxml : {uxml}");
|
||||
return;
|
||||
}
|
||||
_root = _visualAsset.CloneTree();
|
||||
_root.style.flexGrow = 1f;
|
||||
|
||||
// 资源包列表
|
||||
_bundleListView = _root.Q<ListView>("TopListView");
|
||||
_bundleListView.makeItem = MakeBundleListViewItem;
|
||||
_bundleListView.bindItem = BindBundleListViewItem;
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_bundleListView.onSelectionChange += BundleListView_onSelectionChange;
|
||||
#else
|
||||
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
|
||||
#endif
|
||||
|
||||
// 包含列表
|
||||
_includeListView = _root.Q<ListView>("BottomListView");
|
||||
_includeListView.makeItem = MakeContainsListViewItem;
|
||||
_includeListView.bindItem = BindContainsListViewItem;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 填充页面数据
|
||||
/// </summary>
|
||||
public void FillViewData(PatchManifest manifest, string searchKeyWord)
|
||||
{
|
||||
_manifest = manifest;
|
||||
_bundleListView.Clear();
|
||||
_bundleListView.itemsSource = FilterViewItems(manifest, searchKeyWord);
|
||||
}
|
||||
private List<PatchBundle> FilterViewItems(PatchManifest manifest, string searchKeyWord)
|
||||
{
|
||||
List<PatchBundle> result = new List<PatchBundle>(manifest.BundleList.Count);
|
||||
foreach (var patchBundle in manifest.BundleList)
|
||||
{
|
||||
if (string.IsNullOrEmpty(searchKeyWord) == false)
|
||||
{
|
||||
if (patchBundle.BundleName.Contains(searchKeyWord) == false)
|
||||
continue;
|
||||
}
|
||||
result.Add(patchBundle);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 挂接到父类页面上
|
||||
/// </summary>
|
||||
public void AttachParent(VisualElement parent)
|
||||
{
|
||||
parent.Add(_root);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 从父类页面脱离开
|
||||
/// </summary>
|
||||
public void DetachParent()
|
||||
{
|
||||
_root.RemoveFromHierarchy();
|
||||
}
|
||||
|
||||
|
||||
// 资源列表相关
|
||||
private VisualElement MakeBundleListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 250;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label4";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 60;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label5";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 80;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindBundleListViewItem(VisualElement element, int index)
|
||||
{
|
||||
var sourceData = _bundleListView.itemsSource as List<PatchBundle>;
|
||||
var patchBundle = sourceData[index];
|
||||
|
||||
// Bundle Name
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = patchBundle.BundleName;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = (patchBundle.SizeBytes / 1024f).ToString("f1") + " KB";
|
||||
|
||||
// Hash
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = patchBundle.Hash;
|
||||
|
||||
// Version
|
||||
var label4 = element.Q<Label>("Label4");
|
||||
label4.text = patchBundle.Version.ToString();
|
||||
|
||||
// Tags
|
||||
var label5 = element.Q<Label>("Label5");
|
||||
label5.text = GetTagsString(patchBundle.Tags);
|
||||
}
|
||||
private void BundleListView_onSelectionChange(IEnumerable<object> objs)
|
||||
{
|
||||
foreach (var item in objs)
|
||||
{
|
||||
PatchBundle patchBundle = item as PatchBundle;
|
||||
FillContainsListView(patchBundle);
|
||||
}
|
||||
}
|
||||
|
||||
// 依赖列表相关
|
||||
private VisualElement MakeContainsListViewItem()
|
||||
{
|
||||
VisualElement element = new VisualElement();
|
||||
element.style.flexDirection = FlexDirection.Row;
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label1";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
label.style.flexGrow = 1f;
|
||||
label.style.width = 280;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label2";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//assetSizeLabel.style.flexGrow = 1f;
|
||||
label.style.width = 100;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
{
|
||||
var label = new Label();
|
||||
label.name = "Label3";
|
||||
label.style.unityTextAlign = TextAnchor.MiddleLeft;
|
||||
label.style.marginLeft = 3f;
|
||||
//label.style.flexGrow = 1f;
|
||||
label.style.width = 250;
|
||||
element.Add(label);
|
||||
}
|
||||
|
||||
return element;
|
||||
}
|
||||
private void BindContainsListViewItem(VisualElement element, int index)
|
||||
{
|
||||
List<string> containsList = _includeListView.itemsSource as List<string>;
|
||||
string assetPath = containsList[index];
|
||||
|
||||
// Asset Path
|
||||
var label1 = element.Q<Label>("Label1");
|
||||
label1.text = assetPath;
|
||||
|
||||
// Size
|
||||
var label2 = element.Q<Label>("Label2");
|
||||
label2.text = GetAssetFileSize(assetPath);
|
||||
|
||||
// GUID
|
||||
var label3 = element.Q<Label>("Label3");
|
||||
label3.text = AssetDatabase.AssetPathToGUID(assetPath);
|
||||
}
|
||||
private void FillContainsListView(PatchBundle patchBundle)
|
||||
{
|
||||
List<string> containsList = new List<string>();
|
||||
|
||||
int bundleID = -1;
|
||||
for (int i = 0; i < _manifest.BundleList.Count; i++)
|
||||
{
|
||||
if (_manifest.BundleList[i] == patchBundle)
|
||||
{
|
||||
bundleID = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bundleID == -1)
|
||||
{
|
||||
Debug.LogError($"Not found bundle in PatchManifest : {patchBundle.BundleName}");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var patchAsset in _manifest.AssetList)
|
||||
{
|
||||
if (patchAsset.BundleID == bundleID)
|
||||
containsList.Add(patchAsset.AssetPath);
|
||||
}
|
||||
|
||||
_includeListView.Clear();
|
||||
#if UNITY_2020_1_OR_NEWER
|
||||
_includeListView.ClearSelection();
|
||||
#endif
|
||||
_includeListView.itemsSource = containsList;
|
||||
}
|
||||
|
||||
private string GetAssetFileSize(string assetPath)
|
||||
{
|
||||
string fullPath = EditorTools.GetProjectPath() + "/" + assetPath;
|
||||
if (File.Exists(fullPath) == false)
|
||||
return "unknown";
|
||||
else
|
||||
return (EditorTools.GetFileSize(fullPath) / 1024f).ToString("f1") + " KB";
|
||||
}
|
||||
private string GetTagsString(string[] tags)
|
||||
{
|
||||
string result = string.Empty;
|
||||
if (tags != null)
|
||||
{
|
||||
for (int i = 0; i < tags.Length; i++)
|
||||
{
|
||||
result += tags[i];
|
||||
result += ";";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a0319abb8eae03b4b88e8f900fe2276c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,22 @@
|
|||
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" editor-extension-mode="False">
|
||||
<ui:VisualElement name="Viewer" style="flex-grow: 1; 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;">
|
||||
<uie:Toolbar name="TopBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Bundle Name" display-tooltip-when-elided="true" name="TopBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="TopBar2" style="width: 100px; -unity-text-align: middle-left; flex-grow: 0;" />
|
||||
<uie:ToolbarButton text="Hash" display-tooltip-when-elided="true" name="TopBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Version" display-tooltip-when-elided="true" name="TopBar4" style="width: 60px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="Tags" display-tooltip-when-elided="true" name="TopBar5" style="width: 80px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="TopListView" item-height="18" 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;">
|
||||
<uie:Toolbar name="BottomBar" style="height: 25px; margin-left: 1px; margin-right: 1px;">
|
||||
<uie:ToolbarButton text="Include Assets" display-tooltip-when-elided="true" name="BottomBar1" style="width: 280px; -unity-text-align: middle-left; flex-grow: 1;" />
|
||||
<uie:ToolbarButton text="Size" display-tooltip-when-elided="true" name="BottomBar2" style="width: 100px; -unity-text-align: middle-left;" />
|
||||
<uie:ToolbarButton text="GUID" display-tooltip-when-elided="true" name="BottomBar3" style="width: 250px; -unity-text-align: middle-left;" />
|
||||
</uie:Toolbar>
|
||||
<ui:ListView focusable="true" name="BottomListView" item-height="18" style="flex-grow: 1;" />
|
||||
</ui:VisualElement>
|
||||
</ui:VisualElement>
|
||||
</ui:UXML>
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56d6dbe0d65ce334a8996beb19612989
|
||||
ScriptedImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
|
Loading…
Reference in New Issue