Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Custom Graph Radio Buttons

Discussion in 'UGUI & TextMesh Pro' started by David42142, Sep 19, 2020.

  1. David42142


    Jul 15, 2015
    Hello I hope im in the proper forum,

    im creating a custom node system. When adding a node I use this code to add two checkboxes to the node:

    Code (CSharp):
    1. Node tempDialogueNode
    2. var button = new Toggle("1");
    3. var button2 = new Toggle("2");
    4. tempDialogueNode.extensionContainer.Add(button);
    5. tempDialogueNode.extensionContainer.Add(button2);
    However i would like these boxes to work like radio buttons, so only one can be checked at a time.
    Is there a system in place like the toggle group for ui?
  2. Hosnkobf


    Aug 23, 2016
    Is your
    in the namespace

    If yes, you are in the right forum.

    But you cannot create Toggles with a constructor. You should have compile errors. You rather create prefabs, instantiate them and get the Toggle component out of them.
    To make it radio buttons you need to have one "Toggle Group" component and assign that to all toggles.

    If no, you are in the wrong forum.