I solved this problem by using buttonbuttons instead of toggles.
First define two button styles before any functions:
private static GUIStyle ToggleButtonStyleNormal = null;
private static GUIStyle ToggleButtonStyleToggled = null;
Then in OnInspectorGui()OnInspectorGui() make sure they are generated if null:
if ( ToggleButtonStyleNormal == null )
{
ToggleButtonStyleNormal = "Button";
ToggleButtonStyleToggled = new GUIStyle(ToggleButtonStyleNormal);
ToggleButtonStyleToggled.normal.background = ToggleButtonStyleToggled.active.background;
}
And then use the idea proposed by @jzx to toggle the styles:
GUILayout.BeginHorizontal( );
if ( GUILayout.Button( SetAmountFieldContent, _setValue ? ToggleButtonStyleToggled : ToggleButtonStyleNormal ) )
{
_setValue = true;
_smoothValue = false;
}
if ( GUILayout.Button( SmoothValueFieldContent, _smoothValue ? ToggleButtonStyleToggled : ToggleButtonStyleNormal ) )
{
_smoothValue = true;
_setValue = false;
}
GUILayout.EndHorizontal();
This produces what I wanted:
