How to align a toggle box to the right of a custom editor window?

Hi, I’m writing a custom editor window at the moment, and I’m using BeginHorizontal() and EndHorizontal() to put an EditorGUILayout.Foldout() next to an EditorGUILayout.Toggle box. Unfortuantely, when I have these two options following, the toggle box is aligned to the middle of the editor window, even when resizing the window. Is there a way to get the toggle box aligned to the right of the editor window?

I’ve tried using a custom GUIStyle, which changes the text alignment, as well as the amount of right padding, hoping that might work, but no avail, it simply makes the toggle box disappear completely.


before toggle inside horizontal block

ScroodgeM’s solution worked for me, the aligned image is with GUILayout.FlexibleSpace(); and unaligned image is without it

No No No, read my answer on How to clamp EditorGUILayout controls' width ? - Unity Answers on “HOW TO ADJUST THE SIZE OF YOUR BEGINHORIZONTAL/VERTICAL”…it should answer it all.