Raycast from GUI element

How would I raycast from a GUI element? For example, I have a crosshair that lazily follows the center of the screen or can be offset according to the needs of the player. I would like to keep raycasting from the crosshairs regardless of where it is at that moment.

I have tried

camera.ViewportToWorldPoint(guiRect.anchoredPosition);

To no avail.

Note that the crosshair is parented to several other UI elements which also move.

Thanks for your time.

Hello,

Try this:

Ray ray = Camera.main.ScreenPointToRay(uiObject.transform.position);