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); }
public static void Toggle(string labelStr, BoolValueToggle isOn, UnityAction <bool> onToggle = null) { Toggle(labelStr, I.togglePrefab.GetComponent <RectTransform>().rect.width, isOn, onToggle); }