Horizontal Scrollbar shows up when Vertical Scrollbar appears


Im currently working on a project where I need to do an extensive remake on some classes, so Im using CustomEditors in order to give the best interface possible to my scripts. So far this is doing good but one thing is really annoying me. Everytime I have a script thats needs vertical scrolling, then a horizontal scrollbar will also pop up! It seems to me that since the vertical scrollbar takes some space to be drawn, then the editor adds a horizontal bar to make up for the lost space. I find this behaviour to be errouneous, as Id expect the interface to shrink a bit in order for the vertical scrollbar to fit in, which does not happen.

How can I fix this?

In my interface, most fields are composed by a EditorGUILayout.PropertyField with a Name, a Tooltip and a LabelField on the same horizontal space, as seen on the Max Effort field on the following picture


But as soon as I open up the two other foldouts, which makes the GO inspector be vertically bigger than the screen, this happens:


This is the code that I use to draw most variables on the editor:

EditorGUILayout.BeginHorizontal (GUILayout.ExpandWidth(false));
EditorGUILayout.PropertyField ( field.getProperty(), 
								new GUIContent ( field.getName(), field.getTooltip() ), 
								true );
EditorGUILayout.LabelField( field.getUnit() );
EditorGUILayout.EndHorizontal ();

How can I fix this? Thanks!

I also had this problem, but found that using GUILayout rather than EditorGUILayout fixed it.

I’m just guessing that you’re using EditorGUILayout.BeginScrollView(…) ?

Does it fail with forcing alwaysShowHorizontal to false?

You can mix in either GUI.VerticalScrollbar or GUILayout.VerticalScrollbar, but you’ll need to calculate and translate stuff on your own.

… if I recall, EditorGUILayout scrollviews are… pretty buggy.