PreviewCameraSetup
public static class PreviewCameraSetupCentralized camera creation and positioning for all preview types. Consolidates camera logic from PreviewManager, CustomPreviewStage, and PreviewSceneSetup.
Fields
Section titled “Fields”
DefaultPreviewFOV
Section titled “DefaultPreviewFOV”public const float DefaultPreviewFOV = 30No description is available for this member.
Returns
System.Single — No return description is available.
DefaultNearClip
Section titled “DefaultNearClip”public const float DefaultNearClip = 0.01No description is available for this member.
Returns
System.Single — No return description is available.
Methods
Section titled “Methods”
CreatePreviewCamera(Scene, bool)
Section titled “CreatePreviewCamera(Scene, bool)”public static Camera CreatePreviewCamera(Scene scene, bool addToScene = true)Create and configure a preview camera in the specified scene
Parameters
| Name | Type | Description |
|---|---|---|
scene |
UnityEngine.SceneManagement.Scene | |
addToScene |
System.Boolean |
Returns
UnityEngine.Camera — No return description is available.
SetupCameraBackground(Camera)
Section titled “SetupCameraBackground(Camera)”public static void SetupCameraBackground(Camera camera)Setup camera background based on configuration
Parameters
| Name | Type | Description |
|---|---|---|
camera |
UnityEngine.Camera | |
GetBackgroundColor()
Section titled “GetBackgroundColor()”public static Color GetBackgroundColor()Get background color based on render pipeline
Returns
UnityEngine.Color — No return description is available.
PositionCameraForScene(Camera, Bounds)
Section titled “PositionCameraForScene(Camera, Bounds)”public static void PositionCameraForScene(Camera camera, Bounds bounds)Position camera for scene rendering based on scene bounds
Parameters
| Name | Type | Description |
|---|---|---|
camera |
UnityEngine.Camera | |
bounds |
UnityEngine.Bounds | |
CalculateCameraDistance(Bounds, Camera, float, float, float, float)
Section titled “CalculateCameraDistance(Bounds, Camera, float, float, float, float)”public static float CalculateCameraDistance(Bounds bounds, Camera camera, float paddingPercent, float angleX, float angleY, float fillFraction = 1)Calculate the optimal camera distance for framing an object with configurable padding. Uses a hybrid approach: projected bounds calculation verified by corner projection to ensure all 8 bounding box corners fit within the view frustum.
Parameters
| Name | Type | Description |
|---|---|---|
bounds |
UnityEngine.Bounds | The bounding box of the object to frame |
camera |
UnityEngine.Camera | The camera (for FOV) |
paddingPercent |
System.Single | Padding as a percentage (e.g., 2 for 2%) |
angleX |
System.Single | Vertical camera angle in degrees (0 = eye level, 90 = top-down) |
angleY |
System.Single | Horizontal camera angle in degrees (rotation around Y axis) |
fillFraction |
System.Single | Target viewport fill (1 = fit exactly). Lower values bring the camera closer. |
Returns
System.Single — The optimal distance from the camera to the bounds center
CalculateCameraDistance(Bounds, Camera)
Section titled “CalculateCameraDistance(Bounds, Camera)”public static float CalculateCameraDistance(Bounds bounds, Camera camera)Simplified overload using current config settings for angles and padding
Parameters
| Name | Type | Description |
|---|---|---|
bounds |
UnityEngine.Bounds | |
camera |
UnityEngine.Camera |
Returns
System.Single — No return description is available.
PositionCameraFor3D(Camera, Bounds)
Section titled “PositionCameraFor3D(Camera, Bounds)”public static void PositionCameraFor3D(Camera camera, Bounds bounds)Position perspective camera for 3D object rendering
Parameters
| Name | Type | Description |
|---|---|---|
camera |
UnityEngine.Camera | |
bounds |
UnityEngine.Bounds |