Since I haven’t found anything on this forum or in docs, here’s a thread for other developers fighting this awkward component.
No matter if you have some toggles set to isOn
on scene or switched them on from code:
ActiveToggles()
will be empty if called fromOnEnable()
, same forAnyTogglesOn()
SetAllTogglesOff()
is not working fromOnEnable()
It looks like every Toggle registers and unregisters from its group on every enable/disable. That’s why there’s no obvious method like AllToggles()
but only ActiveToggles()
.
So if you need to call these methods inside OnEnable()
then use StartCoroutine()
and call them after yield return new WaitForEndOfFrame();
Now the worst part: if you’d like to dynamically set one of your toggles on then you need to keep a separate list of references to your Toggle
components.