P D
P D

Reputation: 45

Toggle Buttons not getting passed in Toggle Group(Unity)

I am stuck in an issue which is little bit confusing. I am using toggle button under an empty game object consisting toggle group script. When I am placing this group under a panel in Canvas, the programming is running properly, but when I create a full form style type panels and groups, the toggle group shows that there is no toggle under toggle group. I have checked for all the assigning and sample running part but the issue still persists. Maybe I am doing some silly mistakes, but I am not sure what is it.

For getting the active toggle, I have watched this youtube link and coded like this

    ToggleGroup toggleGroup;

    private void Start()
    {
        toggleGroup = GetComponent<ToggleGroup>();
    }

    string val;
    Toggle toggle;
    public string ToggleData()
    {
        toggle = toggleGroup.ActiveToggles().FirstOrDefault();

        if (toggle == null)
            val = "No";
        else if (toggle != null)
            val = toggle.GetComponentInChildren<Text>().text;
        return val;
    }

I have added an image of the hierarchy This is hierarchy image

[This is the toggle component's inspector image1

Upvotes: 1

Views: 441

Answers (1)

P D
P D

Reputation: 45

I have reassigned the ToggleGroup in each Toggle UI, then it started to work.

Upvotes: 1

Related Questions