[Solved] Manually set EditorStyles.radioButton selection state

Hi all,

I’m currently working on a custom editor. What I’m trying to accomplish is essentially a radio button togglegroup where, when a radio button is clicked, it should set an int property to it’s associated value. However, if the button already was selected, it should set the property to -1.

GUILayout.Toggle() works nicely, except it fires when it’s active, rather than when it’s clicked. A GUILayout.Button() with the radioButton style seems to be the way to go then, but I for the life of me can’t figure out how to get it to display in the active/ selected state. Any thoughts?

Thanks,
Patrick

And of course I find a solution right after posting. For future readers: I ended up creating a custom GUIStyle derived from the exiting radioButton one and swapping the normal and active states.

Cheers!

1 Like