private void Start() { foreach (var item in TrainingManager.Circuits) { var widget = GameObject.Instantiate(ToggleButtonPrefab, CircuitsPanel.transform); widget.GetComponentInChildren <Text>().text = item; widget.GetComponentInChildren <TrainingEntityListItem>().item = item; widget.GetComponentInChildren <Toggle>().onValueChanged.AddListener(Refresh); } foreach (var item in TrainingManager.Cars) { var widget = GameObject.Instantiate(ToggleButtonPrefab, CarsPanel.transform); widget.GetComponentInChildren <Text>().text = item; widget.GetComponentInChildren <TrainingEntityListItem>().item = item; widget.GetComponentInChildren <Toggle>().onValueChanged.AddListener(Refresh); } foreach (var item in GetComponentsInChildren <AgentToggle>()) { item.GetComponent <Toggle>().onValueChanged.AddListener(Refresh); } Refresh(false); TrainProfileHereButton.onClick.AddListener(() => TrainingManager.AddTrainingRequests(circuits, cars, agents)); }