public Toggle CreateRadio(RadioData radioData) { var radio = Instantiate(this.radioPrefab, this.canvas.transform, false); radio.GetComponentInChildren <Text>().text = radioData.text; radio.isOn = radioData.isOn; if (radioData.onValueChanged != null) { radio.onValueChanged.AddListener(radioData.onValueChanged); } return(radio); }
public Toggle AddRadio(RadioData radioData) { var radio = UserInterface.Instance.CreateRadio(radioData); radio.transform.SetParent(this.elements); var group = this.elements.GetComponent <ToggleGroup>(); if (group == null) { radio.group = this.elements.gameObject.AddComponent <ToggleGroup>(); } else { radio.group = group; } return(radio); }