- Home /
Get button under mouse
I'm trying to get the button the mouse is hovering and highlighting
public void OnPointerEnter(PointerEventData eventData)
{
print(EventSystem.current.currentSelectedGameObject.name);
}
This prints null as I highlight my buttons with the mouse, how can I get the hovered/highlighted buttons?
Comment
Best Answer
Answer by Khena_B · Mar 21, 2019 at 05:19 PM
Using this seems to work
public void OnPointerEnter(PointerEventData eventData)
{
print(eventData.pointerCurrentRaycast.gameObject.name);
}
Your answer
Follow this Question
Related Questions
Can't interact with UI when using a virtual mouse, 0 Answers
How to access the OnClick event via Script 1 Answer
Button.Select(); does not highlight? 12 Answers
UI Button Focus 2 Answers
Is it wise to add scripts to Unity's Event System? 0 Answers