Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Feedback Add option to UI Toggle to only change selected if user presses another button in that Toggle-Group

Discussion in 'UGUI & TextMesh Pro' started by HuldaGnodima, Nov 13, 2021.

Thread Status:
Not open for further replies.
  1. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    106
    Hi!

    The Toggle-feature in Unity's UI is very useful. At this moment however, there's no way to use Toggles as is and make sure the Toggle-buttons are only deselected when pressing another toggle-button within the same toggle-group.

    1. Any click outside will deselect: That means that if you have a toggle-group and press the screen anywhere outside the toggle it will deselect your original toggle-choice:
    See example here:



    2. Having multiple toggle-groups deselects: Additionally, if you have more than one Toggle-group (say nested or just next to each other), pressing the button in one Toggle group will deselect the toggle in the other group:
    See example here:


    I've understood that this is intended behaviour and not a bug. However, I have seen a lot of forum-posts that are looking for the setting to turn on "only deselect/change selected when pressing toggle within toggle-group" and not finding it. Here is one example (forum from 2017, still active today in 2021):
    https://forum.unity.com/threads/solved-clicking-anywhere-outside-a-toggle-deselects-it.473150/

    How people solve it right now: Currently it seems the best way to get this desired behaviour (only change selected toggle when pressing button within same toggle-group) is to write a new and custom toggle/button script from scratch. I myself am doing that right now (and some in the thread above are sharing their custom toggles to help others). However, this toggle-behaviour is so commonly sought after I wanted to make a formal feature request to possibly add it as an option.

    Feature request: Maybe the standard Toggle could contain a boolean-option, something like "Only change selected within group" or something similiar. I think that would help a lot of people who want to use Toggles. It would be awesome if the option to toggle the behaviour off/on existed in the future (to make the hurdle of using the Toggles smaller).

    Thanks so much in advance! Hope this makes sense : )

    (PS: Tried marking this post as a feature request but couldn't find the prefix)
     
  2. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,014
    You want to either create your own or extend the base component. Multiple selections is counter to expected behavior and accessibility best practices. It’s a fairly safe bet that unity won’t be modifying core/base components to break the built in functionality. It’s definitely an edge case need that falls under custom.

    Alternatively you might consider rethinking the design to use a more expected ux flow, or handle the indicators differently.
     
  3. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    10,055
    We found a solution in another thread (sadly it was deleted because it was posted in the UI Toolkit area).
    (If it's not a big favor to ask, is it possible to bring that back to life? The title was, I think, the same. It could show future readers the solution.)
     
    HuldaGnodima likes this.
  4. HuldaGnodima

    HuldaGnodima

    Joined:
    Oct 10, 2016
    Posts:
    106
    If possible could you reinstate the previous thread/or move it here instead : ) It contained the solution and already someone asked me about the thread/solution. Would love to be able to link it like Lurking-Ninja suggessted!
     
  5. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,014
    Merging it will be a mess. I am going to close this one, reopen the other and move it since there is no new content in this thread.
     
  6. zombiegorilla

    zombiegorilla

    Moderator

    Joined:
    May 8, 2012
    Posts:
    9,014
Thread Status:
Not open for further replies.