You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.9 KiB
64 lines
1.9 KiB
4 years ago
|
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<InputField>().onValueChanged.AddListener(OnValueChanged);
|
||
|
GetComponent<InputField>().onEndEdit.AddListener(onEndEdit);
|
||
|
}
|
||
|
|
||
|
public virtual void OnDisable()
|
||
|
{
|
||
|
GetComponent<InputField>().onValueChanged.RemoveListener(OnValueChanged);
|
||
|
GetComponent<InputField>().onEndEdit.RemoveListener(onEndEdit);
|
||
|
}
|
||
|
|
||
|
public virtual void OnDestroy()
|
||
|
{
|
||
|
GetComponent<InputField>().onValueChanged.RemoveListener(OnValueChanged);
|
||
|
GetComponent<InputField>().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<InputField>().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;
|
||
|
}
|
||
|
}
|