@@ -20,13 +20,21 @@ public enum DropdownMenuSearch
2020 Always
2121 }
2222
23+ public enum DropdownMenuLayout
24+ {
25+ Short ,
26+ Medium ,
27+ Long
28+ }
29+
2330 public class DropdownMenuDescriptor
2431 {
2532 public bool allowSubmenus { get ; set ; } = true ;
2633 public bool autoClose { get ; set ; } = true ;
2734 public bool expansion { get ; set ; } = true ;
2835 public bool parseShortcuts { get ; set ; } = true ;
2936 public DropdownMenuSearch search { get ; set ; } = DropdownMenuSearch . Auto ;
37+ public DropdownMenuLayout layout { get ; set ; } = DropdownMenuLayout . Long ;
3038 public string title { get ; set ; } = null ;
3139 }
3240
@@ -49,7 +57,7 @@ public static class EditorMenuExtensions
4957 internal static readonly string searchCategoryUssClassName = GenericDropdownMenu . ussClassName + "__search-category" ;
5058 internal static readonly string shortcutUssClassName = GenericDropdownMenu . ussClassName + "__shortcut" ;
5159
52- static float maxMenuHeight => Screen . currentResolution . height / ( Screen . dpi / 96.0f ) * 0.75f ;
60+ static float maxMenuHeight => Screen . currentResolution . height / ( Screen . dpi / 96.0f ) ;
5361
5462 internal static bool isEditorContextMenuActive => s_ActiveMenus . Count > 0 ;
5563
@@ -102,7 +110,6 @@ void Host(GenericDropdownMenu menu)
102110 menu . customFocusHandling = true ;
103111
104112 menu . innerContainer . style . maxWidth = k_MaxMenuWidth ;
105- menu . outerContainer . style . maxHeight = maxMenuHeight ;
106113 menu . outerContainer . RegisterCallback < GeometryChangedEvent > ( e =>
107114 {
108115 maxSize = minSize = menu . outerContainer . worldBound . size ;
@@ -465,7 +472,7 @@ void ResetHighlighting(GenericDropdownMenu.MenuItem root)
465472 var menu = search . userData as GenericDropdownMenu ;
466473 var newValue = Regex . Replace ( e . newValue , "[^\\ w ]+" , "" ) ;
467474 search . SetValueWithoutNotify ( newValue ) ;
468-
475+
469476 ResetHighlighting ( menu . root ) ;
470477
471478 if ( string . IsNullOrWhiteSpace ( menu . current . name ) )
@@ -810,6 +817,23 @@ internal static void ApplyDescriptor(this GenericDropdownMenu menu, DropdownMenu
810817 if ( desc . expansion )
811818 menu . MakeExpandable ( ) ;
812819
820+
821+ var factor = 0f ;
822+ switch ( desc . layout )
823+ {
824+ case DropdownMenuLayout . Short :
825+ factor = 0.25f ;
826+ break ;
827+ case DropdownMenuLayout . Medium :
828+ factor = 0.5f ;
829+ break ;
830+ case DropdownMenuLayout . Long :
831+ default :
832+ factor = 0.75f ;
833+ break ;
834+ }
835+ menu . outerContainer . style . maxHeight = maxMenuHeight * factor ;
836+
813837 menu . root . name = desc . title ;
814838 menu . allowBackButton = ! desc . expansion ;
815839 menu . autoClose = desc . autoClose ;
0 commit comments