using System; using UnityEngine; using UnityEngine.UI; public class CommonToggle : BaseToggle { //字体颜色 private Color32 SelectedColor = new Color32(255, 255, 255, 255); private Color32 NormalColor = new Color32(140, 166, 255, 255); public bool UsedColor = true; public Text NameLable { get { return GetComponentInChildren(); } } public Toggle ToggleButton { get { return GetComponent(); } } public Action OnClicked; public override void RespondFun(bool value) { if (UsedColor) { if (value) { NameLable.color = SelectedColor; } else { NameLable.color = NormalColor; } } if (OnClicked != null) { OnClicked(this, value); } } public string LableText { get { return NameLable.text; } set { NameLable.text = value; } } public bool IsOn { get { return ToggleButton.isOn; } set { ToggleButton.isOn = value; } } }