Unable to click UI button, tried everything I could find

I am making a 3d game and I require several UI buttons. I have to interact with both the UI and 3d space (with Physics.Raycast). When I play the game on PC standalone platform it works, but when I try with Android or Windows Phone, they don’t work. I tried with some of the suggestions from several forums like checking if !EventSystem.IsPointerOverGameObject() (and tried -1 as a parameter).
Also, I tried to make layerMasks both manually and within script, but I still can’t find the soluton for my problem.

I fixed the problem by adding CanvasGroup property to some UI element that were in front of it (I wasn’t interacting with buttons at all)