Files
HX_MapEditor/Assets/Scripts/UnUse/UISafeAreaItem.cs

70 lines
1.9 KiB
C#
Raw Permalink Normal View History

2025-06-14 13:46:24 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;
using UnityEngine.UI;
public class UISafeAreaItem : MonoBehaviour
{
public InputField txtPos; //<2F><><EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>
public InputField txtRadius; //<2F>
public Button btnDel; //ɾ<><C9BE>
public int itemIdx;
// Start is called before the first frame update
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.uiSafeAreasPanel.curActiveInput = data.selectedObject.GetComponent<InputField>();
//MapManager.Instance.SetCurSafeCenterPoint(itemIdx, Convert.ToInt32(txtRadius.text));
//MapManager.Instance.SetEditCellType(MapManager.EditCellType.SafeArea);
}
private void RemoveSelf()
{
DestroyImmediate(gameObject);
//MapManager.Instance.RemoveSafeCenterPoint(itemIdx);
}
public bool CheckValid()
{
if (string.IsNullOrEmpty(txtPos.text))
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return false;
}
if (string.IsNullOrEmpty(txtRadius.text))
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ȫ<EFBFBD><C8AB><EFBFBD>뾶");
return false;
}
return true;
}
}