UI WANT TO MAKE AN IN GAME MENU, problems with script.

hi everyone, im trying to make a world space canvas and i want to interact with it in the game, so i was thinking about using Raycast to detect my UI objects like buttons and so. But i cant figure it out how to do it, i cant press the buttons with the RayCast, anyway I’ve 2 scripts one is an attemt to make my rycast detect ui mask’s and make them work, and the other one is just a simple Raycast which prints objects with colliders (it prints the button too).
Any ideas on how i can make this work.
Im a noob at scripting so forgive my poor scripts.




I voted for script.

SOLVED thanks

I used this, i put a public variable for one cam so i can asign my fps cam, and then i put a collider on my button, and it works, it makes the button do what is on the ONCLICK event. i also make sure of using the using unityengine.UI.