Anyone know if there’s an equivalent in Unity UI to NGUI’s:
UICamera.hoveredObject
Basically return whichever UI element the mouse is currently hovering over?
Anyone know if there’s an equivalent in Unity UI to NGUI’s:
UICamera.hoveredObject
Basically return whichever UI element the mouse is currently hovering over?
Yes, sort of.
/// <summary>
/// Gets the list of items clicked.
/// </summary>
/// <returns>The list of items clicked.</returns>
private List<RaycastResult> GetItemsClicked()
{
PointerEventData pointerData = new PointerEventData(EventSystem.current);
pointerData.Reset();
pointerData.position = Input.mousePosition;
List<RaycastResult> Result = new List<RaycastResult>();
EventSystem.current.RaycastAll(pointerData, Result);
return Result;
}
This will give you any “event system” object including UI that is under the mouse.
Not quite what I meant - was curious if there’s a built-in method?
Yeah, that’s why I said “sort of”. The built in method is EventSystem.current.RaycastAll… It takes a little setup to tell Unity where your mouse is at and it returns a list of UI components under the mouse (in the new UI you’re likely to have several UI components layered).
Can’t you use an Event Trigger with Pointer Enter?