Resetting Toggles

I have a group of Toggles in my game menu. I would like it to reset to have the first toggle selected whenever the menu opens.

When I was doing this in my first “proof of concept”, all I had to do was set toggle1 to isOn=true. However, in my new code, when I do that, it sets toggle1 to on, but it also leaves the last selected toggle on, and I can’t figure out why.

They are both members of the same toggle group, and “allow switch off” is false. The only difference is that, in my first code, toggle1 had the toggle group component. In this code, I have the toggle group set to the panel that contains them all.

Is this meant to act this way? Am I doing something wrong? Am I missing something? Thanks!

I did it this way:

toggle.GetComponent().isOn = false;

If the toggle is in a togglegroup, in the togglegroup component activate Allow to Swith Off option.

2 Likes

I appreciate that… but I posted this 3 years ago.

rofl