Files
XRLib/Assets/Scripts/UVC/UI/Tooltip/TooltipHandler.cs

27 lines
876 B
C#
Raw Normal View History

using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
2025-06-16 19:30:01 +09:00
namespace UVC.UI.Tooltip
{
public class TooltipHandler : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
public System.Action<string, Vector3> OnPointerEnterAction; // 툴팁 내용(키), 마우스 위치
public System.Action OnPointerExitAction;
2025-06-16 19:30:01 +09:00
public string Tooltip { get; set; }
public void OnPointerEnter(PointerEventData eventData)
{
2025-06-16 19:30:01 +09:00
if (!string.IsNullOrEmpty(Tooltip) && gameObject.GetComponent<Selectable>()?.interactable == true) // 버튼이 활성화 상태일 때만
{
2025-06-16 19:30:01 +09:00
OnPointerEnterAction?.Invoke(Tooltip, Input.mousePosition);
}
}
public void OnPointerExit(PointerEventData eventData)
{
OnPointerExitAction?.Invoke();
}
}
}