using System; using UnityEngine; public class ConfigSelectButton : MonoBehaviour { protected bool srcValue { get { return this.onGetValue != null && this.onGetValue(); } set { if (this.onSetValue != null) { this.onSetValue(value); } } } public void Initialize() { this.UpdateButton(); EventDelegate.Add(this.onButton.onClick, delegate() { this.srcValue = true; this.SetSelect(true); }); EventDelegate.Add(this.offButton.onClick, delegate() { this.srcValue = false; this.SetSelect(false); }); } public void UpdateButton() { this.SetSelect(this.srcValue); } private void SetSelect(bool isOn) { bool flag = false; if (isOn) { flag = true; } this.onButton.SetSelect(flag); this.offButton.SetSelect(!flag); } [SerializeField] private UIWFTabButton onButton; [SerializeField] private UIWFTabButton offButton; public Func onGetValue; public Action onSetValue; }