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

27 lines
885 B
C#
Raw Normal View History

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