using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
namespace EnglewoodLAB.UI
{
///
/// 클릭, 호버, 포인터 종료와 같은 포인터 이벤트에 대한 응답으로 대상 구성 요소의 색상 변경을 처리합니다.
/// 이 동작은 연결된 의 상호 작용 가능 상태를 고려합니다.
///
public class CustomImageColorChangeBehaviour : MonoBehaviour, IPointerDownHandler, IPointerUpHandler,
IPointerEnterHandler, IPointerExitHandler
{
public Color originalColor = Color.white; // 기본 컬러
public Color hoverColor = Color.gray; // 마우스 오버 시 컬러
public Color clickColor = Color.gray; // 클릭 시 컬러
public Color disabledColor = Color.gray; // 비활성화 시 컬러
[SerializeField]
private Image[] targetImages; // 컬러를 변경할 이미지 컴포넌트
[SerializeField]
private TextMeshProUGUI[] targetTexts; // 컬러를 변경할 텍스트 컴포넌트
[SerializeField]
private Selectable button; // 버튼 컴포넌트
private bool _isSelected = false;
private void Awake()
{
if (targetImages == null || targetImages.Length == 0)
{
var img = GetComponent();
if(img != null) targetImages = new Image[] { img };
}
if (targetTexts == null || targetTexts.Length == 0)
{
var txt = GetComponentInChildren();
if(txt != null) targetTexts = new TextMeshProUGUI[] { txt };
}
if (button == null)
{
button = GetComponent