How to Display "Left/Right" text under a Slider in EditorWindow?

Example

I have been working on a tool and am looking to make my sliders show more information. I am wanting to replicate the “Left/Right” and “2D/3D” that AudioSource uses in the Component. If anyone has suggestions that would be appreciated!

You’d have to calculate the Rect’s manually.

If you are using GUILayout you can get the last used rect through GUILayoutUtility.GetLastRect(). So you can call that method after drawing the Slider, and then split that rect & adjust it for each label.

And for the styled labels is probably using a pre-defined mini-label GUIStyle, you can get those from EditorStyles.miniLabel / EditorStyles.whiteMiniLabel / EditorStyles.miniBoldLabel and use them in a normal label through GUI.Label(myRect, "left", EditorStyles.miniLabel);

image
That got it to work. Thank you so much!

2 Likes