History/Assets/UIImageEventInteractions.cs
Станислав Хозяенок 06c62c1ad6 28.04.2025
2025-04-28 11:35:53 +07:00

46 lines
1.0 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using UnityEngine.Events;
public class UIImageAdvancedInteractions : MonoBehaviour,
IPointerEnterHandler,
IPointerExitHandler
{
[System.Serializable]
public class UIEvent : UnityEvent<PointerEventData> { }
[Header("Events")]
public UIEvent onPointerEnter;
public UIEvent onPointerExit;
public UIEvent onPointerClick;
private Image _image;
private void Awake()
{
_image = GetComponent<Image>();
}
public void OnPointerEnter(PointerEventData eventData)
{
onPointerEnter.Invoke(eventData);
Debug.Log("OnPointerEnter");
}
public void OnPointerExit(PointerEventData eventData)
{
onPointerExit.Invoke(eventData);
Debug.Log("OnPointerExit");
}
public void OnPointerClick(PointerEventData eventData)
{
onPointerClick.Invoke(eventData);
Debug.Log("OnPointerClick");
}
}