using AX.InputSystem; using UnityEngine; using UnityEngine.UI; using UnityEngine.EventSystems; using System; [RequireComponent(typeof(BaseGameObjInfo))] [RequireComponent(typeof(CreateStaticObjID))] public abstract class BaseInputField : MonoBehaviour,ISelectHandler { public virtual void OnEnable() { GetComponent().onValueChanged.AddListener(OnValueChanged); GetComponent().onEndEdit.AddListener(onEndEdit); } public virtual void OnDisable() { GetComponent().onValueChanged.RemoveListener(OnValueChanged); GetComponent().onEndEdit.RemoveListener(onEndEdit); } public virtual void OnDestroy() { GetComponent().onValueChanged.RemoveListener(OnValueChanged); GetComponent().onEndEdit.RemoveListener(onEndEdit); } public void OnValueChanged(string value) { var arg = new UIInputFieldArgs(); arg.msg = value; arg.currentCursorPos = Input.mousePosition; RegisterUIInputEvent.RegisterUIInputHistory(gameObject, this.GetType().Name, "ValueChanged", arg); //ValueChanged(arg); RespondFun(value); //InputManager.OccupyKeyboard = true; } public void ValueChanged(CmdArgs arg) { if (GameSettings.othersSettings.isReplayMode) { if (!GameSettings.othersSettings.isReplayPause && !GameSettings.othersSettings.isReplayOver) { CursorManager.GetInstance.SetClick(arg); } } GetComponent().text = ((UIInputFieldArgs)arg).msg; } public void onEndEdit(string value) { InputManager.OccupyKeyboard = false; } public abstract void RespondFun(string value); public void OnSelect(BaseEventData eventData) { InputManager.OccupyKeyboard = true; } }