Class CameraExtensions
Extension methods for Camera components
Namespace: Unity.XRTools.Utils
Syntax
public static class CameraExtensions : object
Methods
GetHorizontalFOV(Camera)
Calculates the horizontal field of view of the camera
Declaration
public static float GetHorizontalFOV(this Camera camera)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera | camera | The camera to get the aspect ratio and vertical field of view from |
Returns
| Type | Description |
|---|---|
| Single | The horizontal field of view of the camera |
GetVerticalFOV(Camera, Single)
Calculates the vertical field of view from an aspect neutral (diagonal) field of view and the camera's aspect ratio. Unity cameras' field of view properties are storing the vertical field of view.
Declaration
public static float GetVerticalFOV(this Camera camera, float aspectNeutralFOV)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera | camera | The camera to get the aspect ratio from |
| Single | aspectNeutralFOV | The "aspect neutral" field of view, which is the diagonal field of view |
Returns
| Type | Description |
|---|---|
| Single | The vertical field of view calculated |
GetVerticalOrthoSize(Camera, Single)
Calculates the vertical orthographic size for a camera and a given diagonal size
Declaration
public static float GetVerticalOrthoSize(this Camera camera, float size)
Parameters
| Type | Name | Description |
|---|---|---|
| Camera | camera | The camera to get the aspect ratio from |
| Single | size | The diagonal orthographic size |
Returns
| Type | Description |
|---|---|
| Single | The vertical orthographic size calculated |