How to UGUI check mouse on UI?

I use unity 5.2 (UIGUI)and want to check is mouse on UI.
some one tell me like this:

EventSystem.current.IsPointerOverGameObject();

but i use new Physical Raycaster on other camera to get the click infomation.

so when my mouse on 3D objects in scene (like a box), IsPointerOverGameObject() return true.

i can not use it to check is on UI.

so, how to slove.

i think if i can get the gameobject my mouse on it and check its layer can. but i can not find the function!

thanks very much.

any body help

You can use the UnityEvents system for this.

attach this script to the UI object(s) you want to check for mouse over.

using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;

public class MouseOverUIObject : MonoBehaviour, IPointerEnterHandler {
    #region IPointerEnterHandler implementation
    public void OnPointerEnter (PointerEventData eventData)
    {
        Debug.Log(string.Format("Mouse over object {0}", name));
    }
    #endregion
}

You can also use iPointerExitHandler to check when the mouse leaves the UI object if you need to.

Hope this helps.

thank you. i use you method and slover my problem.