Raycasting on render texture, minimap

Hi. I am trying to make interactable minimap. I am using Raw image canvas to hold the second camera and RenderTexture to display the output of the second camera.

I have tried using secondcamera.ScreenPointToRay(input.mousepos) but that does not work.
I cant make the raycast to detect the second camera (canvas/render texture).

I believe that interactable minimap such as this is very common in games and there must be some general workaround for this, that is widely and always used. I need to get hover over effect on the units displayed in minimap.

What I’ve tried so far:

public void CamTest()
        if (Input.GetMouseButton(1))

            RaycastHit hit;
            Ray ray = SecondCamera.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))


But I just cant get a callback from the canvas/renderTexture what so ever. I have read on the forums that I should use the coordinates from the second camera and based on them, cast a ray from the first camera , to get the clickable object on minimap. This seems to be way too complicated for such an easy thing and It wont work for me, since I cant raycast on the minimap at all :frowning:
Thanks for the help.

You don’t need raycasting for this. The minimap is just a representation of types at positions. Since you calculate where these positions are on the minimap, you should be able to transfer the mouse cursor position into the minimap as well. Dinstance calculations in the minimap space should be enough.