Avoid clicks through UI

Hello,

I’m trying to make a drag function for one UI panel but because I use point and click movement for the character sometime the character move when I drag the panel even if i used EventSystem.current.IsPointerOverGameObject(). Didn’t managed to find a pattern for this bad behaviour to reproduce it, just clicked and drag around randomly.

I attached the drag and character controller script and also a gif with in game behaviour to understand better my problem.

7160110--857263--ezgif.com-gif-maker (1).gif
Any help will be appreciated.

Thank you.

PS. I noticed that if I change in player controller to Input.GetMouseButtonDown it work but I want cursive movement without clicking many times.

I think you are looking for this: