How can I detect the mouseEvent is over UIElement or gameobject?

I need to distinguish between the two. Because my character will be action when I click the mouse.
I found it is not working well with “EventSystem.current.IsPointerOverGameObject” what I always been used in UGUI.
So, I need a judge logic when I click the UI or gameObject. Avoid it will execute twice in UI logic and gameObject logic.
Have any suggestion for me : )

The UIElementPointerEnter & UIElementPointerExit events might help you.

I guess your idea is make a flag when mouse enter UIElement. And judge this flag is over UI or gameObject:)
Thanks, I will try to it

It is something wrong when I move mouse enter the UI and hover it.
It will execute PointerEnterEvent and PointerOutEvent right now even if my mouse still hold in the UI.
Is my fault?

code:

print: