Programmatically, how could one easily recreate the “Frame selection” menu item inside of scripting?
In other words, how can I take a Bounds and move a camera so that its view frustum nicely frames the bounds?
Thank you,
-Jon
Programmatically, how could one easily recreate the “Frame selection” menu item inside of scripting?
In other words, how can I take a Bounds and move a camera so that its view frustum nicely frames the bounds?
Thank you,
-Jon
I’d be interested in learning how this is done, also.
Are you looking for how to call the editor function or how to do the same as the editor functionality for an in game camera?
I meant the latter.
For an in game camera.
-Jon
Essentially we have a camera similar to mouse orbit.
When you hit frame selected, we calculate the bounds of all renderers and pivot points selected. I guess how you actually get the bounds etc. is highly game specific in your case.
The new pivot point for the mouse orbit now becomes the bounding box center.
And the distance is:
bounds.extents.magnitude * magicFudeFactor
A value of 2.2 works pretty well for the magicFudeFactor but of course is highly dependent on the field of view you are using on the camera.
Frame selected only modifies the pivot point and the distance. It keeps the rotation exactly the same as before frame selected.
Thanks. That seems simple enough.
Necro. I want the original idea. I have an editor script and I want to script frame selection.
I have the game object, how do I programatically center the scene view camera on it?
Like pushing F through script?