Allow Toggle Group to Have No Active Toggle

A Toggle that belongs to a ToggleGroup should be able to be set to isOn = false via script. Right now, doing so has no effect, even though the field is public. The result would be that a ToggleGroup could have no active Toggle.

At the very least, it's inconsistent that a ToggleGroup will permit its Toggles to all be isOn == false at Start but not if one is enabled and then disabled again during runtime.

2 Likes

Yes, please! In desperate need of this right now!

What is a use case for this? A group should have one option selected as you are choosing between the options.

As someone who's had this request come up in more than a few web development projects myself, it's about forcing the user to consciously make a choice, rather than essentially skipping the field entirely and being able to click through with the default value of the radio button list selected.

2 Likes

Also, it allows one to use the Toggle behavior for groups of GUI elements. If I have options buttons for audio, graphics, and controls on the side of the screen during gameplay, I would conceivably only want one group of settings open at a time—or none open at all.

One can code this, but the Toggle behavior is right there.

1 Like

My situation is similar to Marble's. I'm using a Toggle Group for menus, and allowing one menu to be showing at a time. It works great except that forces one of the menus to be open no matter what. I would like it to be one menu visible or no menus visible.

Just thinking aloud. One possible work around would be to add an extra 'show nothing' toggle to the toggle group. You could even place this off screen if you wanted the effect to be managed via code.


That is definitely a solid workaround as of right now. One limitation of it however is that it still doesn't allow you to disable a toggle by pressing it.

I haven't actually had much cause to play with the toggle groups yet. Is it possible to tie into the OnClick event of the individual toggle, then select the 'show nothing' toggle from there?

We are starting to sound pretty hacky now...

I also have a need for this. My use case is that I have a menu system where you can select menu items to bring up windows populated with various UI elements. However the user should only be able to select one menu item at a time, or none at all (to free up screen space). So, much like the other uses listed here.

It's important to note that NGUI caters to this with an option on the checkbox item called 'State of none', where ticking it allows the group to have no toggle selected.

Whilst certainly not a deal breaker, it would be good to at least aim to achieve feature parity with the competition and this seems like a pretty easy one, that has been requested and discussed a fair few times already.

Thanks!

1 Like

I just think it's bad software ergonomics to have a set of radio buttons without one selected: In order for a UI to be considered "good", it should be intuitive and follow the conventions that users have come to expect. Checkboxes toggle, radio buttons select one at a time, and that's just how those UI elements work.

Users should not need to re-learn how to use standard UI components between programs, so you should not have this deviance: Have a "none" radio button the user can select.

1 Like

Toggle group != radio buttons

I have a toolbar for my game where the player can select a tower to construct. Only one tower can be active at a time, so I use a toggle group for it. But I would like to be able to have no tower selected too !

They are designed to have one thing selected at a time. That is exactly what radio buttons are. That is why they are called "radio buttons": They are like the buttons on a radio (which existed before computers did), where you press one and the others come back up. It makes no sense to have no radio station selected.

When a user looks at a UI element, they should easily and immediately know how to use it: A button performs an action, a checkbox is on and off, a radio/toggle set has one thing on at a time, a drop-down selects one thing at a time, a list lets you select one or more, a slider slides and has a range...all of these elements have commonly-agreed-upon conventions that make software easier to use.

It is bad design to change these conventions rather than working within them. Seriously: What "style" do you gain by having no selection rather than a "none" selection? Little; Versus the confusion users can face. Why do you need to have only one tower selected but sometimes no tower selected? That would confuse me as it makes no sense. RTS/towerdefense games have either "build mode" or they have you select a tower and then build it in immediate mode. I am assuming that, were I playing your game, you would always display the little thing that says whether or not you can build the current tower here, and that would not go away unless I somehow figured out that your radio buttons can be deselected?

And how does the user "turn off" the toggle group anyway? Do you have some sort of button that says "no tower"? So have that be the "none" selection instead, or have that be the build-mode toggle. If your idea was to click the selected tower again to un-select it, that's ridiculous and completely non-intuitive: They are not checkboxes. So many people would not even think to try that, because that is not how such controls work in any other normal application.

1 Like

There is definitely a use for having no selection. In my app, I have a quiz element that instantiates a prefab with some text for the question, and 3 toggles with a togglegroup for the possible answers. For each new question, I change the text in the instantiated prefab, but then I have to ungroup the toggles, set them all to off and regroup them. Being able to set the togglegroup to 'none' would be very handy for me.

2 Likes

@JAKJ While having the ability to deselect a toggle in the group by clicking on it may be counter-intuitive, I see nothing wrong (with few typical use cases listed in this thread) with having "default" state of a group with nothing selected (in fact we already have it and I remember it working that way in every major desktop UI framework I used). So just adding some method like "ClearSelection" to ToggleGroup wouldn't hurt at all.

And it's already half-way there. Right now a ToggleGroup can start with no active Toggle. It just can't be set to no active Toggle. It should at least be consistent.

Although I would like this feature.

http://en.m.wikipedia.org/wiki/Radio_button

[quote]
It is possible that initially none of the radio buttons in a group are selected. This state cannot be restored by interacting with the radio button widget (but it may be possible through other user interface elements).
[/quote]

Touché.

1 Like

I'm going to have to go and respectfully disagree with you on this.

There are many use cases where it might be preferable to toggle a group to 'off' - there's 6 examples just in this thread (including mine). It's not for you to say whether it's a good or bad design choice - it's about offering the choice to the user in the first place.

All the default UI actions you describe above can be achieved with the old GUI system. So why update it? Because of new features, ease of use, in the name of progress, and a whole bunch of other important stuff. How about Unity start breaking down the old 'commonly-agreed-upon conventions' to push the UI system in new and exciting ways? I can't really see how it could negatively affect you if the toggle group has a 'toggle to off' option - if you don't need the feature, don't use it. And the people that do need the feature, will use it and be happy.

I'll again point out that uGUI's biggest competitor has implemented this feature, so clearly people have requested it, and the author has respected those requests. If Unity wants to draw people away from NGUI, then they at least better have feature parity, if not more.

1 Like