Update AssetBundleBrowser

pull/4/head
hevinci 2022-03-15 22:30:46 +08:00
parent 6c0fbdae1f
commit d190bc35b4
9 changed files with 47 additions and 37 deletions

View File

@ -15,19 +15,29 @@ namespace YooAsset.Editor
public static void ShowExample() public static void ShowExample()
{ {
AssetBundleBrowserWindow wnd = GetWindow<AssetBundleBrowserWindow>(); AssetBundleBrowserWindow wnd = GetWindow<AssetBundleBrowserWindow>();
wnd.titleContent = new GUIContent("栗都관啞응묏야"); wnd.titleContent = new GUIContent("资源包浏览工具");
wnd.minSize = new Vector2(800, 600); wnd.minSize = new Vector2(800, 600);
} }
/// <summary>
/// 显示模式
/// </summary>
private enum EShowMode private enum EShowMode
{ {
/// <summary>
/// 资源对象列表显示模式
/// </summary>
AssetList, AssetList,
/// <summary>
/// 资源包列表显示模式
/// </summary>
BundleList, BundleList,
} }
private ToolbarMenu _showModeMenu; private ToolbarMenu _showModeMenu;
private AssetListViewer _assetListViewer; private AssetListBrowserViewer _assetListViewer;
private BundleListViewer _bundleListViewer; private BundleListBrowserViewer _bundleListViewer;
private EShowMode _showMode; private EShowMode _showMode;
private string _searchKeyWord; private string _searchKeyWord;
@ -38,7 +48,7 @@ namespace YooAsset.Editor
{ {
VisualElement root = this.rootVisualElement; VisualElement root = this.rootVisualElement;
// 속潼꼈애匡숭 // 加载布局文件
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowser.uxml"; string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/AssetBundleBrowser.uxml";
var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml); var visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (visualAsset == null) if (visualAsset == null)
@ -48,28 +58,28 @@ namespace YooAsset.Editor
} }
visualAsset.CloneTree(root); visualAsset.CloneTree(root);
// 돔흙객큐 // 导入按钮
var importBtn = root.Q<Button>("ImportButton"); var importBtn = root.Q<Button>("ImportButton");
importBtn.clicked += ImportBtn_onClick; importBtn.clicked += ImportBtn_onClick;
// 鞫刻친駕꽉데 // 显示模式菜单
_showModeMenu = root.Q<ToolbarMenu>("ShowModeMenu"); _showModeMenu = root.Q<ToolbarMenu>("ShowModeMenu");
_showModeMenu.menu.AppendAction(EShowMode.AssetList.ToString(), ShowModeMenuAction1); _showModeMenu.menu.AppendAction(EShowMode.AssetList.ToString(), ShowModeMenuAction1);
_showModeMenu.menu.AppendAction(EShowMode.BundleList.ToString(), ShowModeMenuAction2); _showModeMenu.menu.AppendAction(EShowMode.BundleList.ToString(), ShowModeMenuAction2);
// 鎧乞으 // 搜索栏
var searchField = root.Q<ToolbarPopupSearchField>("SearchField"); var searchField = root.Q<ToolbarPopupSearchField>("SearchField");
searchField.RegisterValueChangedCallback(OnSearchKeyWordChange); searchField.RegisterValueChangedCallback(OnSearchKeyWordChange);
// 속潼女충 // 加载页面
_assetListViewer = new AssetListViewer(); _assetListViewer = new AssetListBrowserViewer();
_assetListViewer.InitViewer(); _assetListViewer.InitViewer();
// 속潼女충 // 加载页面
_bundleListViewer = new BundleListViewer(); _bundleListViewer = new BundleListBrowserViewer();
_bundleListViewer.InitViewer(); _bundleListViewer.InitViewer();
// 놓迦女충 // 初始页面
_showMode = EShowMode.AssetList; _showMode = EShowMode.AssetList;
_showModeMenu.text = EShowMode.AssetList.ToString(); _showModeMenu.text = EShowMode.AssetList.ToString();
_assetListViewer.AttachParent(root); _assetListViewer.AttachParent(root);
@ -77,7 +87,7 @@ namespace YooAsset.Editor
private void ImportBtn_onClick() private void ImportBtn_onClick()
{ {
string selectFilePath = EditorUtility.OpenFilePanel("돔흙껸땀헌데", EditorTools.GetProjectPath(), "bytes"); string selectFilePath = EditorUtility.OpenFilePanel("导入补丁清单", EditorTools.GetProjectPath(), "bytes");
if (string.IsNullOrEmpty(selectFilePath)) if (string.IsNullOrEmpty(selectFilePath))
return; return;

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class AssetListViewer internal class AssetListBrowserViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@ -19,22 +19,22 @@ namespace YooAsset.Editor
private PatchManifest _manifest; private PatchManifest _manifest;
/// <summary> /// <summary>
/// 初始化页面 /// 初始化页面
/// </summary> /// </summary>
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/AssetListViewer.uxml"; string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/AssetListBrowserViewer.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml); _visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(AssetListViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(AssetListBrowserViewer)}.uxml : {uxml}");
return; return;
} }
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
// 资源列表 // 资源列表
_assetListView = _root.Q<ListView>("TopListView"); _assetListView = _root.Q<ListView>("TopListView");
_assetListView.makeItem = MakeAssetListViewItem; _assetListView.makeItem = MakeAssetListViewItem;
_assetListView.bindItem = BindAssetListViewItem; _assetListView.bindItem = BindAssetListViewItem;
@ -44,14 +44,14 @@ namespace YooAsset.Editor
#else #else
_assetListView.onSelectionChanged += AssetListView_onSelectionChange; _assetListView.onSelectionChanged += AssetListView_onSelectionChange;
#endif #endif
// 依赖列表 // 依赖列表
_dependListView = _root.Q<ListView>("BottomListView"); _dependListView = _root.Q<ListView>("BottomListView");
_dependListView.makeItem = MakeDependListViewItem; _dependListView.makeItem = MakeDependListViewItem;
_dependListView.bindItem = BindDependListViewItem; _dependListView.bindItem = BindDependListViewItem;
} }
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
public void FillViewData(PatchManifest manifest, string searchKeyWord) public void FillViewData(PatchManifest manifest, string searchKeyWord)
{ {
@ -75,7 +75,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 挂接到父类页面上 /// 挂接到父类页面上
/// </summary> /// </summary>
public void AttachParent(VisualElement parent) public void AttachParent(VisualElement parent)
{ {
@ -83,7 +83,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 从父类页面脱离开 /// 从父类页面脱离开
/// </summary> /// </summary>
public void DetachParent() public void DetachParent()
{ {
@ -91,7 +91,7 @@ namespace YooAsset.Editor
} }
// 资源列表相关 // 资源列表相关
private VisualElement MakeAssetListViewItem() private VisualElement MakeAssetListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();
@ -156,7 +156,7 @@ namespace YooAsset.Editor
} }
} }
// 依赖列表相关 // 依赖列表相关
private VisualElement MakeDependListViewItem() private VisualElement MakeDependListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();

