diff --git a/Plugins/AssetUsageDetector/Editor/SearchResult.cs b/Plugins/AssetUsageDetector/Editor/SearchResult.cs index 543d7f5..fe9d175 100644 --- a/Plugins/AssetUsageDetector/Editor/SearchResult.cs +++ b/Plugins/AssetUsageDetector/Editor/SearchResult.cs @@ -778,28 +778,47 @@ public float DrawOnGUI( SearchResult searchResult, EditorWindow window, float sc IsExpanded = true; } ); - if( searchResult != null && searchResult.NumberOfGroups > 1 && !string.IsNullOrEmpty( treeViewState.searchTerm ) ) + if( !string.IsNullOrEmpty( treeViewState.searchTerm ) ) { if( contextMenu.GetItemCount() > 0 ) contextMenu.AddSeparator( "" ); - contextMenu.AddItem( new GUIContent( "Apply Search to All Results" ), false, () => + if( searchResult != null && searchResult.NumberOfGroups > 1 ) { - for( int i = 0; i < searchResult.NumberOfGroups; i++ ) + contextMenu.AddItem( new GUIContent( "Apply Search to All Results" ), false, () => { - if( searchResult[i].treeView == null ) - continue; + for( int i = 0; i < searchResult.NumberOfGroups; i++ ) + { + if( searchResult[i].treeView == null ) + continue; - string previousSearchTerm = searchResult[i].treeViewState.searchTerm ?? ""; - SearchResultTreeView.SearchMode previousSearchMode = searchResult[i].treeViewState.searchMode; + string previousSearchTerm = searchResult[i].treeViewState.searchTerm ?? ""; + SearchResultTreeView.SearchMode previousSearchMode = searchResult[i].treeViewState.searchMode; - searchResult[i].treeViewState.searchTerm = treeViewState.searchTerm ?? ""; - searchResult[i].treeViewState.searchMode = treeViewState.searchMode; + searchResult[i].treeViewState.searchTerm = treeViewState.searchTerm ?? ""; + searchResult[i].treeViewState.searchMode = treeViewState.searchMode; - if( treeViewState.searchTerm != previousSearchTerm || treeViewState.searchMode != previousSearchMode ) - searchResult[i].treeView.RefreshSearch( previousSearchTerm ); - } - } ); + if( treeViewState.searchTerm != previousSearchTerm || treeViewState.searchMode != previousSearchMode ) + searchResult[i].treeView.RefreshSearch( previousSearchTerm ); + } + } ); + } + + IList treeViewRows = treeView.GetRows(); + if( treeViewRows.Count > 1 ) // References are at depth 1 so if there are any references, at least 2 rows must exist + { + contextMenu.AddItem( new GUIContent( "Hide Search Results" ), false, () => + { + List removedRows = new List( treeViewRows.Count ); + for( int i = treeViewRows.Count - 1; i >= 0; i-- ) + { + if( treeViewRows[i].depth > 0 ) + removedRows.Add( treeViewRows[i].id ); + } + + treeView.HideItems( removedRows ); + } ); + } } } diff --git a/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs b/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs index 20c6c3f..2c2abc8 100644 --- a/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs +++ b/Plugins/AssetUsageDetector/Editor/SearchResultTreeView.cs @@ -991,7 +991,7 @@ private bool GetReferenceNodeOccurrenceIdsRecursive( TreeViewItem item, HashSet< return referenceNodes.Contains( GetDataFromId( item.id ).node ); } - private void HideItems( IList ids ) + public void HideItems( IList ids ) { if( ids.Count > 0 ) { diff --git a/Plugins/AssetUsageDetector/README.txt b/Plugins/AssetUsageDetector/README.txt index f962275..2b43697 100644 --- a/Plugins/AssetUsageDetector/README.txt +++ b/Plugins/AssetUsageDetector/README.txt @@ -1,4 +1,4 @@ -= Asset Usage Detector (v2.5.3) = += Asset Usage Detector (v2.5.4) = Documentation: https://github.com/yasirkula/UnityAssetUsageDetector E-mail: yasirkula@gmail.com \ No newline at end of file diff --git a/package.json b/package.json index f703d99..4e86af0 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "com.yasirkula.assetusagedetector", "displayName": "Asset Usage Detector", - "version": "2.5.3", + "version": "2.5.4", "documentationUrl": "https://github.com/yasirkula/UnityAssetUsageDetector", "changelogUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/releases", "licensesUrl": "https://github.com/yasirkula/UnityAssetUsageDetector/blob/master/LICENSE.txt",