using AX.InputSystem; using UnityEngine; using UnityEngine.UI; [RequireComponent(typeof(BaseGameObjInfo))] [RequireComponent(typeof(CreateStaticObjID))] [RequireComponent(typeof(Toggle))] public abstract class BaseToggle : MonoBehaviour { public virtual void OnEnable() { GetComponent().onValueChanged.AddListener(OnValueChanged); } public virtual void OnDisable() { GetComponent().onValueChanged.RemoveListener( OnValueChanged); } public virtual void OnDestroy() { GetComponent().onValueChanged.RemoveListener(OnValueChanged); } public void OnValueChanged(bool value) { var arg = new UIToggleArgs(); arg.isOn = value; arg.currentCursorPos = Input.mousePosition; RegisterUIInputEvent.RegisterUIInputHistory(gameObject, this.GetType().Name, "ValueChanged", arg); RespondFun(value); } public void ValueChanged(CmdArgs arg) { if (GameSettings.othersSettings.isReplayMode) { if (!GameSettings.othersSettings.isReplayPause && !GameSettings.othersSettings.isReplayOver) { CursorManager.GetInstance.SetClick(arg); } } GetComponent().isOn = ((UIToggleArgs)arg).isOn; } public abstract void RespondFun(bool value); }