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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to create a Toggle Group

Discussion in 'UGUI & TextMesh Pro' started by pKallv, Aug 24, 2014.

  1. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    I have not found this in the tutorials and in the manual it is not stated how to create, would someone nice point me somewhere or help?
     
    Last edited: Aug 24, 2014
    V5Studio, uc2018278118 and edolecki like this.
  2. PhilAllcock

    PhilAllcock

    Joined:
    Sep 3, 2013
    Posts:
    27
    You can attach a toggle group component onto a gameobject, and then create toggle game objects (Gameobject->UI->Toggle)
    To set it so only one of the toggle objects is active, drag the toggle group onto the group property on the toggle object itself
     
    uc2018278118, alicederyn and hongzhe like this.
  3. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    Where do i find the "Toggle Group" component?
     
  4. PhilAllcock

    PhilAllcock

    Joined:
    Sep 3, 2013
    Posts:
    27
    Select the gameobject you want as the holder/parent of the toggle objects, then in the inspector click on Add Component. Then select UI->ToggleGroup
     
  5. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    Uhhh i am afraid that i still do not get this to work as I try to do what you said but still cannot find the "ToggleGroup"?
     
  6. PhilAllcock

    PhilAllcock

    Joined:
    Sep 3, 2013
    Posts:
    27
    Strange. Does the toggle group appear in the Component->UI->Toggle group menu?
    Also in the Add Component menu in the inspector window, you can start typing toggle and it should appear
     
  7. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    It should be right after Toggle:


    I used a panel as the object to add the component to. You can probably use it on pretty much anything, but there might be some limitations, intentional or not by the developers.
     
  8. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    If i use Add Component on let say an Empty Game Object i only get new script, nothing else.
     
  9. PhilAllcock

    PhilAllcock

    Joined:
    Sep 3, 2013
    Posts:
    27
    Are you under a sub menu in that component menu? Like number 1 in my image? If so you can click the back arrow next to new script and that will return to the main options

    Or if you select the component drop down at number 2, you should get a load of components that you can add
     

    Attached Files:

  10. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    Adding a component to an empty GO gets me the same list as the panel, but sometimes you'll be deeper in the menu, like Phil described. You should stil be able to go back then.
     
  11. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    Ok when i click on the Add Component the only component available to add is script. In the project i have testing the new UI it looks like this:

    I also started a new project and tested and there i got a bit more to add:


    I think i had similar in pre 4.6 as well.
     
  12. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    I did type in a few word, including toggle and finally got a component menu. When i typed in "to" i got this, no toggle or toggle group:

     
  13. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    Hmm i reinstalled and started a new project and added a UI button and then add component, and there it is. Maybe i must start a new scene from scratch as the project i tested on is from previous releases of Unity?
     
  14. PhilAllcock

    PhilAllcock

    Joined:
    Sep 3, 2013
    Posts:
    27
    Did you manage to fix it in pre 4.6? I honestly have never seen this issue before. Perhaps a reinstall could fix it?
     
  15. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    I did reinstall.

    I did exactly the same as when i created a new project but instead of a new project i created a new scene but the UI does not show up in Add Component? Maybe this is a bug.

    Here is the add component menu when i create a new scene within my current project:
     
  16. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    You don't seem to be doing anything wrong. If you go to the Unity menu and click Modules…, do you see the GUI system as the sole module in the list?
     
  17. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    I also reinstalled the two toggle's and then the UI line on the menu suddenly showed up and i got the following in my add component menu UI:



    No toggle group but it seems that I am getting closer at least :)
     
    Last edited: Aug 24, 2014
  18. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    This is what i see:
     
  19. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,033
    Looks alright there. Better prepare a tiny repro project and submit a bugreport.
     
  20. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    i did submit bug report. Thanks for all help :)
     
  21. pKallv

    pKallv

    Joined:
    Mar 2, 2014
    Posts:
    1,132
    Update: problem solved in 4.6b18 :)
     
  22. steveg2357

    steveg2357

    Joined:
    Aug 21, 2014
    Posts:
    34
    I just installed Unity 4.6 RC2 and there is NO toggle group in GameObject->UI. How do I create a toggle group and the associated toggles?
     
  23. Caio_Lib

    Caio_Lib

    Joined:
    Mar 4, 2014
    Posts:
    83
    Toggle Group is a component. Try: Component -> UI -> Toggle Group.
     
  24. hongzhe

    hongzhe

    Joined:
    Aug 1, 2016
    Posts:
    1
    I use your method to create the toggle group.thank your very much
     
  25. UDN_e517836f-bdf7-43e6-8a85-e8c51ff7a035

    UDN_e517836f-bdf7-43e6-8a85-e8c51ff7a035

    Joined:
    Apr 12, 2017
    Posts:
    1
  26. VeerpalK

    VeerpalK

    Joined:
    Jul 4, 2018
    Posts:
    14
    Hi,
    here are the steps for the same
    1.Create Empty Game Object
    Capture.PNG
    2.Attach Toggle-group to it.
    3.Right Click Empty Game Object -->Ui-->Toggle likewise attach how many toggles you need.
    4.In each toggle's Group property drag and drop the Game Object .
    Capture.PNG
     
  27. Gilead7

    Gilead7

    Joined:
    Apr 2, 2009
    Posts:
    27
    What if you wanted a toggle group on a prefab. Only select one out a bunch of instantiated toggles?
     
  28. deverzs

    deverzs

    Joined:
    Apr 6, 2021
    Posts:
    9
    Has anyone figured out how to add ToggleGroup to prefabs?