#Ui hover
1 messages · Page 1 of 1 (latest)
public class UIElement : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler
{
private bool mouse_over = false;
void Update()
{
if (mouse_over)
{
Debug.Log("Mouse Over");
}
}
public void OnPointerEnter(PointerEventData eventData)
{
mouse_over = true;
Debug.Log("Mouse enter");
}
public void OnPointerExit(PointerEventData eventData)
{
mouse_over = false;
Debug.Log("Mouse exit");
}
}
Yup! Just attach it to a button, and it'll trigger the Mouse Over. You can use this for any UI element, text, text mesh pro, buttons, sliders, anything