I want to create a tool similar to Unity's Terrain tool, which has some nice toggle buttons in the inspector:
How can I achieve similar design to this? I know how to create normal buttons and other UI components in the inspector, but I can not find enough information to make the buttons toggle.
So far I have used normal toggles that produce a checkbox:
var tmp = EditorGUILayout.Toggle( SetAmountFieldContent, _setValue );
if ( tmp != _setValue )
{
_setValue = tmp;
if ( _setValue )
_smoothValue = false;
}
tmp = EditorGUILayout.Toggle( SmoothValueFieldContent, _smoothValue );
if ( tmp != _smoothValue )
{
_smoothValue = tmp;
if ( _smoothValue )
_setValue = false;
}
Setting the toggle GUIStyle
to "Button" does not produce the wanted result. The text or image content goes on left of the button instead of inside.
var tmp = EditorGUILayout.Toggle( SetAmountFieldContent, _setValue, "Button" );
Also none of the options found in GUISkin does not seem to help.
_smoothValue = !GUILayout.Button( SetAmountFieldContent, _smoothValue ? ToggleButtonStyleToggled : ToggleButtonStyleNormal)
, instead of having two booleans? That works well for me and the code looks close to using stadnard unity button/toggles – Ivaylo Slavov Oct 16 '17 at 19:31