Clipping a line to a rect?

I'm pretty sure I can find this out on the interwebs, but thought I'd ask if anyone knows: Is there a handy Unity API for clipping a line segment (ray for example) against a Rect or other object? Ex: from screen center to screen edge, if the endpoint were out of the screen's bounds? I'm guessing it's a simple formula, probably with a Dot in it.....

I don't think there's anything in the Unity API for line clipping specifically. However, there is Plane.Raycast(), which can be used to compute the intersection point between a ray and a plane. Depending on your needs, you might be able to make do with that (e.g. by raycasting against 4 planes corresponding to the edges of the screen).

Otherwise, yeah, you can find plenty of info on line clipping online.