Copy the persp/ortho switch in the editor view?

Hi, I have a question that (I hope) should have a straightforward answer:

In the Editor view window, there’s a button to switch the viewpoint used in that window from Perspective view to Orthographic view. This creates a very smooth transition between the two views.

I’d like to have an effect like that in my game. I’ve done perspective-to-ortho switches before, but they don’t come out as clean-looking as that effect in the editor. Is it possible to find the code which controls this button in the editor window? Is there something obvious I can do to replicate this effect?

Thank you!

I remember having seen a custom script for this a few years ago. It transitioned from orthographic to perspective smoothly by chaning the ortho size and/or fov over time. Do some searching, I’m sure you’ll be able to find it. It was either here on UA or on the user wiki.

Edit: turns out I even bookmarked it because it seemed useful back then even though I never used it.

Smooth transition between perspective and orthographic modes