How to set ToggleGroup of a Toggle in C#

Im trying to set a ToggleGroup of dynamically created toggles without success. I have a 3D object that has child object Toggle. I instantiate the object from prefab, but then I would need to set the toggles togglegroup.

I set the desired togglegroup to be used here from editor:

public ToggleGroup toggleGroup;

Then register the newly created toggle to it:

toggleGroup.RegisterToggle(buttonObject.GetComponentInChildren<Toggle>());

But It simply does nothing. No errors or no nothing. What am I doing wrong here? O.o

Thanks in advance :slight_smile:

Set the property “group” of your toggles. I’m not sure what RegisterToggle is meant for, but assigning “group” property of the toggles works as expected.