71 lines
2.1 KiB
C#
71 lines
2.1 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Events;
|
|||
|
|
using UnityEngine.EventSystems;
|
|||
|
|
using UnityEngine.UI;
|
|||
|
|
|
|||
|
|
public class UITeleportItem : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
public InputField txtPos; //<2F><><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
public InputField txtNextMapID; //<2F>¼<EFBFBD><C2BC><EFBFBD>ͼID
|
|||
|
|
public InputField txtNextMapPos; //<2F>¼<EFBFBD><C2BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
|||
|
|
public Button btnDel; //ɾ<><C9BE>
|
|||
|
|
public int itemIdx;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
AddInputNameClickEvent(txtPos);
|
|||
|
|
//AddInputNameClickEvent(txtNextMapPos);
|
|||
|
|
btnDel.onClick.AddListener(RemoveSelf);
|
|||
|
|
itemIdx = 0;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void AddInputNameClickEvent(InputField input) //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Awake<6B>е<EFBFBD><D0B5><EFBFBD>
|
|||
|
|
{
|
|||
|
|
var eventTrigger = input.gameObject.AddComponent<EventTrigger>();
|
|||
|
|
UnityAction<BaseEventData> selectEvent = OnInputFieldClicked;
|
|||
|
|
EventTrigger.Entry onClick = new EventTrigger.Entry()
|
|||
|
|
{
|
|||
|
|
eventID = EventTriggerType.PointerClick
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
onClick.callback.AddListener(selectEvent);
|
|||
|
|
eventTrigger.triggers.Add(onClick);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnInputFieldClicked(BaseEventData data)
|
|||
|
|
{
|
|||
|
|
UIWindow.Instance.uiTeleportPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
|||
|
|
MapManager.Instance.SetCurTeleportPointIdx(itemIdx);
|
|||
|
|
MapManager.Instance.SetEditCellType(MapManager.EditCellType.TeleportCell);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void RemoveSelf()
|
|||
|
|
{
|
|||
|
|
DestroyImmediate(gameObject);
|
|||
|
|
MapManager.Instance.RemoveTeleportPointSize(itemIdx);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public bool CheckValid()
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(txtPos.text))
|
|||
|
|
{
|
|||
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(txtNextMapID.text))
|
|||
|
|
{
|
|||
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ͼID");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(txtNextMapPos.text))
|
|||
|
|
{
|
|||
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>");
|
|||
|
|
return false;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
}
|
|||
|
|
}
|