Skip to content

Commit c7e5246

Browse files
committed
Added Collapse All button to Asset Usage Detector window's context menu that collapses all search result groups at once
1 parent 875f3e6 commit c7e5246

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,14 @@ void IHasCustomMenu.AddItemsToMenu( GenericMenu contextMenu )
152152
objectsToSearch[i].RefreshSubAssets();
153153
} );
154154
}
155+
else if( currentPhase == Phase.Complete )
156+
{
157+
if( searchResult != null && searchResult.NumberOfGroups > 0 )
158+
{
159+
contextMenu.AddSeparator( "" );
160+
contextMenu.AddItem( new GUIContent( "Collapse All" ), false, searchResult.CollapseAllSearchResultGroups );
161+
}
162+
}
155163
}
156164

157165
// Shows lock button at the top-right corner

Plugins/AssetUsageDetector/Editor/SearchResult.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,15 @@ public float DrawOnGUI( EditorWindow window, float scrollPosition, bool noAssetD
371371
return scrollPosition;
372372
}
373373

374-
public int IndexOf( SearchResultGroup searchResult )
374+
public int IndexOf( SearchResultGroup searchResultGroup )
375375
{
376-
return result.IndexOf( searchResult );
376+
return result.IndexOf( searchResultGroup );
377+
}
378+
379+
public void CollapseAllSearchResultGroups()
380+
{
381+
for( int i = 0; i < result.Count; i++ )
382+
result[i].Collapse();
377383
}
378384

379385
public void CancelDelayedTreeViewTooltip()
@@ -600,6 +606,11 @@ public void Clear()
600606
treeViewSearchField = null;
601607
}
602608

609+
public void Collapse()
610+
{
611+
IsExpanded = false;
612+
}
613+
603614
// Initializes commonly used variables of the nodes
604615
public void InitializeNodes( HashSet<Object> objectsToSearchSet )
605616
{

0 commit comments

Comments
 (0)