Function to convert UI Position to actual position?

This is hard to put into words so I hope the picture helps. My guns are in my UI, as they are 2D sprites. Each gun may have a different position for it’s muzzle so I want to draw a ray using the muzzle of the sprite and the players transform.forward.

I need to convert the UI’s position from where it is in the canvas to where it is on the screen.

Please let me know if that makes sense, or is even possible.

What you are going to want to use is Camera. ScreenToWorldPoint(new Vector3 (muzzPos.x, muzzPos.y, distanceFromCam));. That will be your muzzle position translated to world space