File tree Expand file tree Collapse file tree 1 file changed +15
-2
lines changed
Expand file tree Collapse file tree 1 file changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -190,10 +190,23 @@ public override void OnGUI(Rect rect)
190190
191191 public override Vector2 GetWindowSize ( )
192192 {
193+ GUIContent tempLabelContent = new GUIContent ( ) ;
194+ float maxWidth = 0 ;
195+ foreach ( T item in _popup . GetChoices ( ) )
196+ {
197+ string label = item ? . GetHashCode ( ) == _popup . value ? . GetHashCode ( )
198+ ? _popup . formatSelectedValueCallback ? . Invoke ( item ) ?? item ? . ToString ( ) ?? string . Empty
199+ : _popup . formatListItemCallback ? . Invoke ( item ) ?? item ? . ToString ( ) ?? string . Empty ;
200+ tempLabelContent . text = label ;
201+ float width = EditorStyles . toolbarPopup . CalcSize ( tempLabelContent ) . x ;
202+ if ( width > maxWidth )
203+ maxWidth = width ;
204+ }
205+
193206 Vector2 size = new Vector2
194207 {
195- x = Mathf . Max ( 300 , _popup . GetVisualInput ( ) . resolvedStyle . width ) ,
196- y = Mathf . Min ( 400 , _list . elementHeight * _list . count + 36 ) ,
208+ x = Mathf . Max ( 300 , _popup . GetVisualInput ( ) . resolvedStyle . width , maxWidth ) ,
209+ y = Mathf . Min ( 400 , Mathf . Max ( _list . elementHeight * _list . count + 36 , 48 ) ) ,
197210 } ;
198211
199212 return size ;
You can’t perform that action at this time.
0 commit comments