View File

@ -9,7 +9,7 @@ using UnityEngine.UIElements;
namespace YooAsset.Editor namespace YooAsset.Editor
{ {
internal class BundleListViewer internal class BundleListBrowserViewer
{ {
private VisualTreeAsset _visualAsset; private VisualTreeAsset _visualAsset;
private TemplateContainer _root; private TemplateContainer _root;
@ -19,22 +19,22 @@ namespace YooAsset.Editor
private PatchManifest _manifest; private PatchManifest _manifest;
/// <summary> /// <summary>
/// 初始化页面 /// 初始化页面
/// </summary> /// </summary>
public void InitViewer() public void InitViewer()
{ {
// 加载布局文件 // 加载布局文件
string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/BundleListViewer.uxml"; string uxml = "Assets/YooAsset/Editor/AssetBundleBrowser/VisualViewers/BundleListBrowserViewer.uxml";
_visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml); _visualAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxml);
if (_visualAsset == null) if (_visualAsset == null)
{ {
Debug.LogError($"Not found {nameof(BundleListViewer)}.uxml : {uxml}"); Debug.LogError($"Not found {nameof(BundleListBrowserViewer)}.uxml : {uxml}");
return; return;
} }
_root = _visualAsset.CloneTree(); _root = _visualAsset.CloneTree();
_root.style.flexGrow = 1f; _root.style.flexGrow = 1f;
// 资源包列表 // 资源包列表
_bundleListView = _root.Q<ListView>("TopListView"); _bundleListView = _root.Q<ListView>("TopListView");
_bundleListView.makeItem = MakeBundleListViewItem; _bundleListView.makeItem = MakeBundleListViewItem;
_bundleListView.bindItem = BindBundleListViewItem; _bundleListView.bindItem = BindBundleListViewItem;
@ -44,14 +44,14 @@ namespace YooAsset.Editor
_bundleListView.onSelectionChanged += BundleListView_onSelectionChange; _bundleListView.onSelectionChanged += BundleListView_onSelectionChange;
#endif #endif
// 包含列表 // 包含列表
_includeListView = _root.Q<ListView>("BottomListView"); _includeListView = _root.Q<ListView>("BottomListView");
_includeListView.makeItem = MakeContainsListViewItem; _includeListView.makeItem = MakeContainsListViewItem;
_includeListView.bindItem = BindContainsListViewItem; _includeListView.bindItem = BindContainsListViewItem;
} }
/// <summary> /// <summary>
/// 填充页面数据 /// 填充页面数据
/// </summary> /// </summary>
public void FillViewData(PatchManifest manifest, string searchKeyWord) public void FillViewData(PatchManifest manifest, string searchKeyWord)
{ {
@ -75,7 +75,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 挂接到父类页面上 /// 挂接到父类页面上
/// </summary> /// </summary>
public void AttachParent(VisualElement parent) public void AttachParent(VisualElement parent)
{ {
@ -83,7 +83,7 @@ namespace YooAsset.Editor
} }
/// <summary> /// <summary>
/// 从父类页面脱离开 /// 从父类页面脱离开
/// </summary> /// </summary>
public void DetachParent() public void DetachParent()
{ {
@ -91,7 +91,7 @@ namespace YooAsset.Editor
} }
// 资源列表相关 // 资源列表相关
private VisualElement MakeBundleListViewItem() private VisualElement MakeBundleListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();
@ -183,7 +183,7 @@ namespace YooAsset.Editor
} }
} }
// 依赖列表相关 // 依赖列表相关
private VisualElement MakeContainsListViewItem() private VisualElement MakeContainsListViewItem()
{ {
VisualElement element = new VisualElement(); VisualElement element = new VisualElement();