第一次提交
This commit is contained in:
75
Assets/Scripts/UI/UITriggerItem.cs
Normal file
75
Assets/Scripts/UI/UITriggerItem.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using HxGame.Data;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UITriggerItem : MonoBehaviour
|
||||
{
|
||||
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
|
||||
public InputField txtRadius; //<2F>뾶
|
||||
public Dropdown dropMode; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
||||
public InputField txtEvent; //<2F><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
||||
public Button btnDel; //ɾ<><C9BE>
|
||||
public int itemIdx;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
AddInputNameClickEvent(txtPos);
|
||||
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)
|
||||
{
|
||||
if (string.IsNullOrEmpty(txtRadius.text))
|
||||
return;
|
||||
|
||||
UIWindow.Instance.uiTriggersPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
|
||||
MapManager.Instance.SetCurTriggerCenterPoint(itemIdx, Convert.ToInt32(txtRadius.text), (TriggerMode)dropMode.value);
|
||||
MapManager.Instance.SetEditCellType(MapManager.EditCellType.TriggerCell);
|
||||
}
|
||||
|
||||
private void RemoveSelf()
|
||||
{
|
||||
DestroyImmediate(gameObject);
|
||||
MapManager.Instance.RemoveTriggerCenterPoint(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(txtRadius.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD>뾶");
|
||||
return false;
|
||||
}
|
||||
if (string.IsNullOrEmpty(txtEvent.text))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user