Skip to content

Commit ecfb1ad

Browse files
committed
Added Utilities.DrawHeader function to reduce duplicate OnGUI code
1 parent e63ebd7 commit ecfb1ad

2 files changed

Lines changed: 12 additions & 11 deletions

File tree

Plugins/AssetUsageDetector/Editor/AssetUsageDetectorWindow.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,7 @@ private void OnGUI()
502502

503503
GUILayout.Space( 10f );
504504

505-
Color c = GUI.backgroundColor;
506-
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
507-
GUILayout.Box( "<b>SEARCH IN</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
508-
GUI.backgroundColor = c;
505+
Utilities.DrawHeader( "<b>SEARCH IN</b>" );
509506

510507
searchInAssetsFolder = WordWrappingToggleLeft( "Project window (Assets folder)", searchInAssetsFolder );
511508

@@ -573,9 +570,7 @@ private void OnGUI()
573570

574571
GUILayout.Space( 10f );
575572

576-
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
577-
GUILayout.Box( "<b>SETTINGS</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
578-
GUI.backgroundColor = c;
573+
Utilities.DrawHeader( "<b>SETTINGS</b>" );
579574

580575
#if ASSET_USAGE_ADDRESSABLES
581576
EditorGUI.BeginDisabledGroup( addressablesSupport );
@@ -664,10 +659,7 @@ private void OnGUI()
664659

665660
private void DrawObjectsToSearchSection()
666661
{
667-
Color c = GUI.backgroundColor;
668-
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
669-
GUILayout.Box( "<b>SEARCHED OBJECTS</b>", Utilities.BoxGUIStyle, Utilities.GL_EXPAND_WIDTH );
670-
GUI.backgroundColor = c;
662+
Utilities.DrawHeader( "<b>SEARCHED OBJECTS</b>" );
671663

672664
Rect searchedObjectsHeaderRect = GUILayoutUtility.GetLastRect();
673665
searchedObjectsHeaderRect.x += 5f;

Plugins/AssetUsageDetector/Editor/Utilities.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,15 @@ public static string GetFileExtension( string path )
446446
return stringBuilder.ToString();
447447
}
448448

449+
// Draw header inside OnGUI
450+
public static void DrawHeader( string label )
451+
{
452+
Color c = GUI.backgroundColor;
453+
GUI.backgroundColor = AssetUsageDetectorSettings.SettingsHeaderColor;
454+
GUILayout.Box( label, BoxGUIStyle, GL_EXPAND_WIDTH );
455+
GUI.backgroundColor = c;
456+
}
457+
449458
// Draw horizontal line inside OnGUI
450459
public static void DrawSeparatorLine()
451460
{

0 commit comments

Comments
 (0)