How can I get UI element over which pointer is in Unity3D?
<p>I can detect if mouse is hovering any UI element by <code>EventSystem.current.IsPointerOverGameObject()</code>.</p>

<p>But how do I know which <code>GameObjest</code> it is exactly?</p>

<p>I have tried:</p>

<pre><code>    if (EventSystem.current.IsPointerOverGameObject())
        foreach (GameObject go in new PointerEventData(EventSystem.current).hovered)
            print(go.name);
</code></pre>

<p>But in every moment <code>new PointerEventData(EventSystem.current).hovered</code> is empty whether I hover or not.</p>

<p>I can see required info using <code>print(EventSystem.current);</code>:</p>

<pre><code>&lt;b&gt;Selected:&lt;/b&gt;


&lt;b&gt;Pointer Input Module of type: &lt;/b&gt;UnityEngine.EventSystems.StandaloneInputModule
&lt;B&gt;Pointer:&lt;/b&gt; -1
&lt;b&gt;Position&lt;/b&gt;: (746.0, 535.0)
&lt;b&gt;delta&lt;/b&gt;: (60.0, -44.0)
&lt;b&gt;eligibleForClick&lt;/b&gt;: False
&lt;b&gt;pointerEnter&lt;/b&gt;: cursorInfoText (UnityEngine.GameObject)
&lt;b&gt;pointerPress&lt;/b&gt;: 
&lt;b&gt;lastPointerPress&lt;/b&gt;: 
&lt;b&gt;pointerDrag&lt;/b&gt;: 
&lt;b&gt;Use Drag Threshold&lt;/b&gt;: True
&lt;b&gt;Current Rayast:&lt;/b&gt;
Name: cursorInfoText (UnityEngine.GameObject)
module: Name: Canvas (UnityEngine.GameObject)
eventCamera: 
sortOrderPriority: 0
renderOrderPriority: 0
module camera: null
distance: 0
index: 0
depth: 1
worldNormal: (0.0, 0.0, 0.0)
worldPosition: (0.0, 0.0, 0.0)
screenPosition: (746.0, 535.0)
module.sortOrderPriority: 0
module.renderOrderPriority: 0
sortingLayer: 0
sortingOrder: 0
&lt;b&gt;Press Rayast:&lt;/b&gt;


&lt;B&gt;Pointer:&lt;/b&gt; -2
&lt;b&gt;Position&lt;/b&gt;: (746.0, 535.0)
&lt;b&gt;delta&lt;/b&gt;: (60.0, -44.0)
&lt;b&gt;eligibleForClick&lt;/b&gt;: False
&lt;b&gt;pointerEnter&lt;/b&gt;: cursorInfoText (UnityEngine.GameObject)
&lt;b&gt;pointerPress&lt;/b&gt;: 
&lt;b&gt;lastPointerPress&lt;/b&gt;: 
&lt;b&gt;pointerDrag&lt;/b&gt;: 
&lt;b&gt;Use Drag Threshold&lt;/b&gt;: True
&lt;b&gt;Current Rayast:&lt;/b&gt;
Name: cursorInfoText (UnityEngine.GameObject)
module: Name: Canvas (UnityEngine.GameObject)
eventCamera: 
sortOrderPriority: 0
renderOrderPriority: 0
module camera: null
distance: 0
index: 0
depth: 1
worldNormal: (0.0, 0.0, 0.0)
worldPosition: (0.0, 0.0, 0.0)
screenPosition: (746.0, 535.0)
module.sortOrderPriority: 0
module.renderOrderPriority: 0
sortingLayer: 0
sortingOrder: 0
&lt;b&gt;Press Rayast:&lt;/b&gt;


&lt;B&gt;Pointer:&lt;/b&gt; -3
&lt;b&gt;Position&lt;/b&gt;: (746.0, 535.0)
&lt;b&gt;delta&lt;/b&gt;: (60.0, -44.0)
&lt;b&gt;eligibleForClick&lt;/b&gt;: False
&lt;b&gt;pointerEnter&lt;/b&gt;: cursorInfoText (UnityEngine.GameObject)
&lt;b&gt;pointerPress&lt;/b&gt;: 
&lt;b&gt;lastPointerPress&lt;/b&gt;: 
&lt;b&gt;pointerDrag&lt;/b&gt;: 
&lt;b&gt;Use Drag Threshold&lt;/b&gt;: True
&lt;b&gt;Current Rayast:&lt;/b&gt;
Name: cursorInfoText (UnityEngine.GameObject)
module: Name: Canvas (UnityEngine.GameObject)
eventCamera: 
sortOrderPriority: 0
renderOrderPriority: 0
module camera: null
distance: 0
index: 0
depth: 1
worldNormal: (0.0, 0.0, 0.0)
worldPosition: (0.0, 0.0, 0.0)
screenPosition: (746.0, 535.0)
module.sortOrderPriority: 0
module.renderOrderPriority: 0
sortingLayer: 0
sortingOrder: 0
&lt;b&gt;Press Rayast:&lt;/b&gt;
</code></pre>

<p>By the way why are there 3 pointers (-1, -2, -3) and what does this mean? I've read somewhere in docs, <code>pointer -1</code> is left mouse button, but I click nothing, so this is weird.</p>

<p>I can see <code>&lt;b&gt;pointerEnter&lt;/b&gt;: cursorInfoText (UnityEngine.GameObject)</code> and <code>Name: cursorInfoText (UnityEngine.GameObject)</code> which is what I need.
But how do I extract this info? I have tried <code>print(new PointerEventData(EventSystem.current).pointerEnter);</code>, but it is <code>Null</code> doesn't matter I enter or hover. And I see no other appropriate methods or properties in docs, although I can see that info is stored. What have I missed?</p>

<p>My goal is to detect if mouse is hovering UI element with some conditions (ignore small amount of UI elements (likely by tag) and don't ignore the rest (most of elements)), so I have to get <code>GameObject</code> itself. And if mouse doesn't hover UI element (except those few), script does unrelated to UI stuff. But do not ignore if it hovers one of those few and one of the rest at the same time.</p>