As it says I want to change image of all the toggle button back to default except for the active one , so i need a method which would get me all the non active toggles.
Thank you.
Make sure each toggle is attached to a child object of the toggle group object. That is, there should be one game object in your hierarchy with a ToggleGroup component, and the only Toggles in that ToggleGroup are attached to children of that game object.
From here, you can add a method to CustomScript that returns all inactive toggles
List<Toggle> InactiveToggles()
{
// get all toggles, active and inactive
List<Toggle> toggles = GetComponentsInChildren<Toggle>();
// find the active toggle and remove it
foreach(Toggle toggle in toggles)
{
if(toggle.isOn)
{
toggles.Remove(toggle);
return toggle; // only at most one toggle will be on
}
return toggles; // no toggles were on
}
Hope this helps!