Skip to content

Commit f68c8a1

Browse files
committed
Added AssetUsageDetectorWindow.BeginIndentedGUI and EndIndentedGUI functions to reduce duplicate OnGUI code
1 parent ecfb1ad commit f68c8a1

1 file changed

Lines changed: 23 additions & 19 deletions

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -508,15 +508,10 @@ private void OnGUI()
508508

509509
if( searchInAssetsFolder )
510510
{
511-
GUILayout.BeginHorizontal();
512-
GUILayout.Space( 35f );
513-
GUILayout.BeginVertical();
514-
511+
BeginIndentedGUI();
515512
searchInAssetsSubsetDrawer.Draw( searchInAssetsSubset );
516513
excludedAssetsDrawer.Draw( excludedAssets );
517-
518-
GUILayout.EndVertical();
519-
GUILayout.EndHorizontal();
514+
EndIndentedGUI();
520515
}
521516

522517
GUILayout.Space( 5f );
@@ -537,28 +532,20 @@ private void OnGUI()
537532

538533
if( searchInScenesInBuild )
539534
{
540-
GUILayout.BeginHorizontal();
541-
GUILayout.Space( 35f );
542-
535+
BeginIndentedGUI( false );
543536
searchInScenesInBuildTickedOnly = EditorGUILayout.ToggleLeft( "Ticked only", searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
544537
searchInScenesInBuildTickedOnly = !EditorGUILayout.ToggleLeft( "All", !searchInScenesInBuildTickedOnly, Utilities.GL_WIDTH_100 );
545-
546-
GUILayout.EndHorizontal();
538+
EndIndentedGUI( false );
547539
}
548540

549541
GUI.enabled = true;
550542

551543
searchInAllScenes = WordWrappingToggleLeft( "All scenes in the project", searchInAllScenes );
552544
}
553545

554-
GUILayout.BeginHorizontal();
555-
GUILayout.Space( 35f );
556-
GUILayout.BeginVertical();
557-
546+
BeginIndentedGUI();
558547
excludedScenesDrawer.Draw( excludedScenes );
559-
560-
GUILayout.EndVertical();
561-
GUILayout.EndHorizontal();
548+
EndIndentedGUI();
562549

563550
EditorGUI.BeginDisabledGroup( !searchInOpenScenes && !searchInScenesInBuild && !searchInAllScenes );
564551
searchInSceneLightingSettings = WordWrappingToggleLeft( "Scene Lighting Settings (WARNING: This may change the active scene during search)", searchInSceneLightingSettings );
@@ -672,6 +659,23 @@ private void DrawObjectsToSearchSection()
672659
objectsToSearchDrawer.Draw( objectsToSearch );
673660
}
674661

662+
private void BeginIndentedGUI( bool isVertical = true )
663+
{
664+
GUILayout.BeginHorizontal();
665+
GUILayout.Space( 35f );
666+
667+
if( isVertical )
668+
GUILayout.BeginVertical();
669+
}
670+
671+
private void EndIndentedGUI( bool isVertical = true )
672+
{
673+
if( isVertical )
674+
GUILayout.EndVertical();
675+
676+
GUILayout.EndHorizontal();
677+
}
678+
675679
public static bool WordWrappingToggleLeft( string label, bool value )
676680
{
677681
GUILayout.BeginHorizontal();

0 commit comments

Comments
 (0)