private void SetInfraredButtonsToRightState() { // sets the on/off toggle button to the right position. This checks if more than half of the infrared of the controller is on/off and then switches accordingly foreach (KeyValuePair <GameObject, InfraredController> button in buttonDictInfraredMenu) { ToggleController toggleController = button.Key.GetComponentInChildren <ToggleController>(); if (domoticaController.CheckifInfraredAreOn(button.Value)) { toggleController.SwitchButtonToOn(); } else { toggleController.SwitchButtonToOff(); } } }