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. Dismiss Notice

Toggle Group Question

Discussion in 'UGUI & TextMesh Pro' started by Pharadox, Aug 31, 2014.

  1. Pharadox

    Pharadox

    Joined:
    Aug 31, 2014
    Posts:
    1
    Is there a way to turn off currently selected Toggle in a Toggle Group?

    For example lets say there is a quiz with ABC answer but there is only one OR none right answer. If user already selected lets say 'B' but realized this choice is not right he wants to deselect it.

    Would greatly appreciate the answer.
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Best way so far is to add another toggle as none. It's been asked by a few people and I haven't sen a better answer yet.
     
  3. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    Might be possible to make the "none" toggle invisible, and check its state before allowing the user to proceed.
     
  4. Deleted User

    Deleted User

    Guest

  5. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
  6. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    What's wrong with making a "none" box that is invisible and doesn't block raycasts?
     
  7. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Ah, so your saying that in code you secretly set isOn = true on that invisible toggle? That does sound like a good idea.
     
  8. JAKJ

    JAKJ

    Joined:
    Aug 17, 2014
    Posts:
    185
    Well, yes...as was already described in the first two reply posts in this thread.
     
  9. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I didn't get the part of making it non-clickable, and setting isOn = true through code...
     
  10. outgoingnxt

    outgoingnxt

    Joined:
    Aug 31, 2014
    Posts:
    5
    The same problem was NGUI, but there it was decided me add one variable in the code and change a single line. Then the developer has made my edits with his correction :). Strange that it is impossible to make a new GUI.
     
  11. Rodolfo-Rubens

    Rodolfo-Rubens

    Joined:
    Nov 17, 2012
    Posts:
    1,196
    What I did was set all the "group" variables of the toggles to null, then set all the isOn to false, then assign the "group" vars back to your ToggleGroup, for some reason, if no toggle was selected yet then you can have all you toggles set to false...