45 lines
1.5 KiB
C#
45 lines
1.5 KiB
C#
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class InitializePopupCellButton : MonoBehaviour
|
|
{
|
|
[SerializeField] private Button button;
|
|
[SerializeField] private Image background;
|
|
[SerializeField] private TMP_Text text; // 필요 없으면 제거
|
|
|
|
public int X { get; private set; }
|
|
public int Y { get; private set; }
|
|
public int Z { get; private set; }
|
|
|
|
public void Setup(int x, int y, int z, System.Action<InitializePopupCellButton> onDown, System.Action<InitializePopupCellButton> onEnter, System.Action onUp)
|
|
{
|
|
X = x; Y = y; Z = z;
|
|
|
|
// 버튼 이벤트(단순화): Pointer 이벤트가 더 정확하지만, 여기서는 구성 예시로 단순화
|
|
button.onClick.RemoveAllListeners();
|
|
button.onClick.AddListener(() => onDown?.Invoke(this)); // 클릭 시작으로 취급
|
|
|
|
// 드래그/호버는 EventTrigger 또는 IPointerEnterHandler로 확장 권장
|
|
// 여기서는 창 코드에서 추가로 연결할 수 있게 메서드를 남겨둡니다.
|
|
}
|
|
|
|
public void SetEmpty()
|
|
{
|
|
// background.color = ...
|
|
if (text) text.text = "";
|
|
}
|
|
|
|
public void SetOccupied(string prefab)
|
|
{
|
|
// background.color = ...
|
|
if (text) text.text = "■"; // 아이콘/이미지로 바꾸셔도 됨
|
|
}
|
|
|
|
public void SetHighlight(bool on)
|
|
{
|
|
// 하이라이트 색/아웃라인 처리
|
|
// 예: background.color = on ? highlightColor : normalColor;
|
|
}
|
|
}
|