コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }