Castray, camera zoom and draw line

I have two layers. One for the UI, and the other with the sprites, with default name Base Layer.
I am using zoom / pan camera on the Base Layer with “PinchGesture” and “DragCameraWithPointer” extensions. As a result, on a zoom/ pinch action, the UI text remains without alterations.

I am drawing a line between one object on UI layer and other object on BaseLayer using raycast to find xy on the BaseLayer object. All as expected.

When I apply zoom or pan, the x,y collected by raycast is pointing to the same postition. I assume this is correct because sprites positions are not changing but,

The question is, how can I draw a line between two objects in different layers updating with the zoom new ‘relative’ position to camera.

It’s easy enough if both layers have the same camera adjustments (zoom, rotation, position). Just draw from one object to the other, the layer is irrelevant.

However, if the camera positions are different for each layer, or the zoom is different for each layer, then you’ll need to involve a few calculations.

I see, thank you.

Yes, the case is the second one, then I need to do some calculations to change x, y origin and scale according to camera zoom / pan.