- Home /
Horizontal Scrollbar shows up when Vertical Scrollbar appears
Hello!
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!
Answer by frogtamer · May 19, 2015 at 02:31 PM
I also had this problem, but found that using GUILayout rather than EditorGUILayout fixed it.
Answer by tswalk · Mar 26, 2015 at 09:26 PM
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.
To be honest Im not really using BeginScrollView. The scrolls shows up relative to the whole inspector, not just for a single component. Im uploading a picture taken from the full Inspector interface, which for this sample have two components, but it can be more. So im not using any kind of scroll control right now, ill try the alwaysShowHorizontal in a $$anonymous$$ute and will reply back here
][1]
Your answer
Follow this Question
Related Questions
Editor Targets are updated but SerializedPropertys arent 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Invalid iteration - (You need to stop calling Next when it returns false) 2 Answers
Creating a custom inspector utilizing a list of class instances with serialization? 1 Answer