'Unity - Get point on edge of the screen that object directed to?

So this is my problem:

I have an object within the screen that points to a specific direction. For demonstration purposes, I've added a LineRenderer to show this direction.

enter image description here

My final goal is to find the distance between object and the world point where this purple ray intersects with the border of the screen (white outline).

float DistToScreenEdge = Vector2.Distance(Object.transform.position, PointOnScreenEdge);

But for that I need to get this point, and I have no clue how to do that.

Vector2 PointOnScreenEdge = ???

PNG-example

So, the Question: How can I get that "PointOnScreenEdge"?

Note that I always know the direction which object facing and its world coordinates.

On the Internet, I read that to find a world point relative to the screen, you can use Camera.ScreenToWorldPoint() and Camera.ViewportToWorldPoint() but I could not figure out how to use them correctly in this situation.

Thank you for the help.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source