- Home /
Camera settings for viewing any model like the Unity Preview
I'm interested in a way for a camera to view a variety of models that almost matches the model preview windows in Unity when you select a model. So far, I have a gameobject that I'm setting the mesh and materials at runtime based on the model I want to view.
The problem I'm having is keeping the model centered in the camera and the getting each model the same size as the one before it as each model is a little different overall size.
Anyone have an idea of how to scale the current mesh to be relative to the camera like the model preview pane in unity does?
Answer by Seth-Bergman · Jan 06, 2013 at 06:12 AM
You can use the renderer.bounds to get the size of the model, something like:
mainCamera.orthographicSize = myObject.renderer.bounds.extents.magnitude;
mainCamera.transform.position = myObject.renderer.bounds.center;
mainCamera.transform.position.z -=1000;
just an example, you may need to play around a bit to get the exact results you want..
Your answer
![](https://koobas.hobune.stream/wayback/20220613084955im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to fix FPS camera to scale of models? 0 Answers
Change UI scale in relation to 3D camera 0 Answers
Show squares in the camera 0 Answers
Unrealistic size of sun, viewed from earth 2 Answers
Colliders won't work 0 Answers