Accessing the Active property in Toggle via c# script

I have problems with Toggle Groups, which is reported as a bug (How to create a Toggle Group - Unity Engine - Unity Discussions) that Unity is looking at.

However, I am trying to attach a script to my two toggles to make sure that only one of the toggles can be active at one time. My problem is how to i access the Active property on the Toggles via script. Anyone that can share some light on this as I cannot find this in the maul, or i look at the wrong place.

use the property isOn:

GameObject.Find(“toggleX”).GetComponent().isOn = true;

Edit: ToggleGroups work fine for me:

  1. Create your toggles
  2. Add the Component ToggleGroup to one of the Toggles
  3. Choose this ToggleGroup as “Group” Property in the Inspector of each Toggle

I have problem with Toggle Group, see link above, so for the time being I have to do it via script.

Your help worked so thanks :slight_smile:

Hi, please check this tut it might help you.