From e6c082443ac2d486025be8d6781ed167b2c79869 Mon Sep 17 00:00:00 2001 From: Bill Ramsour Date: Tue, 6 Feb 2018 20:27:55 -0600 Subject: [PATCH 1/4] added asset search bar --- Editor/AssetBundleManageTab.cs | 18 +++++++++++--- Editor/AssetBundleModel/ABModelBundleInfo.cs | 25 ++++++++++++++++++++ Editor/AssetBundleTree.cs | 6 +++++ 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/Editor/AssetBundleManageTab.cs b/Editor/AssetBundleManageTab.cs index 8b00dbd..24474ed 100644 --- a/Editor/AssetBundleManageTab.cs +++ b/Editor/AssetBundleManageTab.cs @@ -18,6 +18,8 @@ internal class AssetBundleManageTab [SerializeField] TreeViewState m_BundleDetailState; + SearchField m_searchField; + Rect m_Position; AssetBundleTree m_BundleTree; @@ -66,6 +68,8 @@ internal void OnEnable(Rect pos, EditorWindow parent) (int)(m_Position.y + m_HorizontalSplitterRect.height * m_VerticalSplitterPercentLeft), (m_HorizontalSplitterRect.width) - k_SplitterWidth, k_SplitterWidth); + + m_searchField = new SearchField(); } @@ -167,15 +171,18 @@ internal void OnGUI(Rect pos) //Right half. float panelLeft = m_HorizontalSplitterRect.x + k_SplitterWidth; float panelWidth = m_VerticalSplitterRectRight.width - k_SplitterWidth * 2; - float panelHeight = m_VerticalSplitterRectRight.y - m_Position.y; + float searchHeight = 20f; + float panelTop = m_Position.y + searchHeight; + float panelHeight = m_VerticalSplitterRectRight.y - panelTop; + OnGUISearchBar(new Rect(panelLeft, m_Position.y, panelWidth, searchHeight)); m_AssetList.OnGUI(new Rect( panelLeft, - m_Position.y, + panelTop, panelWidth, panelHeight)); m_MessageList.OnGUI(new Rect( panelLeft, - m_Position.y + panelHeight + k_SplitterWidth, + panelTop + panelHeight + k_SplitterWidth, panelWidth, (m_Position.height - panelHeight) - k_SplitterWidth * 2)); @@ -184,6 +191,11 @@ internal void OnGUI(Rect pos) } } + void OnGUISearchBar(Rect rect) + { + m_BundleTree.searchString = m_searchField.OnGUI(rect, m_BundleTree.searchString); + m_AssetList.searchString = m_BundleTree.searchString; + } private void HandleHorizontalResize() { diff --git a/Editor/AssetBundleModel/ABModelBundleInfo.cs b/Editor/AssetBundleModel/ABModelBundleInfo.cs index d25119c..9ee0af2 100644 --- a/Editor/AssetBundleModel/ABModelBundleInfo.cs +++ b/Editor/AssetBundleModel/ABModelBundleInfo.cs @@ -242,6 +242,8 @@ internal void ForceNeedUpdate() abstract internal void HandleReparent(string parentName, BundleFolderInfo newParent = null); abstract internal List GetDependencies(); + + abstract internal bool DoesItemMatchSearch(string search); } internal class BundleDataInfo : BundleInfo @@ -545,6 +547,21 @@ internal override List GetDependencies() { return m_DependentAssets; } + + internal override bool DoesItemMatchSearch(string search) + { + foreach(var asset in m_ConcreteAssets) + { + if (asset.displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) + return true; + } + foreach (var asset in m_DependentAssets) + { + if (asset.displayName.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0) + return true; + } + return false; + } } internal class BundleVariantDataInfo : BundleDataInfo @@ -721,6 +738,14 @@ internal override void HandleDelete(bool isRootOfDelete, string forcedNewName="" m_Children.Clear(); } + internal override bool DoesItemMatchSearch(string search) + { + bool match = false; + foreach (var child in m_Children) + match |= child.Value.DoesItemMatchSearch(search); + return match; + } + protected override void RefreshMessages() { m_BundleMessages.SetFlag(MessageSystem.MessageFlag.ErrorInChildren, false); diff --git a/Editor/AssetBundleTree.cs b/Editor/AssetBundleTree.cs index 994efdb..f9326eb 100644 --- a/Editor/AssetBundleTree.cs +++ b/Editor/AssetBundleTree.cs @@ -31,6 +31,12 @@ protected override bool CanRename(TreeViewItem item) return item.displayName.Length > 0; } + protected override bool DoesItemMatchSearch(TreeViewItem item, string search) + { + var bundleItem = item as AssetBundleModel.BundleTreeItem; + return bundleItem.bundle.DoesItemMatchSearch(search); + } + protected override void RowGUI(RowGUIArgs args) { var bundleItem = (args.item as AssetBundleModel.BundleTreeItem); From dc5d369824261792050c5115039ad3397e7118f9 Mon Sep 17 00:00:00 2001 From: Bill Ramsour Date: Tue, 6 Feb 2018 20:41:13 -0600 Subject: [PATCH 2/4] fixing for folder case. --- Editor/AssetBundleModel/ABModelBundleInfo.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/Editor/AssetBundleModel/ABModelBundleInfo.cs b/Editor/AssetBundleModel/ABModelBundleInfo.cs index 9ee0af2..1babec1 100644 --- a/Editor/AssetBundleModel/ABModelBundleInfo.cs +++ b/Editor/AssetBundleModel/ABModelBundleInfo.cs @@ -740,10 +740,7 @@ internal override void HandleDelete(bool isRootOfDelete, string forcedNewName="" internal override bool DoesItemMatchSearch(string search) { - bool match = false; - foreach (var child in m_Children) - match |= child.Value.DoesItemMatchSearch(search); - return match; + return false; //folders don't ever match. } protected override void RefreshMessages() From 0455f3dc1055972da1cb739f2be1ae5a4f4d9d36 Mon Sep 17 00:00:00 2001 From: Bill Ramsour Date: Wed, 21 Feb 2018 08:32:46 -0600 Subject: [PATCH 3/4] step two in reseting dev branch. --- Editor/AssetBundleManageTab.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Editor/AssetBundleManageTab.cs b/Editor/AssetBundleManageTab.cs index 24474ed..8e9adc1 100644 --- a/Editor/AssetBundleManageTab.cs +++ b/Editor/AssetBundleManageTab.cs @@ -18,8 +18,6 @@ internal class AssetBundleManageTab [SerializeField] TreeViewState m_BundleDetailState; - SearchField m_searchField; - Rect m_Position; AssetBundleTree m_BundleTree; @@ -39,6 +37,7 @@ internal class AssetBundleManageTab const float k_SplitterWidth = 3f; private static float m_UpdateDelay = 0f; + SearchField m_searchField; EditorWindow m_Parent = null; @@ -197,6 +196,11 @@ void OnGUISearchBar(Rect rect) m_AssetList.searchString = m_BundleTree.searchString; } + public bool hasSearch + { + get { return m_BundleTree.hasSearch; } + } + private void HandleHorizontalResize() { m_HorizontalSplitterRect.x = (int)(m_Position.width * m_HorizontalSplitterPercent); From 84b95f40d804de6aff723a0015569e97400c156c Mon Sep 17 00:00:00 2001 From: Bill Ramsour Date: Fri, 23 Feb 2018 13:14:11 -0600 Subject: [PATCH 4/4] updating package info for next release. --- CHANGELOG.md | 3 +++ package.json | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6df1478..dc15cd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ All notable changes to this package will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.4.0] - 2018-2-23 +- Added a search bar to the main tab. Searches based on asset name. + ## [1.3.0] - 2018-1-08 - serialization fix for inspect tab (was causing entire window to potentially be blank). - documentation fix diff --git a/package.json b/package.json index 0803d3e..86af037 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.unity.assetbundlebrowser", "displayName": "Asset Bundle Browser", - "version": "1.3.0", + "version": "1.4.0", "unity": "2018.1", "description": "The Asset Bundle Browser tool enables the user to view and edit the configuration of asset bundles for their Unity project. It will block editing that would create invalid bundles, and inform you of any issues with existing bundles. It also provides basic build functionality.\n\nUse this tool as an alternative to selecting assets and setting their asset bundle manually in the inspector. It can be dropped into any Unity project with a version of 5.6 or greater. It will create a new menu item in Window > AssetBundle Browser. The bundle configuration, build functionality, and built-bundle inspection are split into three tabs within the new window.", "keywords": ["asset", "bundle", "bundles", "assetbundles"],