示例#1
0
文件: ASUI.cs 项目: wjk17/AnimaSoul
        public static void Toggle(string labelStr, float width, BoolValueToggle value, UnityAction <bool> onToggle = null)
        {
            var toggle = Obj.Instantiate(I.togglePrefab, parent).GetComponent <Toggle>();

            toggle.isOn  = value.defaultValue;
            value.toggle = toggle;
            toggle.onValueChanged.AddListener(onToggle);
            var rt = toggle.GetComponent <RectTransform>();

            rt.sizeDelta = rt.sizeDelta.SetX(width);
            var label = toggle.GetComponentInChildren <Text>(true);

            label.text  = labelStr;
            label.color = labelColor;
            horizon.Add(toggle);
        }
示例#2
0
文件: ASUI.cs 项目: wjk17/AnimaSoul
 public static void Toggle(string labelStr, BoolValueToggle isOn, UnityAction <bool> onToggle = null)
 {
     Toggle(labelStr, I.togglePrefab.GetComponent <RectTransform>().rect.width, isOn, onToggle);
 }