Find edge of camera in direction of mouse (2D)

I’m trying to create a laser that shoots from the player towards the mouse and doesn’t stop until it either reaches the edge of the screen, or hits something along the way. I’ve managed to script a line that goes from the player to an object but if there’s no object for the laser to hit, the line will just stop where the mouse is. How can I give it a point at the edge of the screen/camera to continue to?


check it for the point of your laser end. Than check the point coordinates agains rectangle (0,0) to (1,1) if its outside its behind the edge. All you need is in the example