12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- 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<bool> onGetValue;
- public Action<bool> onSetValue;
- }
|