Unity 4.6 UI doesn't really like those OnMouse events, so we can't use OnMouseOver() for example. (Those are just for Colliders or GUIElements.) Instead, we use [Pointer][1] properties from [Selectable][2] under EventSystem.
You can add the following script on your [Canvas][3], or individually on UI transforms, or just attach [EventListeners][4] to them.
using UnityEngine;
using UnityEngine.EventSystems; //required for Event data
public class MouseOver : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler {
GameObject currentHover;
public void OnPointerEnter(PointerEventData eventData) {
if (eventData.pointerCurrentRaycast.gameObject != null) {
Debug.Log("Mouse Over: " + eventData.pointerCurrentRaycast.gameObject.name);
currentHover = eventData.pointerCurrentRaycast.gameObject;
}
}
public void OnPointerExit(PointerEventData eventData) {
currentHover = null;
}
void Update() {
if (currentHover)
Debug.Log(currentHover.name + " @ " + Input.mousePosition);
}
}
[1]: https://bitbucket.org/Unity-Technologies/ui/src/0155c39e05ca5d7dcc97d9974256ef83bc122586/UnityEngine.UI/EventSystem/InputModules/BaseInputModule.cs?at=5.4&fileviewer=file-view-default#BaseInputModule.cs-101
[2]: https://docs.unity3d.com/ScriptReference/UI.Selectable.html
[3]: https://stackoverflow.com/a/38539828/4393588
[4]: https://forum.unity3d.com/threads/onpointerover-a-sad-tooltip-story.282472/