Active toggle in ToggleGroup

Hi Guys,

Is there any way (currently implemented or planned/to be implemented) which will allow code to grab the active toggle(s) from a toggle group without having to loop through a ToggleGroup’s children? We already have the ability to check if there are any active toggles from the toggle group, but it would be a lot nicer if we could grab the active toggle(s)

Thanks

API oversight. I have added this locally now.

1 Like

Thanks :slight_smile:

If you have a ToggleGroup where only one Toggle must be selected, in my case a language selector, how do you make the ToggleGroup remember which Toggle was the one previously selected, after leaving and returning to the scene?

Thanks

Are you using PlayerPrefs?
And calling Save()? https://docs.unity3d.com/ScriptReference/PlayerPrefs.Save.html

No, I have not tried Save()

Will report later and thanks a lot!

I asked around and got terrific answers, all of which pointed to persistent data, like you also mentioned.

But I realized I was using SystemLanguage so I could get the language users had selected and update Toggles accordingly.

Thanks a lot

void SetActiveToggle () {
        switch (LanguageController.GetLanguage())
        {
            case SystemLanguage.English:
                _aryOfToggles[0].isOn = true;
                break;
            case SystemLanguage.Unknown:
                _aryOfToggles[1].isOn = true;
                break;
            case SystemLanguage.French:
                _aryOfToggles[2].isOn = true;
                break;
            case SystemLanguage.Spanish:
                _aryOfToggles[3].isOn = true;
                break;
            case SystemLanguage.German:
                _aryOfToggles[4].isOn = true;
                break;
            default:
                break;
        }
    }
1 Like